From e6e0233e6ddc50fc3ea0995535823f9e54f690bc Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Fri, 25 Nov 2022 15:58:06 +0100 Subject: [PATCH] handle incomplete transactions --- EliteBGS/MainWindow.xaml.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/EliteBGS/MainWindow.xaml.cs b/EliteBGS/MainWindow.xaml.cs index c59e57a..1d51170 100644 --- a/EliteBGS/MainWindow.xaml.cs +++ b/EliteBGS/MainWindow.xaml.cs @@ -63,10 +63,16 @@ public partial class MainWindow : Window { GenerateLog(); } - private void Loadentries_EntriesLoaded(List lines) { + private void HandleEntries(List entries) { try { TransactionParser parser = new TransactionParser(); - List transactions = parser.Parse(lines); + List transactions = parser.Parse(entries); + + // Log incomplete and remove them from the results. + foreach (var incomplete in transactions.OfType()) { + Log(incomplete.Reason); + transactions.Remove(incomplete); + } report = new Report(transactions); this.entries.ItemsSource = report.Objectives; @@ -77,6 +83,10 @@ public partial class MainWindow : Window { } } + private void Loadentries_EntriesLoaded(List lines) { + HandleEntries(lines); + } + private void Report_OnLog(string message) { StringBuilder builder = new StringBuilder(); @@ -122,11 +132,7 @@ public partial class MainWindow : Window { .ToList() ; - List transactions = parser.Parse(entries); - report = new Report(transactions); - - this.entries.ItemsSource = report.Objectives; - + HandleEntries(entries); GenerateLog(); } catch (Exception exception) { Log("Something went terribly wrong while parsing the E:D player journal.");