Skip to content

Commit f3976b9

Browse files
authored
Merge pull request #2941 from gandhiniraj/dev
Fix the ARM cmdlet to show the progress bar for long running operation
2 parents e1fce16 + 69728ec commit f3976b9

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private ResourceManagerRestRestClient GetResourcesClient()
283283
/// <param name="result">The operation result</param>
284284
private void UpdateProgress(TrackingOperationResult result)
285285
{
286-
this.ProgressTrackerObject.UpdateProgress(result);
286+
this.ProgressTrackerObject.UpdateProgress(result, this.IsResourceCreateOrUpdate);
287287
}
288288

289289
/// <summary>
@@ -332,26 +332,43 @@ internal ProgressTracker(string activityName, Func<ResourceManagerRestRestClient
332332
this.ProgressRecord = new ProgressRecord(activityId: 0, activity: activityName, statusDescription: "Starting - 0.00% completed.");
333333
}
334334

335+
internal void SetProgressPercentageAndWriteProgress(double percentage)
336+
{
337+
this.SetProgressRecordPercentComplete(percentage);
338+
this.WriteProgressAction(this.ProgressRecord);
339+
}
340+
335341
/// <summary>
336342
/// Logs the fact that the operation has progressed.
337343
/// </summary>
338344
/// <param name="result">The operation result</param>
339-
internal void UpdateProgress(TrackingOperationResult result)
345+
/// <param name="isResourceCreateOrUpdate">Is Create or Update operation, other option include Move etc.</param>
346+
internal void UpdateProgress(TrackingOperationResult result, bool isResourceCreateOrUpdate)
340347
{
341-
var currentState = this.GetOperationState(result.OperationResult);
342-
343-
if (result.Failed || currentState == null || !this.LastState.EqualsInsensitively(currentState))
348+
if (isResourceCreateOrUpdate)
344349
{
345-
this.SetProgressRecordPercentComplete(100.0);
346-
this.WriteProgressAction(this.ProgressRecord);
347-
}
350+
var currentState = this.GetOperationState(result.OperationResult);
348351

349-
if (currentState == null)
352+
if (result.Failed || currentState == null || !this.LastState.EqualsInsensitively(currentState))
353+
{
354+
this.SetProgressPercentageAndWriteProgress(100.0);
355+
}
356+
357+
if (currentState == null)
358+
{
359+
return;
360+
}
361+
362+
this.LastState = currentState;
363+
}
364+
else
350365
{
351-
return;
366+
if(result.Failed)
367+
{
368+
this.SetProgressPercentageAndWriteProgress(100.0);
369+
}
352370
}
353371

354-
this.LastState = currentState;
355372
this.SetProgressRecordPercentComplete(result.OperationResult.PercentComplete);
356373
this.WriteProgressAction(this.ProgressRecord);
357374
}

0 commit comments

Comments
 (0)