allow a choice whether to collate entries

This commit is contained in:
Florian Stinglmayr 2022-11-05 21:02:51 +01:00
parent ed26c48f5f
commit 03e7fcbc15
3 changed files with 15 additions and 12 deletions

View File

@ -49,7 +49,7 @@ namespace EliteBGS.BGS {
; ;
} }
public void Scan(PlayerJournal journal, DateTime start, DateTime end) { public void Scan(PlayerJournal journal, DateTime start, DateTime end, bool CollateEntries = true) {
/* Log files only get rotated if you restart the game client. This means that there might /* Log files only get rotated if you restart the game client. This means that there might
* be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This * be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This
* happens if you happen to play a session late into the night. * happens if you happen to play a session late into the night.
@ -72,10 +72,10 @@ namespace EliteBGS.BGS {
.Where(e => e.Timestamp >= start && e.Timestamp < actualend) .Where(e => e.Timestamp >= start && e.Timestamp < actualend)
.ToList() .ToList()
; ;
Scan(entries); Scan(entries, CollateEntries);
} }
public void Scan(List<Entry> entries) { public void Scan(List<Entry> entries, bool CollateEntries = true) {
if (entries.Count <= 0) { if (entries.Count <= 0) {
return; return;
} }
@ -198,7 +198,7 @@ namespace EliteBGS.BGS {
System = current_system, System = current_system,
Faction = faction, Faction = faction,
}); });
collate = true; collate = CollateEntries;
} else if (e.Is(Events.MissionCompleted)) { } else if (e.Is(Events.MissionCompleted)) {
MissionCompletedEntry completed = e as MissionCompletedEntry; MissionCompletedEntry completed = e as MissionCompletedEntry;
MissionAcceptedEntry accepted = null; MissionAcceptedEntry accepted = null;
@ -411,7 +411,7 @@ namespace EliteBGS.BGS {
/* Mission failed should be collated if they are in the same system/station /* Mission failed should be collated if they are in the same system/station
*/ */
collate = true; collate = CollateEntries;
} else if (e.Is(Events.SellExplorationData)) { } else if (e.Is(Events.SellExplorationData)) {
results.Add(new Cartographics(e as SellExplorationDataEntry) { results.Add(new Cartographics(e as SellExplorationDataEntry) {
System = current_system, System = current_system,
@ -420,7 +420,7 @@ namespace EliteBGS.BGS {
}); });
/* colate single cartographic selling into one */ /* colate single cartographic selling into one */
collate = true; collate = CollateEntries;
} else if (e.Is(Events.SellOrganicData)) { } else if (e.Is(Events.SellOrganicData)) {
/* organic data sold to Vista Genomics */ /* organic data sold to Vista Genomics */
results.Add(new OrganicData(e as SellOrganicDataEntry) { results.Add(new OrganicData(e as SellOrganicDataEntry) {
@ -429,7 +429,7 @@ namespace EliteBGS.BGS {
Faction = controlling_faction, Faction = controlling_faction,
}); });
collate = true; collate = CollateEntries;
} else if (e.Is(Events.MultiSellExplorationData)) { } else if (e.Is(Events.MultiSellExplorationData)) {
/* For multi-sell-exploraton-data only the controlling faction of the station sold to matters. /* For multi-sell-exploraton-data only the controlling faction of the station sold to matters.
*/ */
@ -439,7 +439,7 @@ namespace EliteBGS.BGS {
Faction = controlling_faction Faction = controlling_faction
}); });
collate = true; collate = CollateEntries;
} else if (e.Is(Events.RedeemVoucher)) { } else if (e.Is(Events.RedeemVoucher)) {
RedeemVoucherEntry voucher = e as RedeemVoucherEntry; RedeemVoucherEntry voucher = e as RedeemVoucherEntry;
List<Faction> current_factions = new List<Faction>(); List<Faction> current_factions = new List<Faction>();
@ -470,7 +470,7 @@ namespace EliteBGS.BGS {
}); });
} }
collate = true; collate = CollateEntries;
} else if (e.Is(Events.SellMicroResources)) { } else if (e.Is(Events.SellMicroResources)) {
results.Add(new SellMicroResources(e as SellMicroResourcesEntry) { results.Add(new SellMicroResources(e as SellMicroResourcesEntry) {
Faction = controlling_faction, Faction = controlling_faction,
@ -490,7 +490,7 @@ namespace EliteBGS.BGS {
System = current_system, System = current_system,
}); });
collate = true; collate = CollateEntries;
} else if (e.Is(Events.SearchAndRescue)) { } else if (e.Is(Events.SearchAndRescue)) {
results.Add(new SearchAndRescue(e as SearchAndRescueEntry) { results.Add(new SearchAndRescue(e as SearchAndRescueEntry) {
Faction = controlling_faction, Faction = controlling_faction,
@ -498,7 +498,7 @@ namespace EliteBGS.BGS {
System = current_system, System = current_system,
}); });
collate = true; collate = CollateEntries;
} else if (e.Is(Events.MarketSell)) { } else if (e.Is(Events.MarketSell)) {
MarketSellEntry sell = e as MarketSellEntry; MarketSellEntry sell = e as MarketSellEntry;
long profit = 0; long profit = 0;

View File

@ -50,6 +50,8 @@
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/> <Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/> <DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/> <Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<CheckBox x:Name="collate" Margin="1" Content="Collate entries" IsChecked="True" IsThreeState="False"/>
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" /> <Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
</ToolBar> </ToolBar>
<TreeView x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp"> <TreeView x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp">

View File

@ -110,10 +110,11 @@ namespace EliteBGS {
private void ParseJournal_Click(object sender, RoutedEventArgs e) { private void ParseJournal_Click(object sender, RoutedEventArgs e) {
try { try {
bool collate = (this.collate.IsChecked ?? true);
journal.Open(); // Load all files journal.Open(); // Load all files
var start = startdate.SelectedDate ?? DateTime.Now; var start = startdate.SelectedDate ?? DateTime.Now;
var end = enddate.SelectedDate ?? DateTime.Now; var end = enddate.SelectedDate ?? DateTime.Now;
report.Scan(journal, start, end); report.Scan(journal, start, end, collate);
RefreshObjectives(); RefreshObjectives();
} catch (Exception exception) { } catch (Exception exception) {
Log("Something went terribly wrong while parsing the E:D player journal."); Log("Something went terribly wrong while parsing the E:D player journal.");