diff --git a/FrontSocket/FrontendServices.cs b/FrontSocket/FrontendServices.cs index b65e8b64..2e2539fe 100644 --- a/FrontSocket/FrontendServices.cs +++ b/FrontSocket/FrontendServices.cs @@ -51,6 +51,10 @@ namespace Swarmops.Frontend.Socket case "Metapackage": ProcessMetapackage((string) json["XmlData"]); break; + case "BroadcastProgress": + Sessions.Broadcast("{\"messageType\":\"ProgressUpdate\",\"Guid\":\"" + json["Guid"] + + "\",\"Progress\":\"" + json["Progress"] + "\"}"); + break; case "Ping": // TODO: Request heartbeat from backend // Sessions.Broadcast("{\"messageType\":\"Heartbeat\"}"); diff --git a/Logic/Cache/GuidCache.cs b/Logic/Cache/GuidCache.cs index 8711980d..20c1bd36 100644 --- a/Logic/Cache/GuidCache.cs +++ b/Logic/Cache/GuidCache.cs @@ -51,12 +51,6 @@ namespace Swarmops.Logic.Cache } - public static void SetProgress(string guid, int progress) - { - GuidCache.Set(guid + "-Progress", progress); - } - - private static void ConditionalGarbageCollect() { lock (_cache) // thread safety diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index bb965b75..60e03ed5 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -422,6 +422,7 @@ + diff --git a/Site/Controls/v5/Base/ProgressBar.ascx b/Site/Controls/v5/Base/ProgressBar.ascx index 3432c877..8301240d 100644 --- a/Site/Controls/v5/Base/ProgressBar.ascx +++ b/Site/Controls/v5/Base/ProgressBar.ascx @@ -37,7 +37,7 @@ $("#Div_<%=this.ClientID %>_ProgressBar .progressbar-value").animate( { - width: "100%" + width: newProgress + "%" }, { queue: false }); if (<%=this.ClientID%>_lastProgress < 50 && newProgress >= 50) { @@ -51,6 +51,13 @@ } if (<%=this.ClientID%>_lastProgress < 100 && newProgress >= 100) { + + $("#Div_<%=this.ClientID %>_ProgressBar .progressbar-value").animate( + { + width: "100%" + }, { queue: false }); + + // check for completion callback <% if (!String.IsNullOrEmpty(this.OnClientProgressCompleteCallback)) { %> diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs index 01c39418..20cc42a4 100644 --- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs +++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs @@ -218,8 +218,10 @@ namespace Swarmops.Frontend.Pages.v5.Financial Person currentUser = ((ProcessThreadArguments) args).CurrentUser; Organization organization = ((ProcessThreadArguments) args).Organization; + ProgressBarBackend progress = new ProgressBarBackend(guidProgress); + Documents documents = Documents.RecentFromDescription(guidFiles); - GuidCache.SetProgress(guidProgress, 1); // to make sure results aren't repeated from last file + progress.Set(1); GuidCache.Set(guidProgress + "-UploadResult", UploadBankFiles.ImportResultsCategory.Bad); // default - this is what happens if exception @@ -378,7 +380,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial throw new BarfException(); // TODO: ASK USER } - GuidCache.SetProgress(guidProgress, 10); + progress.Set(10); // We now need to get all the receipt images. This is a little tricky as we don't have the URL // of the receipt directly, we only have the URL of a webpage that contains JavaScript code @@ -392,7 +394,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial for (int loop = 0; loop < recordList.Count; loop++) { - GuidCache.SetProgress(guidProgress, loop * 90 / recordList.Count + 10); + progress.Set(guidProgress, loop * 90 / recordList.Count + 10); using (WebClient client = new WebClient()) { @@ -462,7 +464,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial // TODO: Once user has confirmed budgets, save expenses - GuidCache.SetProgress(guidProgress, 100); + progress.Set(100); }