Compare commits
15
Commits
e948cc0ce1
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a77967d57 | ||
|
|
094fa9e0f4 | ||
|
|
5909d57f47 | ||
|
|
e502aac843 | ||
|
|
5c391a3cc9 | ||
|
|
0bf93cf240 | ||
|
|
de97421914 | ||
|
|
89a9a919e3 | ||
|
|
8dcf1810d4 | ||
|
|
ef7c3c268f | ||
|
|
33b40a1e73 | ||
|
|
6435dd8994 | ||
|
|
6c6aea611d | ||
|
|
0476704e9b | ||
|
|
d79d8f9155 |
@@ -42,6 +42,7 @@ public class KasAddressList //Address-Set
|
|||||||
if(customer.patch != null && expAsAdpac)
|
if(customer.patch != null && expAsAdpac)
|
||||||
{
|
{
|
||||||
string header = customer.patch.GetCSVHeader(sep);
|
string header = customer.patch.GetCSVHeader(sep);
|
||||||
|
result += header + "\n";
|
||||||
} else
|
} 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";
|
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";
|
||||||
|
|||||||
@@ -113,6 +113,21 @@ public static class SchemaMigration
|
|||||||
obj["expLabEnable"] = JToken.FromObject(new PdfExportSettings().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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!obj.ContainsKey("rsGrupTol"))
|
||||||
|
{
|
||||||
|
obj["rsGrupTol"] = JToken.FromObject(new PdfExportSettings().rsGrupTol);
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ public class PdfExportSettings
|
|||||||
public int rsNumGrouped { get; set; } = 25;
|
public int rsNumGrouped { get; set; } = 25;
|
||||||
public bool rsPvSt { get; set; } = true;
|
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 rsKNrAbs { get; set; } = "";
|
||||||
public string rsKNrEmp { get; set; } = "";
|
public string rsKNrEmp { get; set; } = "";
|
||||||
public string rsZKZ { get; set; } = "";
|
public string rsZKZ { get; set; } = "";
|
||||||
@@ -128,6 +131,7 @@ public class PdfExportSettings
|
|||||||
public string rsBundGew { get; set; } = "";
|
public string rsBundGew { get; set; } = "";
|
||||||
public int rsPalNr { get; set; } = 1;
|
public int rsPalNr { get; set; } = 1;
|
||||||
public int rsBundNrPal { get; set; } = 20;
|
public int rsBundNrPal { get; set; } = 20;
|
||||||
|
public int rsGrupTol { get; set; } = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-4
@@ -132,6 +132,14 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</MenuItem.Header>
|
</MenuItem.Header>
|
||||||
</MenuItem>
|
</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 x:Name="MnIAdSetDelete" Click="MnIAdSetDelete_OnClick" IsEnabled="True">
|
||||||
<MenuItem.Header>
|
<MenuItem.Header>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -323,7 +331,23 @@
|
|||||||
<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" Margin="10,10,10,0"></CheckBox>
|
<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">
|
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="20" Margin="10,10,10,0">
|
||||||
<StackPanel Orientation="Vertical" Spacing="10">
|
<StackPanel Orientation="Vertical" Spacing="10">
|
||||||
<Grid ColumnDefinitions="*,*">
|
<Grid ColumnDefinitions="*,*">
|
||||||
@@ -342,9 +366,8 @@
|
|||||||
<Label Grid.Column="0" Content="Zellenrand rechts (mm)"></Label>
|
<Label Grid.Column="0" Content="Zellenrand rechts (mm)"></Label>
|
||||||
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingRight" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingRight" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
||||||
</Grid>
|
</Grid>
|
||||||
<CheckBox Content="Bundleitzettel erstellen" x:Name="CbExpRnsEnable"></CheckBox>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
||||||
<Grid ColumnDefinitions="*,*">
|
<Grid ColumnDefinitions="*,*">
|
||||||
<Label Content="Zellenabstand oben"></Label>
|
<Label Content="Zellenabstand oben"></Label>
|
||||||
@@ -385,9 +408,9 @@
|
|||||||
<Label Grid.Column="0" Content="Schriftgröße (klein)"></Label>
|
<Label Grid.Column="0" Content="Schriftgröße (klein)"></Label>
|
||||||
<NumericUpDown Grid.Column="1" x:Name="NudExpMargSmallFontSize" Minimum="3" Maximum="30" Value="6"></NumericUpDown>
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargSmallFontSize" Minimum="3" Maximum="30" Value="6"></NumericUpDown>
|
||||||
</Grid>
|
</Grid>
|
||||||
<CheckBox Content="PvSt" IsChecked="True" x:Name="CbExpRnsPvSt"></CheckBox>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</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">
|
<Grid ColumnDefinitions="*,*" ColumnSpacing="20" Margin="10,10,10,0">
|
||||||
<StackPanel Grid.Column="0" Orientation="Vertical" Spacing="10">
|
<StackPanel Grid.Column="0" Orientation="Vertical" Spacing="10">
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,2*">
|
||||||
@@ -410,6 +433,10 @@
|
|||||||
<Label Grid.Column="0" Content="Laufzeit" />
|
<Label Grid.Column="0" Content="Laufzeit" />
|
||||||
<TextBox Grid.Column="1" x:Name="TbExpRnsLaufz" />
|
<TextBox Grid.Column="1" x:Name="TbExpRnsLaufz" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,2*">
|
||||||
|
<Label Grid.Column="0" Content="Gruppiertoleranz (Ende)" />
|
||||||
|
<NumericUpDown Grid.Column="1" Minimum="0" Value="0" x:Name="NudExpRnsGrupTol" />
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
||||||
<Grid ColumnDefinitions="*,2*">
|
<Grid ColumnDefinitions="*,2*">
|
||||||
|
|||||||
+40
-2
@@ -998,6 +998,9 @@ public partial class MainWindow : Window
|
|||||||
CbExpRnsPvSt.IsChecked = options.rsPvSt;
|
CbExpRnsPvSt.IsChecked = options.rsPvSt;
|
||||||
CbExpRnsEnable.IsChecked = options.exportRunningSheets;
|
CbExpRnsEnable.IsChecked = options.exportRunningSheets;
|
||||||
|
|
||||||
|
CbExpNat.IsChecked = options.expNat;
|
||||||
|
CbExpInt.IsChecked = options.expInt;
|
||||||
|
|
||||||
TbExpRnsKNrAbs.Text = options.rsKNrAbs;
|
TbExpRnsKNrAbs.Text = options.rsKNrAbs;
|
||||||
TbExpRnsKNrEmp.Text = options.rsKNrEmp;
|
TbExpRnsKNrEmp.Text = options.rsKNrEmp;
|
||||||
TbExpRnsZKZ.Text = options.rsZKZ;
|
TbExpRnsZKZ.Text = options.rsZKZ;
|
||||||
@@ -1008,6 +1011,7 @@ public partial class MainWindow : Window
|
|||||||
TbExpRnsBundGew.Text = options.rsBundGew;
|
TbExpRnsBundGew.Text = options.rsBundGew;
|
||||||
NudExpRnsPalNr.Value = options.rsPalNr;
|
NudExpRnsPalNr.Value = options.rsPalNr;
|
||||||
NudExpRnsBundNrPal.Value = options.rsBundNrPal;
|
NudExpRnsBundNrPal.Value = options.rsBundNrPal;
|
||||||
|
NudExpRnsGrupTol.Value = options.rsGrupTol;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -1046,6 +1050,9 @@ public partial class MainWindow : Window
|
|||||||
rsPalNr = ReadInt(NudExpRnsPalNr, 1),
|
rsPalNr = ReadInt(NudExpRnsPalNr, 1),
|
||||||
rsBundNrPal = ReadInt(NudExpRnsBundNrPal, 20),
|
rsBundNrPal = ReadInt(NudExpRnsBundNrPal, 20),
|
||||||
rsNumGrouped = ReadInt(NudExpRnsPlzcount, 25),
|
rsNumGrouped = ReadInt(NudExpRnsPlzcount, 25),
|
||||||
|
expNat = CbExpNat.IsChecked.Value,
|
||||||
|
expInt = CbExpInt.IsChecked.Value,
|
||||||
|
rsGrupTol = ReadInt(NudExpRnsGrupTol, 0),
|
||||||
|
|
||||||
rsPvSt = CbExpRnsPvSt.IsChecked.Value,
|
rsPvSt = CbExpRnsPvSt.IsChecked.Value,
|
||||||
exportRunningSheets = CbExpRnsEnable.IsChecked.Value
|
exportRunningSheets = CbExpRnsEnable.IsChecked.Value
|
||||||
@@ -1482,7 +1489,7 @@ public partial class MainWindow : Window
|
|||||||
private async void MnIAdSetExp_OnClick(object? sender, RoutedEventArgs e)
|
private async void MnIAdSetExp_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var topLevel = TopLevel.GetTopLevel(this);
|
var topLevel = TopLevel.GetTopLevel(this);
|
||||||
|
Logger.Log("Exporting as CSV without address patch...");
|
||||||
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||||
{
|
{
|
||||||
Title = "Select a Folder",
|
Title = "Select a Folder",
|
||||||
@@ -1492,12 +1499,43 @@ public partial class MainWindow : Window
|
|||||||
if (folders.Count > 0)
|
if (folders.Count > 0)
|
||||||
{
|
{
|
||||||
var folderPath = folders[0].Path.LocalPath;
|
var folderPath = folders[0].Path.LocalPath;
|
||||||
|
Logger.Log($"using ${folderPath} as export destination");
|
||||||
if (LstCustomerAdressSets.SelectedItems.Count > 0)
|
if (LstCustomerAdressSets.SelectedItems.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var set in LstCustomerAdressSets.SelectedItems)
|
foreach (var set in LstCustomerAdressSets.SelectedItems)
|
||||||
{
|
{
|
||||||
string output = await ((KasAddressList)set).GenerateCSV();
|
string output = await ((KasAddressList)set).GenerateCSV(false);
|
||||||
File.WriteAllText(Path.Combine(folderPath,((KasAddressList)set).Name + ".csv"), output);
|
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!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class AddressPatch
|
|||||||
if(has_funktionad){
|
if(has_funktionad){
|
||||||
output += funktionad_is + sep + " ";
|
output += funktionad_is + sep + " ";
|
||||||
}
|
}
|
||||||
|
Logger.Log($"Generated CSV header ist ${output}");
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+177
-12
@@ -11,6 +11,8 @@ namespace Logof_Client;
|
|||||||
|
|
||||||
public class PdfBuilder
|
public class PdfBuilder
|
||||||
{
|
{
|
||||||
|
private const char RecipientTextMarker = '\u001f';
|
||||||
|
|
||||||
private readonly PdfExportSettings _settings;
|
private readonly PdfExportSettings _settings;
|
||||||
private readonly XFont _boldFont;
|
private readonly XFont _boldFont;
|
||||||
private readonly XFont _regularFont;
|
private readonly XFont _regularFont;
|
||||||
@@ -140,9 +142,9 @@ public class PdfBuilder
|
|||||||
else
|
else
|
||||||
senderLineID += "\n</font6>";
|
senderLineID += "\n</font6>";
|
||||||
if (!string.IsNullOrEmpty(senderLineID))
|
if (!string.IsNullOrEmpty(senderLineID))
|
||||||
addresses_german.Add(senderLineID + (addr ?? ""));
|
addresses_german.Add(senderLineID + RecipientTextMarker + (addr ?? ""));
|
||||||
else
|
else
|
||||||
addresses_german.Add(addr);
|
addresses_german.Add(RecipientTextMarker + (addr ?? ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// international addresses
|
// international addresses
|
||||||
@@ -163,9 +165,9 @@ public class PdfBuilder
|
|||||||
else
|
else
|
||||||
senderLineID += "\n</font6>";
|
senderLineID += "\n</font6>";
|
||||||
if (!string.IsNullOrEmpty(senderLineID))
|
if (!string.IsNullOrEmpty(senderLineID))
|
||||||
addresses_inter.Add(senderLineID + (addr ?? ""));
|
addresses_inter.Add(senderLineID + RecipientTextMarker + (addr ?? ""));
|
||||||
else
|
else
|
||||||
addresses_inter.Add(addr);
|
addresses_inter.Add(RecipientTextMarker + (addr ?? ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addresses_german.Count == 0 && addresses_inter.Count == 0)
|
if (addresses_german.Count == 0 && addresses_inter.Count == 0)
|
||||||
@@ -181,8 +183,8 @@ public class PdfBuilder
|
|||||||
Logger.Log("Skipping label pdf generation cause it was disabled by user");
|
Logger.Log("Skipping label pdf generation cause it was disabled by user");
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if(addresses_german.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath, pvst);
|
if(addresses_german.Count > 0 && Settings._instance.pdfExport.expNat) CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath, pvst);
|
||||||
if(addresses_inter.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter, pvst);
|
if(addresses_inter.Count > 0 && Settings._instance.pdfExport.expInt) CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter, pvst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -359,12 +361,14 @@ public class PdfBuilder
|
|||||||
public string Text { get; }
|
public string Text { get; }
|
||||||
public TextStyle Style { get; }
|
public TextStyle Style { get; }
|
||||||
public bool LineBreak { get; }
|
public bool LineBreak { get; }
|
||||||
|
public bool WrapAtWords { get; }
|
||||||
|
|
||||||
public TextToken(string text, TextStyle style, bool lineBreak = false)
|
public TextToken(string text, TextStyle style, bool lineBreak = false, bool wrapAtWords = false)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
Style = style;
|
Style = style;
|
||||||
LineBreak = lineBreak;
|
LineBreak = lineBreak;
|
||||||
|
WrapAtWords = wrapAtWords;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,19 +422,28 @@ public class PdfBuilder
|
|||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var style = TextStyle.Regular;
|
var style = TextStyle.Regular;
|
||||||
|
var wrapAtWords = false;
|
||||||
var buffer = new System.Text.StringBuilder();
|
var buffer = new System.Text.StringBuilder();
|
||||||
|
|
||||||
void FlushBuffer()
|
void FlushBuffer()
|
||||||
{
|
{
|
||||||
if (buffer.Length > 0)
|
if (buffer.Length > 0)
|
||||||
{
|
{
|
||||||
tokens.Add(new TextToken(buffer.ToString(), style));
|
tokens.Add(new TextToken(buffer.ToString(), style, wrapAtWords: wrapAtWords));
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < text.Length)
|
while (i < text.Length)
|
||||||
{
|
{
|
||||||
|
if (text[i] == RecipientTextMarker)
|
||||||
|
{
|
||||||
|
FlushBuffer();
|
||||||
|
wrapAtWords = true;
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (text[i] == '\r')
|
if (text[i] == '\r')
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@@ -547,6 +560,39 @@ public class PdfBuilder
|
|||||||
available = maxWidth;
|
available = maxWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (token.WrapAtWords)
|
||||||
|
{
|
||||||
|
var wordParts = System.Text.RegularExpressions.Regex.Split(remaining, @"(\s+)");
|
||||||
|
foreach (var wordPart in wordParts)
|
||||||
|
{
|
||||||
|
if (wordPart.Length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var wordWidth = gfx.MeasureString(wordPart, font).Width;
|
||||||
|
if (string.IsNullOrWhiteSpace(wordPart))
|
||||||
|
{
|
||||||
|
if (currentLine.Count == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (currentWidth + wordWidth > maxWidth)
|
||||||
|
{
|
||||||
|
PushLine();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentLine.Count > 0 && currentWidth + wordWidth > maxWidth)
|
||||||
|
{
|
||||||
|
PushLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentLine.Add(new TextRun { Text = wordPart, Font = font });
|
||||||
|
currentWidth += wordWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
remaining = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var fit = FitTextToWidth(gfx, remaining, font, available);
|
var fit = FitTextToWidth(gfx, remaining, font, available);
|
||||||
if (string.IsNullOrEmpty(fit))
|
if (string.IsNullOrEmpty(fit))
|
||||||
{
|
{
|
||||||
@@ -703,6 +749,7 @@ public class PdfBuilder
|
|||||||
document.Info.Author = "logofclient";
|
document.Info.Author = "logofclient";
|
||||||
|
|
||||||
var grouped_nums = GroupAddresses(setID).ToList();
|
var grouped_nums = GroupAddresses(setID).ToList();
|
||||||
|
DrawPostalCodeOverview(document, grouped_nums);
|
||||||
|
|
||||||
// Zwei Tabellen pro A4-Seite
|
// Zwei Tabellen pro A4-Seite
|
||||||
int sheets = (grouped_nums.Count + 1) / 2;
|
int sheets = (grouped_nums.Count + 1) / 2;
|
||||||
@@ -794,6 +841,106 @@ public class PdfBuilder
|
|||||||
document.Save(path);
|
document.Save(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawPostalCodeOverview(PdfDocument document, List<(int, string, string, string, int)> groupedNumbers)
|
||||||
|
{
|
||||||
|
if (groupedNumbers.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var summaries = groupedNumbers
|
||||||
|
.GroupBy(item => item.Item2)
|
||||||
|
.OrderBy(group => group.Key, StringComparer.Ordinal)
|
||||||
|
.Select(group => new
|
||||||
|
{
|
||||||
|
Prefix = group.Key,
|
||||||
|
AddressCount = group.Sum(item => item.Item5),
|
||||||
|
GroupCount = group.Count(),
|
||||||
|
StartPostalCode = group.First().Item3,
|
||||||
|
EndPostalCode = group.Last().Item4
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
const double tableTop = 58;
|
||||||
|
const double headerHeight = 16;
|
||||||
|
const double rowHeight = 14;
|
||||||
|
const double tableGap = 12;
|
||||||
|
double[] columnWidths = { 40, 50, 36, 55, 55 };
|
||||||
|
string[] headers = { "PLZ-Gr.", "Anz.", "Anz.Gr.", "Start", "Ende" };
|
||||||
|
var titleFont = new XFont("Arial", 13, XFontStyleEx.Bold);
|
||||||
|
var headerFont = new XFont("Arial", 7.5, XFontStyleEx.Bold);
|
||||||
|
var textFont = new XFont("Arial", 7.5, XFontStyleEx.Regular);
|
||||||
|
var groupCountFont = new XFont("Arial", 7.5, XFontStyleEx.Bold);
|
||||||
|
int leftCount = (summaries.Count + 1) / 2;
|
||||||
|
double tableWidth = columnWidths.Sum();
|
||||||
|
double allTablesWidth = tableWidth * 2 + tableGap;
|
||||||
|
|
||||||
|
var page = document.AddPage();
|
||||||
|
page.Size = PageSize.A4;
|
||||||
|
using var gfx = XGraphics.FromPdfPage(page);
|
||||||
|
|
||||||
|
gfx.DrawString("Übersicht PLZ-Gruppen", titleFont, XBrushes.Black,
|
||||||
|
new XRect(28, 16, page.Width.Point - 56, 20), XStringFormats.TopLeft);
|
||||||
|
|
||||||
|
var metadataFont = new XFont("Arial", 9, XFontStyleEx.Regular);
|
||||||
|
double metadataWidth = (page.Width.Point - 56) / 3;
|
||||||
|
gfx.DrawString($"ZKZ: {_settings.rsZKZ}", metadataFont, XBrushes.Black,
|
||||||
|
new XRect(28, 38, metadataWidth, 16), XStringFormats.TopLeft);
|
||||||
|
gfx.DrawString($"Datum: {DateTime.Now:dd.MM.yyyy}", metadataFont, XBrushes.Black,
|
||||||
|
new XRect(28 + metadataWidth, 38, metadataWidth, 16), XStringFormats.TopLeft);
|
||||||
|
gfx.DrawString("Projekt: ____________________", metadataFont, XBrushes.Black,
|
||||||
|
new XRect(28 + 2 * metadataWidth, 38, metadataWidth, 16), XStringFormats.TopLeft);
|
||||||
|
|
||||||
|
double firstTableX = (page.Width.Point - allTablesWidth) / 2;
|
||||||
|
for (int tableIndex = 0; tableIndex < 2; tableIndex++)
|
||||||
|
{
|
||||||
|
int startIndex = tableIndex == 0 ? 0 : leftCount;
|
||||||
|
int itemCount = tableIndex == 0 ? leftCount : summaries.Count - leftCount;
|
||||||
|
if (itemCount == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
double tableX = firstTableX + tableIndex * (tableWidth + tableGap);
|
||||||
|
gfx.DrawRectangle(XBrushes.LightGray, tableX, tableTop, tableWidth, headerHeight);
|
||||||
|
gfx.DrawRectangle(XPens.Black, tableX, tableTop, tableWidth, headerHeight);
|
||||||
|
|
||||||
|
double columnX = tableX;
|
||||||
|
for (int columnIndex = 0; columnIndex < headers.Length; columnIndex++)
|
||||||
|
{
|
||||||
|
gfx.DrawString(headers[columnIndex], headerFont, XBrushes.Black,
|
||||||
|
new XRect(columnX + 2, tableTop, columnWidths[columnIndex] - 4, headerHeight),
|
||||||
|
XStringFormats.Center);
|
||||||
|
columnX += columnWidths[columnIndex];
|
||||||
|
if (columnIndex < headers.Length - 1)
|
||||||
|
gfx.DrawLine(XPens.Black, columnX, tableTop, columnX, tableTop + headerHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int rowIndex = 0; rowIndex < itemCount; rowIndex++)
|
||||||
|
{
|
||||||
|
var summary = summaries[startIndex + rowIndex];
|
||||||
|
string[] values =
|
||||||
|
{
|
||||||
|
summary.Prefix,
|
||||||
|
summary.AddressCount.ToString(),
|
||||||
|
summary.GroupCount.ToString(),
|
||||||
|
summary.StartPostalCode,
|
||||||
|
summary.EndPostalCode
|
||||||
|
};
|
||||||
|
double rowY = tableTop + headerHeight + rowIndex * rowHeight;
|
||||||
|
gfx.DrawRectangle(XPens.Black, tableX, rowY, tableWidth, rowHeight);
|
||||||
|
|
||||||
|
columnX = tableX;
|
||||||
|
for (int columnIndex = 0; columnIndex < values.Length; columnIndex++)
|
||||||
|
{
|
||||||
|
gfx.DrawString(values[columnIndex], columnIndex == 2 ? groupCountFont : textFont,
|
||||||
|
XBrushes.Black,
|
||||||
|
new XRect(columnX + 2, rowY, columnWidths[columnIndex] - 4, rowHeight),
|
||||||
|
XStringFormats.Center);
|
||||||
|
columnX += columnWidths[columnIndex];
|
||||||
|
if (columnIndex < values.Length - 1)
|
||||||
|
gfx.DrawLine(XPens.Black, columnX, rowY, columnX, rowY + rowHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawGermanyRunningSheet(XGraphics gfx, double x, double y, double w, double h, KasAddressList list, dynamic result, List<(int,string,string,string,int)> grouped_nums, XFont fontLabel, XFont fontText, XFont fontBig, int? pal_nr, int? bundleOnPallet, int totalBundleNumber)
|
private void DrawGermanyRunningSheet(XGraphics gfx, double x, double y, double w, double h, KasAddressList list, dynamic result, List<(int,string,string,string,int)> grouped_nums, XFont fontLabel, XFont fontText, XFont fontBig, int? pal_nr, int? bundleOnPallet, int totalBundleNumber)
|
||||||
{
|
{
|
||||||
double line = 1.0;
|
double line = 1.0;
|
||||||
@@ -1262,6 +1409,7 @@ public class PdfBuilder
|
|||||||
public List<(int, string, string, string, int)> GroupAddresses(int setID)
|
public List<(int, string, string, string, int)> GroupAddresses(int setID)
|
||||||
{
|
{
|
||||||
int grpcount = Settings._instance.pdfExport.rsNumGrouped; // Amount of addresses per group
|
int grpcount = Settings._instance.pdfExport.rsNumGrouped; // Amount of addresses per group
|
||||||
|
int grptol = Settings._instance.pdfExport.rsGrupTol; // Amount of addresses per group
|
||||||
int stpoint = 2; // group starting point (first n characters of the plz)
|
int stpoint = 2; // group starting point (first n characters of the plz)
|
||||||
KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID);
|
KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
@@ -1280,12 +1428,20 @@ public class PdfBuilder
|
|||||||
{
|
{
|
||||||
string start = group.Key;
|
string start = group.Key;
|
||||||
int fraktion = 0;
|
int fraktion = 0;
|
||||||
|
int addressCount = group.Count();
|
||||||
|
int remainder = addressCount % grpcount;
|
||||||
|
int groupCount = (addressCount - 1) / grpcount + 1;
|
||||||
|
bool mergeLastGroup = groupCount > 1 && remainder > 0 && remainder <= grptol;
|
||||||
|
int effectiveGroupCount = groupCount - (mergeLastGroup ? 1 : 0);
|
||||||
|
|
||||||
for (int count = 0; count < group.Count(); count += grpcount)
|
for (int groupIndex = 0; groupIndex < effectiveGroupCount; groupIndex++)
|
||||||
{
|
{
|
||||||
fraktion++;
|
fraktion++;
|
||||||
|
|
||||||
int currentGroupSize = Math.Min(grpcount, group.Count() - count);
|
int count = groupIndex * grpcount;
|
||||||
|
int currentGroupSize = mergeLastGroup && groupIndex == effectiveGroupCount - 1
|
||||||
|
? addressCount - count
|
||||||
|
: Math.Min(grpcount, addressCount - count);
|
||||||
|
|
||||||
string first = group.ElementAt(count).used_plz;
|
string first = group.ElementAt(count).used_plz;
|
||||||
string last = group.ElementAt(count + currentGroupSize - 1).used_plz;
|
string last = group.ElementAt(count + currentGroupSize - 1).used_plz;
|
||||||
@@ -1300,6 +1456,7 @@ public class PdfBuilder
|
|||||||
public List<(int, string, string, string, int)> GroupAddressesInternational(int setID)
|
public List<(int, string, string, string, int)> GroupAddressesInternational(int setID)
|
||||||
{
|
{
|
||||||
int grpcount = Settings._instance.pdfExport.rsNumGrouped; // Amount of addresses per group
|
int grpcount = Settings._instance.pdfExport.rsNumGrouped; // Amount of addresses per group
|
||||||
|
int grptol = Settings._instance.pdfExport.rsGrupTol; // Amount of addresses per group
|
||||||
KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID);
|
KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
throw new Exception("AddressSet nicht gefunden");
|
throw new Exception("AddressSet nicht gefunden");
|
||||||
@@ -1316,12 +1473,20 @@ public class PdfBuilder
|
|||||||
{
|
{
|
||||||
string start = group.Key;
|
string start = group.Key;
|
||||||
int fraktion = 0;
|
int fraktion = 0;
|
||||||
|
int addressCount = group.Count();
|
||||||
|
int remainder = addressCount % grpcount;
|
||||||
|
int groupCount = (addressCount - 1) / grpcount + 1;
|
||||||
|
bool mergeLastGroup = groupCount > 1 && remainder > 0 && remainder <= grptol;
|
||||||
|
int effectiveGroupCount = groupCount - (mergeLastGroup ? 1 : 0);
|
||||||
|
|
||||||
for (int count = 0; count < group.Count(); count += grpcount)
|
for (int groupIndex = 0; groupIndex < effectiveGroupCount; groupIndex++)
|
||||||
{
|
{
|
||||||
fraktion++;
|
fraktion++;
|
||||||
|
|
||||||
int currentGroupSize = Math.Min(grpcount, group.Count() - count);
|
int count = groupIndex * grpcount;
|
||||||
|
int currentGroupSize = mergeLastGroup && groupIndex == effectiveGroupCount - 1
|
||||||
|
? addressCount - count
|
||||||
|
: Math.Min(grpcount, addressCount - count);
|
||||||
|
|
||||||
string first = group.ElementAt(count).used_plz;
|
string first = group.ElementAt(count).used_plz;
|
||||||
string last = group.ElementAt(count + currentGroupSize - 1).used_plz;
|
string last = group.ElementAt(count + currentGroupSize - 1).used_plz;
|
||||||
|
|||||||
Reference in New Issue
Block a user