From e27ca500ab6e8f97e71d2d826511d9d54be33f64 Mon Sep 17 00:00:00 2001 From: Niraj Gandhi Date: Wed, 14 Sep 2016 14:12:03 -0700 Subject: [PATCH 1/2] Fix the progress for ARM cmdlets --- .../Components/LongRunningOperationHelper.cs | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs index 3a12c30b613e..171a85d9e299 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs @@ -283,7 +283,7 @@ private ResourceManagerRestRestClient GetResourcesClient() /// The operation result private void UpdateProgress(TrackingOperationResult result) { - this.ProgressTrackerObject.UpdateProgress(result); + this.ProgressTrackerObject.UpdateProgress(result, this.IsResourceCreateOrUpdate); } /// @@ -332,26 +332,42 @@ internal ProgressTracker(string activityName, Func /// Logs the fact that the operation has progressed. /// /// The operation result - internal void UpdateProgress(TrackingOperationResult result) + internal void UpdateProgress(TrackingOperationResult result, bool isResourceCreateOrUpdate) { - 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); } From e8d13a2fc0412d3688ca0c8d17e386d3ad71b37e Mon Sep 17 00:00:00 2001 From: Niraj Gandhi Date: Wed, 21 Sep 2016 14:59:56 -0700 Subject: [PATCH 2/2] Updated the method summary --- .../Cmdlets/Components/LongRunningOperationHelper.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs index 171a85d9e299..9736a5bf1fb3 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/LongRunningOperationHelper.cs @@ -342,6 +342,7 @@ internal void SetProgressPercentageAndWriteProgress(double percentage) /// Logs the fact that the operation has progressed. /// /// The operation result + /// Is Create or Update operation, other option include Move etc. internal void UpdateProgress(TrackingOperationResult result, bool isResourceCreateOrUpdate) { if (isResourceCreateOrUpdate)