diff --git a/Logic/Cache/GuidCache.cs b/Logic/Cache/GuidCache.cs
index afef9f76..bf6d83b7 100644
--- a/Logic/Cache/GuidCache.cs
+++ b/Logic/Cache/GuidCache.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using Swarmops.Common;
@@ -48,7 +49,13 @@ namespace Swarmops.Logic.Cache
_cache.Remove (guidString);
}
}
-
+
+
+ public static void SetProgress(string guid, int progress)
+ {
+ GuidCache.Set(guid + "-Progress", progress.ToString(CultureInfo.InvariantCulture));
+ }
+
private static void ConditionalGarbageCollect()
{
diff --git a/Site/Automation/Json-ByGuid.aspx.cs b/Site/Automation/Json-ByGuid.aspx.cs
index 226d25a4..c7f73ff9 100644
--- a/Site/Automation/Json-ByGuid.aspx.cs
+++ b/Site/Automation/Json-ByGuid.aspx.cs
@@ -42,6 +42,7 @@ namespace Swarmops.Frontend.Automation
// if the progress object doesn't exist, assume it hasn't been initialized yet
return new AjaxCallResult {Success = false};
+
}
}
}
\ No newline at end of file
diff --git a/Site/Controls/v5/Base/ProgressBar.ascx b/Site/Controls/v5/Base/ProgressBar.ascx
index 0793fc24..6d880639 100644
--- a/Site/Controls/v5/Base/ProgressBar.ascx
+++ b/Site/Controls/v5/Base/ProgressBar.ascx
@@ -78,18 +78,21 @@
<%=this.ClientID%>_nextPollTimer = null;
SwarmopsJS.ajaxCall(
- "/Automation/Json-ByGuid.aspx/GetProgress",
+ "/Automation/Json-ByGuid.aspx/GetNonsocketProgress",
{ guid: '<%= this.Guid%>' },
function(result) {
- // Call our ordinary progress updater from the poller
+ if (result.Success) {
- progressUpdateCallback_<%=this.GuidToken%>(result.d);
+ // Call our ordinary progress updater from the poller
- // If the progress is less than 100, schedule another poll
+ progressUpdateCallback_<%=this.GuidToken%>(result.DisplayMessage);
- if (result.d < 100) {
- <%=this.ClientID%>_nextPollTimer = setTimeout(function() { <%= this.ClientID%>_progressFallbackPoll(); }, 2500);
+ // If the progress is less than 100, schedule another poll
+
+ if (result.DisplayMessage < 100) {
+ <%=this.ClientID%>_nextPollTimer = setTimeout(function() { <%= this.ClientID%>_progressFallbackPoll(); }, 2500);
+ }
}
}
);
diff --git a/Site/Controls/v5/Base/ProgressBar.ascx.cs b/Site/Controls/v5/Base/ProgressBar.ascx.cs
index f0636337..0e9d4aba 100644
--- a/Site/Controls/v5/Base/ProgressBar.ascx.cs
+++ b/Site/Controls/v5/Base/ProgressBar.ascx.cs
@@ -11,8 +11,8 @@ namespace Swarmops.Frontend.Controls.v5.Base
{
protected void Page_Load(object sender, EventArgs e)
{
- _guid = string.Empty;
- this.Header = Resources.Global.Global_ProcessingFile + "...";
+ _guid = System.Guid.NewGuid().ToString();
+ this.Header = Resources.Global.Global_ProcessingFile;
}
protected string GuidToken
diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx b/Site/Pages/v5/Financial/FileExpenseClaim.aspx
index 3d6fb0bb..0684438d 100644
--- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx
+++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx
@@ -95,25 +95,25 @@
$('#divExpensifyResults').slideUp();
expensifyProcessingHalfway = false;
+ <%=this.ProgressExpensify.ClientID%>_begin(); // starts listening / polling for progress
+
SwarmopsJS.ajaxCall
("/Pages/v5/Financial/FileExpenseClaim.aspx/InitializeExpensifyProcessing",
- { guid: '<%= this.UploadExpensify.GuidString%>' },
+ {
+ guidFiles: '<%= this.UploadExpensify.GuidString%>',
+ guidProgress: '<%= this.ProgressExpensify.Guid%>'
+ },
function(result) {
if (result.Success) {
- setTimeout(function() { updateExpensifyProgress(); }, 3000);
+
}
});
}
- function updateExpensifyProgress() {
- // This is a fallback for when the master page's Progress over socket doesn't work.
- // We're polling every three seconds just to make sure to give the user some feedback.
-
-
- }
+ function onExpensify
@@ -168,6 +168,9 @@
+
+
+
@@ -198,11 +201,8 @@
-
-
+
+
diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs
index 0f57d150..c0d6b900 100644
--- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs
+++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs
@@ -174,7 +174,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
[WebMethod(true)]
- public static AjaxCallResult InitializeExpensifyProcessing(string guid)
+ public static AjaxCallResult InitializeExpensifyProcessing(string guidFiles, string guidProgress)
{
// Start an async thread that does all the work, then return
@@ -184,7 +184,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
ProcessThreadArguments args = new ProcessThreadArguments
{
- Guid = guid,
+ GuidFiles = guidFiles,
+ GuidProgress = guidProgress,
Organization = authData.CurrentOrganization,
CurrentUser = authData.CurrentUser
};
@@ -197,7 +198,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
private class ProcessThreadArguments
{
- public string Guid { get; set; }
+ public string GuidFiles { get; set; }
+ public string GuidProgress { get; set; }
public Organization Organization { get; set; }
public Person CurrentUser { get; set; }
}
@@ -211,13 +213,14 @@ namespace Swarmops.Frontend.Pages.v5.Financial
private static void ProcessExpensifyUploadThread(object args)
{
- string guid = ((ProcessThreadArguments) args).Guid;
+ string guidProgress = ((ProcessThreadArguments) args).GuidProgress;
+ string guidFiles = ((ProcessThreadArguments)args).GuidFiles;
Person currentUser = ((ProcessThreadArguments) args).CurrentUser;
Organization organization = ((ProcessThreadArguments) args).Organization;
- Documents documents = Documents.RecentFromDescription(guid);
- GuidCache.Set(guid + "-Progress", 1); // to make sure results aren't repeated from last file
- GuidCache.Set(guid + "-Result", UploadBankFiles.ImportResultsCategory.Bad);
+ Documents documents = Documents.RecentFromDescription(guidFiles);
+ GuidCache.SetProgress(guidProgress, 1); // to make sure results aren't repeated from last file
+ GuidCache.Set(guidProgress + "-UploadResult", UploadBankFiles.ImportResultsCategory.Bad);
// default - this is what happens if exception
if (documents.Count != 1)
@@ -295,7 +298,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// Set progress to complete
// Abort
- GuidCache.Set(guid + "-Progress", 100); // terminate progress bar
+ GuidCache.Set(guidProgress, 100); // terminate progress bar
throw new BarfException();
}
@@ -375,6 +378,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
throw new BarfException(); // TODO: ASK USER
}
+ GuidCache.SetProgress(guidProgress, 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
// to fetch the receipt image.
@@ -385,10 +390,10 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// Get all receipts
-
-
for (int loop = 0; loop < recordList.Count; loop++)
{
+ GuidCache.SetProgress(guidProgress, loop * 90 / recordList.Count + 10);
+
using (WebClient client = new WebClient())
{
string receiptResource = client.DownloadString(recordList[loop].ReceiptUrl);
diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.designer.cs b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.designer.cs
index 79db9c53..7c0d440f 100644
--- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.designer.cs
+++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.designer.cs
@@ -219,6 +219,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
///
protected global::System.Web.UI.WebControls.Label LabelBankAccount;
+ ///
+ /// ProgressExpensifyFake control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::Swarmops.Frontend.Controls.v5.Base.ProgressBarFake ProgressExpensifyFake;
+
///
/// LabelProcessingComplete control.
///
@@ -283,12 +292,12 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
protected global::System.Web.UI.WebControls.Label LabelExpensifyCsv;
///
- /// LabelProcessing control.
+ /// ProgressExpensify control.
///
///
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
///
- protected global::System.Web.UI.WebControls.Label LabelProcessing;
+ protected global::Swarmops.Frontend.Controls.v5.Base.ProgressBar ProgressExpensify;
}
}