Work on progress bar

This commit is contained in:
Rick Falkvinge
2018-02-11 15:35:04 +01:00
parent 869ab68f85
commit 9edbfd8c5c
5 changed files with 19 additions and 11 deletions
+4
View File
@@ -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\"}");
-6
View File
@@ -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
+1
View File
@@ -422,6 +422,7 @@
<Compile Include="Support\CheckDigit.cs" />
<Compile Include="Support\Document.cs" />
<Compile Include="Support\Documents.cs" />
<Compile Include="Support\ProgressBarBackend.cs" />
<Compile Include="Support\PWEvents.cs" />
<Compile Include="Support\Formatting.cs" />
<Compile Include="Support\LogicServices.cs" />
+8 -1
View File
@@ -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)) { %>
@@ -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);
}