[feat:] csv export (no adpac)

This commit is contained in:
2026-10-21 15:56:13 +02:00
parent f09ccc883d
commit d1fc214c10
3 changed files with 65 additions and 1 deletions
+29
View File
@@ -33,6 +33,35 @@ public class KasAddressList //Address-Set
this.owner_id = owner_id; this.owner_id = owner_id;
} }
public async Task<string> GenerateCSV()
{
var customer = Customer.GetCustomerByID(owner_id);
// using adpac
string result = "";
string sep = customer.separator + " ";
if(customer.patch == null)
{
result = $"refsid{sep} anrede{sep} titel{sep} vorname{sep} adel{sep} name{sep} namezus{sep} anredzus{sep} strasse{sep} strasse2{sep} plz{sep} ort{sep} land{sep} pplz{sep} postfach{sep} name1{sep} name2{sep} name3{sep} name4{sep} name5{sep} funktion{sep} funktion2{sep} abteilung{sep} funktionad{sep} lastupdate\n";
}
foreach(var item in KasPersons)
{
if(customer.patch != null) // Fall 1: adpac
{
// Fall 1: adpac
} else // Fall 2: kein adpac:
{
// refsid anrede titel vorname adel name namezus anredzus strasse strasse2 plz ort land pplz postfach name1 name2 name3 name4 name5 funktion funktion2 abteilung funktionad lastupdate
result += item.refsid + sep + item.anrede+ sep + item.titel+ sep + item.vorname+ sep + item.adel+ sep + item.name+ sep + item.namezus+ sep + item.anredzus+ sep + item.strasse+ sep + item.strasse2+ sep + item.plz+ sep + item.ort+ sep + item.land+ sep + item.pplz+ sep + item.postfach+ sep + item.name1+ sep + item.name2+ sep + item.name3+ sep + item.name4+ sep + item.name5+ sep + item.funktion+ sep + item.funktion2+ sep + item.abteilung+ sep + item.funktionad+ sep + "null\n";
}
}
return result;
}
public static async Task<string> GenerateName(string basic_type, bool? is_rest = false) public static async Task<string> GenerateName(string basic_type, bool? is_rest = false)
{ {
string pre = ""; string pre = "";
+9 -1
View File
@@ -124,6 +124,14 @@
</StackPanel> </StackPanel>
</MenuItem.Header> </MenuItem.Header>
</MenuItem> </MenuItem>
<MenuItem x:Name="MnIAdSetExp" Click="MnIAdSetExp_OnClick">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<LucideIcon Kind="FileUp" Width="12" Height="12" Size="12" />
<Label Content="Exportieren (CSV)" VerticalContentAlignment="Center" />
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem x:Name="MnIAdSetDelete" Click="MnIAdSetDelete_OnClick" IsEnabled="True"> <MenuItem x:Name="MnIAdSetDelete" Click="MnIAdSetDelete_OnClick" IsEnabled="True">
<MenuItem.Header> <MenuItem.Header>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
@@ -315,7 +323,7 @@
<Grid Grid.Row="2" Margin="20" ColumnDefinitions="*,5*,*" IsVisible="False" x:Name="GrdExportMarginOptions"> <Grid Grid.Row="2" Margin="20" ColumnDefinitions="*,5*,*" IsVisible="False" x:Name="GrdExportMarginOptions">
<ScrollViewer Grid.Column="1"> <ScrollViewer Grid.Column="1">
<StackPanel Margin="5,5,5,5" Orientation="Vertical" Spacing="20" Background="AliceBlue" > <StackPanel Margin="5,5,5,5" Orientation="Vertical" Spacing="20" Background="AliceBlue" >
<CheckBox Content="Versandetiketten erstellen" x:Name="CbExpLabEnable"></CheckBox> <CheckBox Content="Versandetiketten erstellen" x:Name="CbExpLabEnable" Margin="10,10,10,0"></CheckBox>
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="20" Margin="10,10,10,0"> <Grid ColumnDefinitions="*,*,*" ColumnSpacing="20" Margin="10,10,10,0">
<StackPanel Orientation="Vertical" Spacing="10"> <StackPanel Orientation="Vertical" Spacing="10">
<Grid ColumnDefinitions="*,*"> <Grid ColumnDefinitions="*,*">
+27
View File
@@ -1479,6 +1479,33 @@ public partial class MainWindow : Window
} }
} }
private async void MnIAdSetExp_OnClick(object? sender, RoutedEventArgs e)
{
var topLevel = TopLevel.GetTopLevel(this);
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
Title = "Select a Folder",
AllowMultiple = false
});
if (folders.Count > 0)
{
var folderPath = folders[0].Path.LocalPath;
if (LstCustomerAdressSets.SelectedItems.Count > 0)
{
foreach (var set in LstCustomerAdressSets.SelectedItems)
{
string output = await ((KasAddressList)set).GenerateCSV();
File.WriteAllText(Path.Combine(folderPath,((KasAddressList)set).Name + ".csv"), output);
}
}
}
}
private void BtnAdmgmt_OnClick(object? sender, RoutedEventArgs e) private void BtnAdmgmt_OnClick(object? sender, RoutedEventArgs e)
{ {
if (Addressmanagement.IsVisible && Addressmanagement.IsVisible) if (Addressmanagement.IsVisible && Addressmanagement.IsVisible)