diff --git a/DataStore/DataStructures.cs b/DataStore/DataStructures.cs index 688a016..cc10f29 100644 --- a/DataStore/DataStructures.cs +++ b/DataStore/DataStructures.cs @@ -33,6 +33,35 @@ public class KasAddressList //Address-Set this.owner_id = owner_id; } + public async Task 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 GenerateName(string basic_type, bool? is_rest = false) { string pre = ""; diff --git a/MainWindow.axaml b/MainWindow.axaml index e29141c..f945f1f 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -124,6 +124,14 @@ + + + + + + + @@ -315,7 +323,7 @@ - + diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index 06e83ad..84a7259 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -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) { if (Addressmanagement.IsVisible && Addressmanagement.IsVisible)