From e948cc0ce1dff52091805dd0a5c79727b2652513 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Mon, 2 Nov 2026 14:10:49 +0100 Subject: [PATCH] [chore:] csv export utils --- DataStore/DataStructures.cs | 90 +++++++++++++++++++++-- Tasks/AddressPatch.cs | 138 ++++++++++++++++++------------------ 2 files changed, 155 insertions(+), 73 deletions(-) diff --git a/DataStore/DataStructures.cs b/DataStore/DataStructures.cs index cc10f29..e64af6e 100644 --- a/DataStore/DataStructures.cs +++ b/DataStore/DataStructures.cs @@ -33,22 +33,26 @@ public class KasAddressList //Address-Set this.owner_id = owner_id; } - public async Task GenerateCSV() + public async Task GenerateCSV(bool expAsAdpac) { var customer = Customer.GetCustomerByID(owner_id); // using adpac string result = ""; string sep = customer.separator + " "; - if(customer.patch == null) + if(customer.patch != null && expAsAdpac) + { + string header = customer.patch.GetCSVHeader(sep); + } else { 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 + if(customer.patch != null && expAsAdpac) // Fall 1: adpac { // Fall 1: adpac + result += item.getAdpacValues(sep,customer.patch) + "\n"; + } 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 @@ -257,6 +261,84 @@ public class KasPerson return id + " - " + name; } + + public string getAdpacValues(string sep,AddressPatch ap) + { + string output = ""; + if(ap.has_refsid){ + output += ap.refsid_is + sep + " "; + } + if(ap.has_anrede){ + output += ap.anrede_is + sep + " "; + } + if(ap.has_titel){ + output += ap.titel_is + sep + " "; + } + if(ap.has_vorname){ + output += ap.vorname_is + sep + " "; + } + if(ap.has_adel){ + output += ap.adel_is + sep + " "; + } + if(ap.has_name){ + output += ap.name_is + sep + " "; + } + if(ap.has_namezus){ + output += ap.namezus_is + sep + " "; + } + if(ap.has_anredzus){ + output += ap.anredzus_is + sep + " "; + } + if(ap.has_strasse){ + output += ap.strasse_is + sep + " "; + } + if(ap.has_strasse2){ + output += ap.strasse2_is + sep + " "; + } + if(ap.has_plz){ + output += ap.plz_is + sep + " "; + } + if(ap.has_ort){ + output += ap.ort_is + sep + " "; + } + if(ap.has_land){ + output += ap.land_is + sep + " "; + } + if(ap.has_pplz){ + output += ap.pplz_is + sep + " "; + } + if(ap.has_postfach){ + output += ap.postfach_is + sep + " "; + } + if(ap.has_name1){ + output += ap.name1_is + sep + " "; + } + if(ap.has_name2){ + output += ap.name2_is + sep + " "; + } + if(ap.has_name3){ + output += ap.name3_is + sep + " "; + } + if(ap.has_name4){ + output += ap.name4_is + sep + " "; + } + if(ap.has_name5){ + output += ap.name5_is + sep + " "; + } + if(ap.has_funktion){ + output += ap.funktion_is + sep + " "; + } + if(ap.has_funktion2){ + output += ap.funktion2_is + sep + " "; + } + if(ap.has_abteilung){ + output += ap.abteilung_is + sep + " "; + } + if(ap.has_funktionad){ + output += ap.funktionad_is + sep + " "; + } + return output; + } } public class KasPersonError diff --git a/Tasks/AddressPatch.cs b/Tasks/AddressPatch.cs index b5100cd..522e147 100644 --- a/Tasks/AddressPatch.cs +++ b/Tasks/AddressPatch.cs @@ -143,75 +143,75 @@ public class AddressPatch if(has_refsid){ output += refsid_is + sep + " "; } - if(has_anrede){ - output += anrede_is + sep + " "; - } - if(has_titel){ - output += titel_is + sep + " "; - } - if(has_vorname){ - output += vorname_is + sep + " "; - } - if(has_adel){ - output += adel_is + sep + " "; - } - if(has_name){ - output += name_is + sep + " "; - } - if(has_namezus){ - output += namezus_is + sep + " "; - } - if(has_anredzus){ - output += anredzus_is + sep + " "; - } - if(has_strasse){ - output += strasse_is + sep + " "; - } - if(has_strasse2){ - output += strasse2_is + sep + " "; - } - if(has_plz){ - output += plz_is + sep + " "; - } - if(has_ort){ - output += ort_is + sep + " "; - } - if(has_land){ - output += land_is + sep + " "; - } - if(has_pplz){ - output += pplz_is + sep + " "; - } - if(has_postfach){ - output += postfach_is + sep + " "; - } - if(has_name1){ - output += name1_is + sep + " "; - } - if(has_name2){ - output += name2_is + sep + " "; - } - if(has_name3){ - output += name3_is + sep + " "; - } - if(has_name4){ - output += name4_is + sep + " "; - } - if(has_name5){ - output += name5_is + sep + " "; - } - if(has_funktion){ - output += funktion_is + sep + " "; - } - if(has_funktion2){ - output += funktion2_is + sep + " "; - } - if(has_abteilung){ - output += abteilung_is + sep + " "; - } - if(has_funktionad){ - output += funktionad_is + sep + " "; - } + if(has_anrede){ + output += anrede_is + sep + " "; + } + if(has_titel){ + output += titel_is + sep + " "; + } + if(has_vorname){ + output += vorname_is + sep + " "; + } + if(has_adel){ + output += adel_is + sep + " "; + } + if(has_name){ + output += name_is + sep + " "; + } + if(has_namezus){ + output += namezus_is + sep + " "; + } + if(has_anredzus){ + output += anredzus_is + sep + " "; + } + if(has_strasse){ + output += strasse_is + sep + " "; + } + if(has_strasse2){ + output += strasse2_is + sep + " "; + } + if(has_plz){ + output += plz_is + sep + " "; + } + if(has_ort){ + output += ort_is + sep + " "; + } + if(has_land){ + output += land_is + sep + " "; + } + if(has_pplz){ + output += pplz_is + sep + " "; + } + if(has_postfach){ + output += postfach_is + sep + " "; + } + if(has_name1){ + output += name1_is + sep + " "; + } + if(has_name2){ + output += name2_is + sep + " "; + } + if(has_name3){ + output += name3_is + sep + " "; + } + if(has_name4){ + output += name4_is + sep + " "; + } + if(has_name5){ + output += name5_is + sep + " "; + } + if(has_funktion){ + output += funktion_is + sep + " "; + } + if(has_funktion2){ + output += funktion2_is + sep + " "; + } + if(has_abteilung){ + output += abteilung_is + sep + " "; + } + if(has_funktionad){ + output += funktionad_is + sep + " "; + } return output; }