Compare commits
15
Commits
v1.0.2
..
89a9a919e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89a9a919e3 | ||
|
|
8dcf1810d4 | ||
|
|
ef7c3c268f | ||
|
|
33b40a1e73 | ||
|
|
6435dd8994 | ||
|
|
6c6aea611d | ||
|
|
0476704e9b | ||
|
|
d79d8f9155 | ||
|
|
e948cc0ce1 | ||
|
|
fc6b5e45e0 | ||
|
|
d1fc214c10 | ||
|
|
f09ccc883d | ||
|
|
ce46b90890 | ||
|
|
4a2af7ac0c | ||
|
|
8ea3ed1e8c |
@@ -33,6 +33,40 @@ public class KasAddressList //Address-Set
|
||||
this.owner_id = owner_id;
|
||||
}
|
||||
|
||||
public async Task<string> GenerateCSV(bool expAsAdpac)
|
||||
{
|
||||
var customer = Customer.GetCustomerByID(owner_id);
|
||||
// using adpac
|
||||
string result = "";
|
||||
string sep = customer.separator + " ";
|
||||
if(customer.patch != null && expAsAdpac)
|
||||
{
|
||||
string header = customer.patch.GetCSVHeader(sep);
|
||||
result += header + "\n";
|
||||
} 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 && 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
|
||||
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)
|
||||
{
|
||||
string pre = "";
|
||||
@@ -228,6 +262,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
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Logof_Client;
|
||||
public static class SchemaMigration
|
||||
{
|
||||
// Current schema version - increment when you make breaking changes
|
||||
public const int CURRENT_SCHEMA_VERSION = 4;
|
||||
public const int CURRENT_SCHEMA_VERSION = 5;
|
||||
|
||||
// Dictionary of migration functions, keyed by the version they migrate TO
|
||||
private static readonly Dictionary<int, Func<JObject, JObject>> Migrations = new()
|
||||
@@ -24,6 +24,7 @@ public static class SchemaMigration
|
||||
|
||||
// Example: Migration from v2 to v3
|
||||
{ 4, MigrateV3ToV4 },
|
||||
{ 5, MigrateV4ToV5 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -104,6 +105,26 @@ public static class SchemaMigration
|
||||
|
||||
return obj;
|
||||
}
|
||||
private static JObject MigrateV4ToV5(JObject obj)
|
||||
{
|
||||
// Example: Add a new field that didn't exist before
|
||||
if (!obj.ContainsKey("expLabEnable"))
|
||||
{
|
||||
obj["expLabEnable"] = JToken.FromObject(new PdfExportSettings().expLabEnable);
|
||||
}
|
||||
|
||||
if (!obj.ContainsKey("expInt"))
|
||||
{
|
||||
obj["expInt"] = JToken.FromObject(new PdfExportSettings().expInt);
|
||||
}
|
||||
|
||||
if (!obj.ContainsKey("expNat"))
|
||||
{
|
||||
obj["expNat"] = JToken.FromObject(new PdfExportSettings().expNat);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new migration function that will be called when upgrading to a specific version.
|
||||
|
||||
@@ -98,6 +98,7 @@ public enum LCModule
|
||||
|
||||
public class PdfExportSettings
|
||||
{
|
||||
public bool expLabEnable {get; set;} = true;
|
||||
public double cellPaddingTopMm { get; set; } = 4;
|
||||
public double cellPaddingBottomMm { get; set; } = 4;
|
||||
public double cellPaddingLeftMm { get; set; } = 4;
|
||||
@@ -117,6 +118,9 @@ public class PdfExportSettings
|
||||
public int rsNumGrouped { get; set; } = 25;
|
||||
public bool rsPvSt { get; set; } = true;
|
||||
|
||||
public bool expInt { get; set; } = true;
|
||||
public bool expNat { get; set; } = true;
|
||||
|
||||
public string rsKNrAbs { get; set; } = "";
|
||||
public string rsKNrEmp { get; set; } = "";
|
||||
public string rsZKZ { get; set; } = "";
|
||||
|
||||
+35
-3
@@ -124,6 +124,22 @@
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</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="MnIAdSetExpAdpac" Click="MnIAdSetExpAdpac_OnClick">
|
||||
<MenuItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<LucideIcon Kind="FileUp" Width="12" Height="12" Size="12" />
|
||||
<Label Content="Exportieren inkl. Adpac (CSV)" VerticalContentAlignment="Center" />
|
||||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="MnIAdSetDelete" Click="MnIAdSetDelete_OnClick" IsEnabled="True">
|
||||
<MenuItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -315,6 +331,23 @@
|
||||
<Grid Grid.Row="2" Margin="20" ColumnDefinitions="*,5*,*" IsVisible="False" x:Name="GrdExportMarginOptions">
|
||||
<ScrollViewer Grid.Column="1">
|
||||
<StackPanel Margin="5,5,5,5" Orientation="Vertical" Spacing="20" Background="AliceBlue" >
|
||||
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="20" Margin="10,10,10,0">
|
||||
<StackPanel Orientation="Vertical" Spacing="10">
|
||||
<Label Content="Was soll exportiert werden?" FontWeight="Bold"></Label>
|
||||
<CheckBox Content="National exportieren" IsChecked="True" x:Name="CbExpNat"></CheckBox>
|
||||
<CheckBox Content="International exportieren" IsChecked="True" x:Name="CbExpInt"></CheckBox>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
||||
<Label Content="Versandetiketten-Export" FontWeight="Bold"></Label>
|
||||
<CheckBox Content="Versandetiketten erstellen" x:Name="CbExpLabEnable"></CheckBox>
|
||||
<CheckBox Content="PvSt" IsChecked="True" x:Name="CbExpRnsPvSt"></CheckBox>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Orientation="Vertical" Spacing="10">
|
||||
<Label Content="Leitzettel-Export" FontWeight="Bold"></Label>
|
||||
<CheckBox Content="Bundleitzettel erstellen" x:Name="CbExpRnsEnable"></CheckBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid Height="1" MaxHeight="1" MinHeight="1" Background="DarkGray" Margin="10,10,10,0"></Grid>
|
||||
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="20" Margin="10,10,10,0">
|
||||
<StackPanel Orientation="Vertical" Spacing="10">
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
@@ -333,9 +366,8 @@
|
||||
<Label Grid.Column="0" Content="Zellenrand rechts (mm)"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingRight" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
||||
</Grid>
|
||||
<CheckBox Content="Bundleitzettel erstellen" x:Name="CbExpRnsEnable"></CheckBox>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
<Label Content="Zellenabstand oben"></Label>
|
||||
@@ -376,9 +408,9 @@
|
||||
<Label Grid.Column="0" Content="Schriftgröße (klein)"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudExpMargSmallFontSize" Minimum="3" Maximum="30" Value="6"></NumericUpDown>
|
||||
</Grid>
|
||||
<CheckBox Content="PvSt" IsChecked="True" x:Name="CbExpRnsPvSt"></CheckBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid Height="1" MaxHeight="1" MinHeight="1" Background="DarkGray" Margin="10,10,10,0"></Grid>
|
||||
<Grid ColumnDefinitions="*,*" ColumnSpacing="20" Margin="10,10,10,0">
|
||||
<StackPanel Grid.Column="0" Orientation="Vertical" Spacing="10">
|
||||
<Grid ColumnDefinitions="*,2*">
|
||||
|
||||
@@ -978,6 +978,8 @@ public partial class MainWindow : Window
|
||||
{
|
||||
var options = Settings._instance.pdfExport ?? new PdfExportSettings();
|
||||
|
||||
CbExpLabEnable.IsChecked = (bool)options.expLabEnable;
|
||||
|
||||
NudExpMargCellPaddingTop.Value = (decimal)options.cellPaddingTopMm;
|
||||
NudExpMargCellPaddingBot.Value = (decimal)options.cellPaddingBottomMm;
|
||||
NudExpMargCellPaddingLeft.Value = (decimal)options.cellPaddingLeftMm;
|
||||
@@ -996,6 +998,9 @@ public partial class MainWindow : Window
|
||||
CbExpRnsPvSt.IsChecked = options.rsPvSt;
|
||||
CbExpRnsEnable.IsChecked = options.exportRunningSheets;
|
||||
|
||||
CbExpNat.IsChecked = options.expNat;
|
||||
CbExpInt.IsChecked = options.expInt;
|
||||
|
||||
TbExpRnsKNrAbs.Text = options.rsKNrAbs;
|
||||
TbExpRnsKNrEmp.Text = options.rsKNrEmp;
|
||||
TbExpRnsZKZ.Text = options.rsZKZ;
|
||||
@@ -1031,6 +1036,8 @@ public partial class MainWindow : Window
|
||||
fontSize = ReadDouble(NudExpMargFontSize),
|
||||
smallFontSize = ReadDouble(NudExpMargSmallFontSize),
|
||||
|
||||
expLabEnable = CbExpLabEnable.IsChecked.Value,
|
||||
|
||||
rsKNrAbs = TbExpRnsKNrAbs.Text,
|
||||
rsKNrEmp = TbExpRnsKNrEmp.Text,
|
||||
rsZKZ = TbExpRnsZKZ.Text,
|
||||
@@ -1042,6 +1049,8 @@ public partial class MainWindow : Window
|
||||
rsPalNr = ReadInt(NudExpRnsPalNr, 1),
|
||||
rsBundNrPal = ReadInt(NudExpRnsBundNrPal, 20),
|
||||
rsNumGrouped = ReadInt(NudExpRnsPlzcount, 25),
|
||||
expNat = CbExpNat.IsChecked.Value,
|
||||
expInt = CbExpInt.IsChecked.Value,
|
||||
|
||||
rsPvSt = CbExpRnsPvSt.IsChecked.Value,
|
||||
exportRunningSheets = CbExpRnsEnable.IsChecked.Value
|
||||
@@ -1475,6 +1484,64 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private async void MnIAdSetExp_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
Logger.Log("Exporting as CSV without address patch...");
|
||||
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Select a Folder",
|
||||
AllowMultiple = false
|
||||
});
|
||||
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
var folderPath = folders[0].Path.LocalPath;
|
||||
Logger.Log($"using ${folderPath} as export destination");
|
||||
if (LstCustomerAdressSets.SelectedItems.Count > 0)
|
||||
{
|
||||
foreach (var set in LstCustomerAdressSets.SelectedItems)
|
||||
{
|
||||
string output = await ((KasAddressList)set).GenerateCSV(false);
|
||||
File.WriteAllText(Path.Combine(folderPath,((KasAddressList)set).Name + ".csv"), output);
|
||||
Logger.Log($"exported ${((KasAddressList)set).Name} successfully!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async void MnIAdSetExpAdpac_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
Logger.Log("Exporting as CSV with address patch...");
|
||||
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Select a Folder",
|
||||
AllowMultiple = false
|
||||
});
|
||||
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
var folderPath = folders[0].Path.LocalPath;
|
||||
Logger.Log($"using ${folderPath} as export destination");
|
||||
if (LstCustomerAdressSets.SelectedItems.Count > 0)
|
||||
{
|
||||
foreach (var set in LstCustomerAdressSets.SelectedItems)
|
||||
{
|
||||
string output = await ((KasAddressList)set).GenerateCSV(true);
|
||||
File.WriteAllText(Path.Combine(folderPath,((KasAddressList)set).Name + ".csv"), output);
|
||||
Logger.Log($"exported ${((KasAddressList)set).Name} successfully!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void BtnAdmgmt_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Addressmanagement.IsVisible && Addressmanagement.IsVisible)
|
||||
|
||||
@@ -168,6 +168,7 @@ public static class AddressCreator
|
||||
} // Error-Handling?
|
||||
|
||||
if (address_line_count > 1) return string_address;
|
||||
Logger.Log($"Address with ID {address.id} (refsid: {address.refsid} not valid for production use", Logger.LogType.Warning);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Avalonia.Controls;
|
||||
using Logof_Client;
|
||||
|
||||
public class AddressPatch
|
||||
@@ -134,4 +135,84 @@ public class AddressPatch
|
||||
|
||||
return "Error while parsing";
|
||||
}
|
||||
|
||||
public string GetCSVHeader(string sep)
|
||||
{
|
||||
string output = "";
|
||||
|
||||
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 + " ";
|
||||
}
|
||||
Logger.Log($"Generated CSV header ist ${output}");
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,26 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using System.Threading;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
public class AddressShortener(ProgressWindow progressWindow)
|
||||
public class AddressShortener
|
||||
{
|
||||
private readonly ProgressWindow _progress;
|
||||
|
||||
public AddressShortener(ProgressWindow progressWindow)
|
||||
{
|
||||
_progress = progressWindow;
|
||||
}
|
||||
public async Task Perform(KasAddressList list)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<int> doubled_ids = new List<int>();
|
||||
int[] percentages = [25,25,25,25];
|
||||
|
||||
for (int i = 0; i < list.KasPersons.Count; i++)
|
||||
{
|
||||
var address = list.KasPersons[i];
|
||||
@@ -26,8 +36,19 @@ public class AddressShortener(ProgressWindow progressWindow)
|
||||
doubled_ids.Add(address.refsid);
|
||||
}
|
||||
}
|
||||
|
||||
// var cd = Interlocked.Increment(ref current);
|
||||
|
||||
// if (cd % 10 == 0)
|
||||
// {
|
||||
// var percent = cd / (double)total * 100;
|
||||
|
||||
// await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
// _progress.ChangePercentage(percent));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// delete doubled addresses by refsid
|
||||
foreach (int id in doubled_ids)
|
||||
{
|
||||
@@ -65,12 +86,19 @@ public class AddressShortener(ProgressWindow progressWindow)
|
||||
}
|
||||
}
|
||||
|
||||
string faileds = "Folgende Adressen wurden entfernt:\n(refsid - Name, Vorname)\n\n";
|
||||
// delete doubled addresses by refsid
|
||||
foreach (int id in toRemove)
|
||||
{
|
||||
// does this remove both of the doubled addresses?
|
||||
list.KasPersons.Remove(list.KasPersons.Find(x => x.id == id));
|
||||
var pers = list.KasPersons.Find(x => x.id == id);
|
||||
faileds += pers.refsid + " - " + pers.name + ", " + pers.vorname + "\n";
|
||||
list.KasPersons.Remove(pers);
|
||||
|
||||
}
|
||||
await Dispatcher.UIThread.InvokeAsync(() => _progress.Hide());
|
||||
if (toRemove.Count > 0) await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(null,faileds,"Fehlerhafte Adressen"));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
+23
-2
@@ -92,6 +92,8 @@ public class PdfBuilder
|
||||
public void CreateAddressLabelPdfFromAddressSetWithPlaceholder(int addressSetId, string placeholderText, bool pvst,
|
||||
string outputPath)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// Find the AddressSet by ID
|
||||
@@ -120,6 +122,7 @@ public class PdfBuilder
|
||||
senderLine = null;
|
||||
}
|
||||
|
||||
List<KasPerson> failed = new();
|
||||
// national addresses
|
||||
foreach (var person in addressSet.KasPersons
|
||||
.Where(person => person.IsGermany())
|
||||
@@ -127,6 +130,7 @@ public class PdfBuilder
|
||||
{
|
||||
string senderLineID = senderLine;
|
||||
var addr = AddressCreator.CreateFinalMarkdownString(person.id);
|
||||
if(addr == null) failed.Add(person);
|
||||
if (string.IsNullOrWhiteSpace(addr)) continue;
|
||||
if (pvst)
|
||||
senderLineID += $"</font6>**PvSt, DP AG, Entgelt bezahlt, ZKZ {Settings._instance.pdfExport.rsZKZ}**\n<font6>";
|
||||
@@ -149,6 +153,7 @@ public class PdfBuilder
|
||||
{
|
||||
string senderLineID = senderLine;
|
||||
var addr = AddressCreator.CreateFinalMarkdownString(person.id);
|
||||
if(addr == null) failed.Add(person);
|
||||
if (string.IsNullOrWhiteSpace(addr)) continue;
|
||||
if (pvst)
|
||||
senderLineID += $"</font6>**PvSt, DP AG, Entgelt bezahlt, ZKZ {Settings._instance.pdfExport.rsZKZ}**\n<font6>";
|
||||
@@ -171,13 +176,29 @@ public class PdfBuilder
|
||||
|
||||
string output_inter = outputPath.Replace(".pdf", "-international.pdf");
|
||||
|
||||
if(addresses_german.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath, pvst);
|
||||
if(addresses_inter.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter, pvst);
|
||||
if(Settings._instance.pdfExport.expLabEnable == false)
|
||||
{
|
||||
Logger.Log("Skipping label pdf generation cause it was disabled by user");
|
||||
} else
|
||||
{
|
||||
if(addresses_german.Count > 0 && Settings._instance.pdfExport.expNat) CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath, pvst);
|
||||
if(addresses_inter.Count > 0 && Settings._instance.pdfExport.expInt) CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter, pvst);
|
||||
}
|
||||
|
||||
|
||||
if (_settings.exportRunningSheets)
|
||||
{
|
||||
ExportRunningSheets(addressSetId, outputPath);
|
||||
}
|
||||
if(failed.Count > 0)
|
||||
{
|
||||
string faileds = "Versandetiketten zu folgenden Adressen konnten nicht generiert werden:\n(refsid - Name, Vorname)\n\n";
|
||||
foreach(var pers in failed)
|
||||
{
|
||||
faileds += pers.refsid + " - " + pers.name + ", " + pers.vorname + "\n";
|
||||
}
|
||||
MessageBox.Show(MainWindow._instance,faileds,"Fehlerhafte Adressen");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user