Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the ARM cmdlet to show the progress bar for long running operation #2941

Merged
merged 4 commits into from
Sep 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private ResourceManagerRestRestClient GetResourcesClient()
/// <param name="result">The operation result</param>
private void UpdateProgress(TrackingOperationResult result)
{
this.ProgressTrackerObject.UpdateProgress(result);
this.ProgressTrackerObject.UpdateProgress(result, this.IsResourceCreateOrUpdate);
}

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include ///summary

internal void SetProgressPercentageAndWriteProgress(double percentage)
{
this.SetProgressRecordPercentComplete(percentage);
this.WriteProgressAction(this.ProgressRecord);
}

/// <summary>
/// Logs the fact that the operation has progressed.
/// </summary>
/// <param name="result">The operation result</param>
internal void UpdateProgress(TrackingOperationResult result)
/// <param name="isResourceCreateOrUpdate">Is Create or Update operation, other option include Move etc.</param>
internal void UpdateProgress(TrackingOperationResult result, bool isResourceCreateOrUpdate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change isResourceCreateOrUpdate to something more generic, like isLongRunning. This is because we need the progress for not just create or update, but for other operations like resource move

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we have two categories for progress bar - if its Create/Update or everything else, hence IMHO this is sufficient

{
var currentState = this.GetOperationState(result.OperationResult);

if (result.Failed || currentState == null || !this.LastState.EqualsInsensitively(currentState))
if (isResourceCreateOrUpdate)
{
this.SetProgressRecordPercentComplete(100.0);
this.WriteProgressAction(this.ProgressRecord);
}
var currentState = this.GetOperationState(result.OperationResult);

if (currentState == null)
if (result.Failed || currentState == null || !this.LastState.EqualsInsensitively(currentState))
{
this.SetProgressPercentageAndWriteProgress(100.0);
}

if (currentState == null)
{
return;
}

this.LastState = currentState;
}
else
{
return;
if(result.Failed)
{
this.SetProgressPercentageAndWriteProgress(100.0);
}
}

this.LastState = currentState;
this.SetProgressRecordPercentComplete(result.OperationResult.PercentComplete);
this.WriteProgressAction(this.ProgressRecord);
}
Expand Down