2022-02-18 Fixed CsvImportProcess wasn't used, Changed Member banktransferregex -> Contains

This commit is contained in:
phantomix 2022-02-18 22:34:28 +01:00
parent 4d16e11b6e
commit 64ae7f6c4b
4 changed files with 25 additions and 13 deletions

View File

@ -261,6 +261,12 @@ namespace dezentrale.core
TimeSpan tsLastMail = ProgramStartTime.Subtract(m.LastCronjobBalanceMail); TimeSpan tsLastMail = ProgramStartTime.Subtract(m.LastCronjobBalanceMail);
bool skipInsufficientNotify = ((DateTime.Now.Day < 8) || (tsLastMail.TotalDays < 14)); bool skipInsufficientNotify = ((DateTime.Now.Day < 8) || (tsLastMail.TotalDays < 14));
if(m.Number == 37)
{
//Sixtus detected
Console.WriteLine("Sixtus detected");
}
int currentDebtLevel = 0; //no payments missed int currentDebtLevel = 0; //no payments missed
//Account balance is capped to -2 monthly fees //Account balance is capped to -2 monthly fees

View File

@ -9,18 +9,16 @@ namespace dezentrale.core
{ {
public class CsvImportProcess : BackgroundProcess public class CsvImportProcess : BackgroundProcess
{ {
private string fileName = ""; public string FileName { get; set; } = "";
public CsvImportProcess(string fileName) public CsvImportProcess()
{ {
this.fileName = fileName;
Caption = "Import CSV Money Transfers"; Caption = "Import CSV Money Transfers";
Steps = 3; Steps = 5;
} }
protected override bool Run() protected override bool Run()
{ {
uint step = 0; uint step = 0;
LogTarget.LogLine($"Importing from {fileName}", LogEvent.ELogLevel.Info, "CsvImportProcess"); LogTarget.LogLine($"Importing from {FileName}", LogEvent.ELogLevel.Info, "CsvImportProcess");
List<BankTransfer> tmpList = new List<BankTransfer>(); List<BankTransfer> tmpList = new List<BankTransfer>();
List<string> headlineFields = null; List<string> headlineFields = null;
@ -32,7 +30,7 @@ namespace dezentrale.core
LogTarget.StepStarted(++step, "Reading file..."); LogTarget.StepStarted(++step, "Reading file...");
try try
{ {
csv.ReadFile(fileName); csv.ReadFile(FileName);
LogTarget.StepCompleted(step, "Done reading file.", true); LogTarget.StepCompleted(step, "Done reading file.", true);
} catch(Exception ex) } catch(Exception ex)
{ {
@ -59,7 +57,7 @@ namespace dezentrale.core
continue; continue;
} }
BankTransfer bt = new BankTransfer(headlineFields, l, fileName, csvLine); BankTransfer bt = new BankTransfer(headlineFields, l, FileName, csvLine);
MoneyTransfer duplicate = Program.MoneyTransfers.FindEqualEntry(bt); MoneyTransfer duplicate = Program.MoneyTransfers.FindEqualEntry(bt);
if (duplicate != null) if (duplicate != null)
{ {
@ -116,7 +114,7 @@ namespace dezentrale.core
} }
catch (Exception ex) catch (Exception ex)
{ {
LogTarget.LogLine($"Error while processing csv file \"{fileName}\": {ex.Message}", LogEvent.ELogLevel.Error, "CsvImportProcess"); LogTarget.LogLine($"Error while processing csv file \"{FileName}\": {ex.Message}", LogEvent.ELogLevel.Error, "CsvImportProcess");
return false; return false;
} }
} }

View File

@ -180,9 +180,10 @@ namespace dezentrale.model
try try
{ {
if (!string.IsNullOrEmpty(BankTransferRegEx)) if (!string.IsNullOrEmpty(BankTransferRegEx))
{ {
if (Regex.IsMatch(t.TransferReason, BankTransferRegEx)) if(!t.TransferReason.ToLower().Contains(BankTransferRegEx.ToLower()))
return true; return false;
//if (Regex.IsMatch(t.TransferReason, BankTransferRegEx)) return true;
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -465,7 +465,14 @@ namespace dezentrale.view
if (dr == DialogResult.OK) if (dr == DialogResult.OK)
{ {
lstMembers.SuspendLayout(); lstMembers.SuspendLayout();
ProcessCsv.ProcessCSV(ofd.FileName);
CsvImportProcess csvImport = new CsvImportProcess()
{
FileName = ofd.FileName,
};
frmProcessWithLog frmCsvImport = new frmProcessWithLog(csvImport, true);
dr = frmCsvImport.ShowDialog();
foreach (Member m in Program.members.Entries) lstMembers.UpdateEntry(m); foreach (Member m in Program.members.Entries) lstMembers.UpdateEntry(m);
if (Program.MoneyTransfersLoaded) if (Program.MoneyTransfersLoaded)