allow selection of commander names to post as

This commit is contained in:
Florian Stinglmayr 2024-09-18 21:36:39 +02:00
parent 007b391dc2
commit 262182cfaf
2 changed files with 15 additions and 2 deletions

View File

@ -184,7 +184,10 @@
<Separator /> <Separator />
<CheckBox x:Name="SelectAll" Content="Select All" IsChecked="True" Click="SelectAll_Click"/> <CheckBox x:Name="SelectAll" Content="Select All" IsChecked="True" Click="SelectAll_Click"/>
<Separator /> <Separator />
<mah:DropDownButton x:Name="PostToDiscord" Content="Post to Discord" /> <Label Content="Post log as" VerticalAlignment="Center" Margin="0,3,0,3" />
<ComboBox x:Name="Commanders" VerticalAlignment="Stretch" Margin="0,3,0,3" Width="180" />
<Label Content="to" VerticalAlignment="Center" Margin="0,3,0,3" />
<mah:DropDownButton x:Name="PostToDiscord" Content="Discord" />
</ToolBar> </ToolBar>
<TreeView CheckBox.Checked="TreeView_CheckBox_Updated" <TreeView CheckBox.Checked="TreeView_CheckBox_Updated"
CheckBox.Unchecked="TreeView_CheckBox_Updated" CheckBox.Unchecked="TreeView_CheckBox_Updated"

View File

@ -185,6 +185,11 @@ public partial class MainWindow : MetroWindow {
List<Transaction> transactions = parser.Parse(entries, options); List<Transaction> transactions = parser.Parse(entries, options);
Commanders.ItemsSource = parser.Commanders;
if (Commanders.Items.Count > 0) {
Commanders.SelectedIndex = 0;
}
// Filter the transactions down to the given time frame // Filter the transactions down to the given time frame
transactions = transactions transactions = transactions
.Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= end) .Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= end)
@ -673,10 +678,15 @@ public partial class MainWindow : MetroWindow {
return; return;
} }
string commander = "EDBGS";
if (Commanders.SelectedIndex >= 0) {
commander = Commanders.SelectedItem.ToString();
}
foreach (var hook in hooks) { foreach (var hook in hooks) {
try { try {
foreach (var chunk in chunks) { foreach (var chunk in chunks) {
DiscordPoster.PostToDiscord(hook, chunk); DiscordPoster.PostToDiscord(hook, chunk, commander);
} }
Log(string.Format("successfully posted to discord webhook `{0}`", hook.Name)); Log(string.Format("successfully posted to discord webhook `{0}`", hook.Name));
} catch (Exception ex) { } catch (Exception ex) {