From 13549e7ec4b8616914542f1025545285a4e9acaf Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Fri, 14 Apr 2023 16:39:14 +1000 Subject: [PATCH] bug fix: calculate task progress offsets and multiplier correctly --- Disco.Services/Tasks/ScheduledTaskStatus.cs | 38 ++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/Disco.Services/Tasks/ScheduledTaskStatus.cs b/Disco.Services/Tasks/ScheduledTaskStatus.cs index b08bcd6f..4a08b4cf 100644 --- a/Disco.Services/Tasks/ScheduledTaskStatus.cs +++ b/Disco.Services/Tasks/ScheduledTaskStatus.cs @@ -117,7 +117,7 @@ namespace Disco.Services.Tasks } #region Progress Actions - private byte CalculateProgressValue(byte Progress) + private byte CalculateProgressValue(double Progress) { return (byte)((Progress * ProgressMultiplier) + ProgressOffset); } @@ -129,7 +129,8 @@ namespace Disco.Services.Tasks } public void UpdateStatus(double Progress) { - UpdateStatus((byte)Progress); + _progress = CalculateProgressValue(Progress); + UpdateTriggered("Progress", _progress); } public void UpdateStatus(string CurrentDescription) { @@ -157,7 +158,19 @@ namespace Disco.Services.Tasks } public void UpdateStatus(double Progress, string CurrentDescription) { - UpdateStatus((byte)Progress, CurrentDescription); + _progress = CalculateProgressValue(Progress); + + var changedProperties = new List() { + new ChangedItem("Progress", Progress) + }; + + if (!IgnoreCurrentDescription) + { + _currentDescription = CurrentDescription; + changedProperties.Add(new ChangedItem("CurrentDescription", CurrentDescription)); + } + + UpdateTriggered(changedProperties.ToArray()); } public void UpdateStatus(byte Progress, string CurrentProcess, string CurrentDescription) { @@ -182,7 +195,24 @@ namespace Disco.Services.Tasks } public void UpdateStatus(double Progress, string CurrentProcess, string CurrentDescription) { - UpdateStatus((byte)Progress, CurrentProcess, CurrentDescription); + _progress = CalculateProgressValue(Progress); + + var changedProperties = new List() { + new ChangedItem("Progress", Progress) + }; + + if (!IgnoreCurrentProcessChanges) + { + _currentProcess = CurrentProcess; + changedProperties.Add(new ChangedItem("CurrentProcess", CurrentProcess)); + } + if (!IgnoreCurrentDescription) + { + _currentDescription = CurrentDescription; + changedProperties.Add(new ChangedItem("CurrentDescription", CurrentDescription)); + } + + UpdateTriggered(changedProperties.ToArray()); } #endregion