diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index 0b220794..2fc0bd8a 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; using Swarmops.Logic.Communications; using Swarmops.Logic.Financial; @@ -133,5 +134,32 @@ namespace Swarmops.Logic.Support SetForeignObject(new TemporaryIdentity(0)); } + + protected static string StorageRoot + { + get + { + if (Debugger.IsAttached) + { + return @"C:\Windows\Temp\\Swarmops-Debug\\"; // Windows debugging environment + } + else + { + return "/opt/swarmops/upload/"; // production location on Debian installation TODO: config file + } + } + } + + public StreamReader GetReader(Encoding encoding) + { + return new StreamReader(StorageRoot + this.ServerFileName, encoding); + } + + public StreamReader GetReader(int encodingCodePage) + { + return GetReader(Encoding.GetEncoding(encodingCodePage)); + } + + } } diff --git a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs index 744d18f7..0f316083 100644 --- a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs +++ b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx.cs @@ -4,7 +4,9 @@ using System.Globalization; using System.IO; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using System.Web; +using System.Web.Services; using System.Web.UI; using System.Web.UI.WebControls; using Swarmops.Logic.Swarm; @@ -194,6 +196,14 @@ namespace Swarmops.Site.Pages.Ledgers initThread.Start(args); } + private class ProcessThreadArguments + { + public string Guid { get; set; } + public Organization Organization { get; set; } + public FinancialAccount Account { get; set; } + } + + private static void ProcessUploadThread(object args) { @@ -211,9 +221,9 @@ namespace Swarmops.Site.Pages.Ledgers FinancialAccount account = ((ProcessThreadArguments)args).Account; ExternalBankData externalData = new ExternalBankData(); - externalData.Profile = ExternalBankDataProfile.FromIdentity(ExternalBankDataProfile.SESebId); // TODO: HACK HACK HACK HACK LOAD + externalData.Profile = account.ExternalBankDataProfile; - using (StreamReader reader = new StreamReader(StorageRoot + uploadedDoc.ServerFileName, Encoding.GetEncoding(1252))) + using (StreamReader reader = uploadedDoc.GetReader(1252)) { externalData.LoadData(reader, ((ProcessThreadArguments) args).Organization); }