Work on Upload (finally)

This commit is contained in:
Rick Falkvinge
2019-12-23 13:27:08 +01:00
parent 52712a9a96
commit 46e540fe4e
2 changed files with 32 additions and 2 deletions
+1
View File
@@ -323,6 +323,7 @@
activeUpload = null;
} else {
alert(result.DisplayMessage); // temporary debug function
// Todo: add more error handling later, maybe
clientFailedUpload();
}
+31 -2
View File
@@ -390,9 +390,38 @@ namespace Swarmops.Frontend.Pages.Ledgers
Documents documents = Documents.RecentFromDescription(guid);
// Continue here
// Safeguard 2019-Dec-23: Abort if more than one document (code below needs hardening against concurrent-threads race conditions)
throw new NotImplementedException();
if (documents.Count != 1)
{
throw new NotImplementedException();
}
// Load documents and process them as loaded strings, one by one
foreach (Document document in documents)
{
string documentData = document.GetReader().ReadToEnd();
ExternalBankDataProfile profile = account.ExternalBankDataProfile;
ExternalBankData loadedData = new ExternalBankData();
loadedData.Profile = profile;
try
{
loadedData.LoadData(documentData, authData.CurrentOrganization, account.Currency);
}
catch (Exception)
{
return new AjaxCallResult {Success = false, DisplayMessage = "ERROR_FILEDATAFORMAT"};
}
// Start async thread to import the data to the SQL database; the caller must
// check the status of the import
// Continue here
}
return new AjaxCallResult {Success = true, DisplayMessage = "SUCCESS_UPLOAD_PROCESSING"};
}
[WebMethod]