Compare commits
2
Commits
d1fc214c10
..
db
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cd5d4aeed | ||
|
|
decc46d84a |
@@ -33,35 +33,6 @@ 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 = "";
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Logof_Client;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zentrale Datenbankverwaltung für Logof Client.
|
||||||
|
///
|
||||||
|
/// Zuständig für:
|
||||||
|
/// - PostgreSQL-Verbindung
|
||||||
|
/// - EF Core DbContext
|
||||||
|
/// - Datenbankmodelle
|
||||||
|
/// - Migrationen
|
||||||
|
/// - Verbindungstest
|
||||||
|
/// </summary>
|
||||||
|
public static class DatabseService
|
||||||
|
{
|
||||||
|
private static DbContextOptions<LogofDbContext>? _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialisiert die Datenbankverbindung.
|
||||||
|
/// Sollte einmal beim Programmstart aufgerufen werden.
|
||||||
|
/// </summary>
|
||||||
|
public static void Initialize(string connectionString)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(connectionString))
|
||||||
|
throw new ArgumentException(
|
||||||
|
"Kein Datenbank-Connection-String angegeben.",
|
||||||
|
nameof(connectionString));
|
||||||
|
|
||||||
|
var builder = new DbContextOptionsBuilder<LogofDbContext>();
|
||||||
|
|
||||||
|
builder.UseNpgsql(connectionString);
|
||||||
|
|
||||||
|
_options = builder.Options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Erstellt einen neuen DbContext.
|
||||||
|
/// </summary>
|
||||||
|
public static LogofDbContext GetContext()
|
||||||
|
{
|
||||||
|
if (_options == null)
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"DB wurde noch nicht initialisiert. " +
|
||||||
|
"Rufen Sie DB.Initialize(...) auf.");
|
||||||
|
|
||||||
|
return new LogofDbContext(_options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Testet die Verbindung zum Datenbankserver.
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<bool> TestConnectionAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var db = GetContext();
|
||||||
|
return await db.Database.CanConnectAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Erstellt bzw. aktualisiert das Datenbankschema
|
||||||
|
/// anhand der vorhandenen EF-Core-Migrationen.
|
||||||
|
/// </summary>
|
||||||
|
public static async Task MigrateAsync()
|
||||||
|
{
|
||||||
|
await using var db = GetContext();
|
||||||
|
|
||||||
|
await db.Database.MigrateAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// DATABASE CONTEXT
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
public class LogofDbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<CustomerEx> Customers => Set<CustomerEx>();
|
||||||
|
|
||||||
|
public LogofDbContext(
|
||||||
|
DbContextOptions<LogofDbContext> options)
|
||||||
|
: base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
// Customer
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
modelBuilder.Entity<CustomerEx>(entity =>
|
||||||
|
{
|
||||||
|
entity.ToTable("customers");
|
||||||
|
|
||||||
|
entity.HasKey(x => x.Id);
|
||||||
|
|
||||||
|
entity.Property(x => x.Id)
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
entity.Property(x => x.Name)
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
entity.Property(x => x.Description)
|
||||||
|
.HasMaxLength(4000);
|
||||||
|
|
||||||
|
entity.Property(x => x.SenderAddress)
|
||||||
|
.HasMaxLength(4000);
|
||||||
|
|
||||||
|
entity.Property(x => x.Separator)
|
||||||
|
.HasMaxLength(1)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
// Optimistic Concurrency
|
||||||
|
entity.Property(x => x.Version)
|
||||||
|
.IsConcurrencyToken();
|
||||||
|
|
||||||
|
entity.Property(x => x.CreatedAt)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
entity.Property(x => x.UpdatedAt)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// DATABASE MODELS
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
public class CustomerEx
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
|
||||||
|
public string Description { get; set; } = "";
|
||||||
|
|
||||||
|
public string SenderAddress { get; set; } = "";
|
||||||
|
|
||||||
|
public char Separator { get; set; } = ',';
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wird bei jeder Änderung erhöht.
|
||||||
|
/// Verhindert, dass zwei Benutzer sich gegenseitig
|
||||||
|
/// Änderungen überschreiben.
|
||||||
|
/// </summary>
|
||||||
|
public long Version { get; set; } = 1;
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace Logof_Client;
|
|||||||
public static class SchemaMigration
|
public static class SchemaMigration
|
||||||
{
|
{
|
||||||
// Current schema version - increment when you make breaking changes
|
// Current schema version - increment when you make breaking changes
|
||||||
public const int CURRENT_SCHEMA_VERSION = 5;
|
public const int CURRENT_SCHEMA_VERSION = 4;
|
||||||
|
|
||||||
// Dictionary of migration functions, keyed by the version they migrate TO
|
// Dictionary of migration functions, keyed by the version they migrate TO
|
||||||
private static readonly Dictionary<int, Func<JObject, JObject>> Migrations = new()
|
private static readonly Dictionary<int, Func<JObject, JObject>> Migrations = new()
|
||||||
@@ -24,7 +24,6 @@ public static class SchemaMigration
|
|||||||
|
|
||||||
// Example: Migration from v2 to v3
|
// Example: Migration from v2 to v3
|
||||||
{ 4, MigrateV3ToV4 },
|
{ 4, MigrateV3ToV4 },
|
||||||
{ 5, MigrateV4ToV5 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -105,16 +104,6 @@ public static class SchemaMigration
|
|||||||
|
|
||||||
return obj;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a new migration function that will be called when upgrading to a specific version.
|
/// Registers a new migration function that will be called when upgrading to a specific version.
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ public enum LCModule
|
|||||||
|
|
||||||
public class PdfExportSettings
|
public class PdfExportSettings
|
||||||
{
|
{
|
||||||
public bool expLabEnable {get; set;} = true;
|
|
||||||
public double cellPaddingTopMm { get; set; } = 4;
|
public double cellPaddingTopMm { get; set; } = 4;
|
||||||
public double cellPaddingBottomMm { get; set; } = 4;
|
public double cellPaddingBottomMm { get; set; } = 4;
|
||||||
public double cellPaddingLeftMm { get; set; } = 4;
|
public double cellPaddingLeftMm { get; set; } = 4;
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
@@ -24,6 +24,9 @@
|
|||||||
<PackageReference Include="Markdown.Avalonia" Version="11.0.3" />
|
<PackageReference Include="Markdown.Avalonia" Version="11.0.3" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
<PackageReference Include="PdfSharp" Version="6.1.1" />
|
<PackageReference Include="PdfSharp" Version="6.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.12" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.12" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+1
-47
@@ -21,44 +21,7 @@
|
|||||||
<MenuItem Header="Über" x:Name="MnuAbout" Click="MnuAbout_OnClick" />
|
<MenuItem Header="Über" x:Name="MnuAbout" Click="MnuAbout_OnClick" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<TabControl Grid.Row="1" x:Name="TcMain">
|
<TabControl Grid.Row="1">
|
||||||
<TabItem x:Name="Home">
|
|
||||||
<TabItem.Header>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<LucideIcon Kind="House" Width="32" Height="32" Size="32" />
|
|
||||||
<!-- <Label FontSize="20" Content="Addressverwaltung" VerticalContentAlignment="Center" /> -->
|
|
||||||
</StackPanel>
|
|
||||||
</TabItem.Header>
|
|
||||||
<Grid RowDefinitions="3*,*,100">
|
|
||||||
<StackPanel Orientation="Vertical" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" > <!-- ColumnDefinitions="*,*" -->
|
|
||||||
<Label Content="Welcome to Logofclient!" HorizontalAlignment="Center" FontSize="32" ></Label>
|
|
||||||
<Label Content="Version 1.0.1" FontSize="16" HorizontalAlignment="Center"></Label>
|
|
||||||
<!-- <Image Source="assets/calc_man.png" MaxHeight="350" VerticalAlignment="Center" HorizontalAlignment="Center" /> -->
|
|
||||||
</StackPanel>
|
|
||||||
<Grid Grid.Row="1" Margin="20" IsVisible="True" x:Name="GrdHMCalcMan">
|
|
||||||
<Image Source="assets/calc_man.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
|
||||||
</Grid>
|
|
||||||
<!-- <Grid ColumnDefinitions="*,*,*" Grid.Row="1"> -->
|
|
||||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Spacing="10" HorizontalAlignment="Center"
|
|
||||||
Margin="0,0,5,0">
|
|
||||||
<Button Width="250" HorizontalContentAlignment="Center"
|
|
||||||
Margin="0,0,0,10" IsEnabled="True" VerticalAlignment="Stretch"
|
|
||||||
x:Name="BtnAdmgmt" Click="BtnAdmgmt_OnClick">
|
|
||||||
<StackPanel Orientation="Vertical">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<LucideIcon Kind="MapPinHouse" Width="36" Height="36" />
|
|
||||||
<Label Content="Addressverwaltung" VerticalContentAlignment="Center" FontSize="15"
|
|
||||||
FontWeight="Bold" />
|
|
||||||
</StackPanel>
|
|
||||||
<TextBlock TextWrapping="Wrap" FontSize="9" Text="Strukturierte Verwaltung von Adressen für Pressepost-Printmailings inkl. Erstellung von Bundleitzetteln." HorizontalAlignment="Stretch" TextAlignment="Left"></TextBlock>
|
|
||||||
</StackPanel>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
</StackPanel>
|
|
||||||
<!-- </Grid> -->
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem IsVisible="False" x:Name="Addressmanagement">
|
<TabItem IsVisible="False" x:Name="Addressmanagement">
|
||||||
<TabItem.Header>
|
<TabItem.Header>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -124,14 +87,6 @@
|
|||||||
</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">
|
||||||
@@ -323,7 +278,6 @@
|
|||||||
<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">
|
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="20" Margin="10,10,10,0">
|
||||||
<StackPanel Orientation="Vertical" Spacing="10">
|
<StackPanel Orientation="Vertical" Spacing="10">
|
||||||
<Grid ColumnDefinitions="*,*">
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
|||||||
+1
-43
@@ -978,8 +978,6 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
var options = Settings._instance.pdfExport ?? new PdfExportSettings();
|
var options = Settings._instance.pdfExport ?? new PdfExportSettings();
|
||||||
|
|
||||||
CbExpLabEnable.IsChecked = (bool)options.expLabEnable;
|
|
||||||
|
|
||||||
NudExpMargCellPaddingTop.Value = (decimal)options.cellPaddingTopMm;
|
NudExpMargCellPaddingTop.Value = (decimal)options.cellPaddingTopMm;
|
||||||
NudExpMargCellPaddingBot.Value = (decimal)options.cellPaddingBottomMm;
|
NudExpMargCellPaddingBot.Value = (decimal)options.cellPaddingBottomMm;
|
||||||
NudExpMargCellPaddingLeft.Value = (decimal)options.cellPaddingLeftMm;
|
NudExpMargCellPaddingLeft.Value = (decimal)options.cellPaddingLeftMm;
|
||||||
@@ -996,7 +994,6 @@ public partial class MainWindow : Window
|
|||||||
NudExpMargFontSize.Value = (decimal)options.fontSize;
|
NudExpMargFontSize.Value = (decimal)options.fontSize;
|
||||||
NudExpMargSmallFontSize.Value = (decimal)options.smallFontSize;
|
NudExpMargSmallFontSize.Value = (decimal)options.smallFontSize;
|
||||||
CbExpRnsPvSt.IsChecked = options.rsPvSt;
|
CbExpRnsPvSt.IsChecked = options.rsPvSt;
|
||||||
CbExpRnsEnable.IsChecked = options.exportRunningSheets;
|
|
||||||
|
|
||||||
TbExpRnsKNrAbs.Text = options.rsKNrAbs;
|
TbExpRnsKNrAbs.Text = options.rsKNrAbs;
|
||||||
TbExpRnsKNrEmp.Text = options.rsKNrEmp;
|
TbExpRnsKNrEmp.Text = options.rsKNrEmp;
|
||||||
@@ -1033,8 +1030,6 @@ public partial class MainWindow : Window
|
|||||||
fontSize = ReadDouble(NudExpMargFontSize),
|
fontSize = ReadDouble(NudExpMargFontSize),
|
||||||
smallFontSize = ReadDouble(NudExpMargSmallFontSize),
|
smallFontSize = ReadDouble(NudExpMargSmallFontSize),
|
||||||
|
|
||||||
expLabEnable = CbExpLabEnable.IsChecked.Value,
|
|
||||||
|
|
||||||
rsKNrAbs = TbExpRnsKNrAbs.Text,
|
rsKNrAbs = TbExpRnsKNrAbs.Text,
|
||||||
rsKNrEmp = TbExpRnsKNrEmp.Text,
|
rsKNrEmp = TbExpRnsKNrEmp.Text,
|
||||||
rsZKZ = TbExpRnsZKZ.Text,
|
rsZKZ = TbExpRnsZKZ.Text,
|
||||||
@@ -1045,10 +1040,8 @@ public partial class MainWindow : Window
|
|||||||
rsBundGew = TbExpRnsBundGew.Text,
|
rsBundGew = TbExpRnsBundGew.Text,
|
||||||
rsPalNr = ReadInt(NudExpRnsPalNr, 1),
|
rsPalNr = ReadInt(NudExpRnsPalNr, 1),
|
||||||
rsBundNrPal = ReadInt(NudExpRnsBundNrPal, 20),
|
rsBundNrPal = ReadInt(NudExpRnsBundNrPal, 20),
|
||||||
rsNumGrouped = ReadInt(NudExpRnsPlzcount, 25),
|
|
||||||
|
|
||||||
rsPvSt = CbExpRnsPvSt.IsChecked.Value,
|
rsPvSt = CbExpRnsPvSt.IsChecked.Value
|
||||||
exportRunningSheets = CbExpRnsEnable.IsChecked.Value
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings.Save();
|
Settings.Save();
|
||||||
@@ -1478,39 +1471,4 @@ 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)
|
|
||||||
{
|
|
||||||
TcMain.SelectedIndex = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ public static class AddressCreator
|
|||||||
} // Error-Handling?
|
} // Error-Handling?
|
||||||
|
|
||||||
if (address_line_count > 1) return string_address;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,26 +3,16 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks.Dataflow;
|
using System.Threading.Tasks.Dataflow;
|
||||||
using System.Threading;
|
|
||||||
using Avalonia.Threading;
|
|
||||||
|
|
||||||
namespace Logof_Client;
|
namespace Logof_Client;
|
||||||
|
|
||||||
public class AddressShortener
|
public class AddressShortener(ProgressWindow progressWindow)
|
||||||
{
|
{
|
||||||
private readonly ProgressWindow _progress;
|
|
||||||
|
|
||||||
public AddressShortener(ProgressWindow progressWindow)
|
|
||||||
{
|
|
||||||
_progress = progressWindow;
|
|
||||||
}
|
|
||||||
public async Task Perform(KasAddressList list)
|
public async Task Perform(KasAddressList list)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<int> doubled_ids = new List<int>();
|
List<int> doubled_ids = new List<int>();
|
||||||
int[] percentages = [25,25,25,25];
|
|
||||||
|
|
||||||
for (int i = 0; i < list.KasPersons.Count; i++)
|
for (int i = 0; i < list.KasPersons.Count; i++)
|
||||||
{
|
{
|
||||||
var address = list.KasPersons[i];
|
var address = list.KasPersons[i];
|
||||||
@@ -36,19 +26,8 @@ public class AddressShortener
|
|||||||
doubled_ids.Add(address.refsid);
|
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
|
// delete doubled addresses by refsid
|
||||||
foreach (int id in doubled_ids)
|
foreach (int id in doubled_ids)
|
||||||
{
|
{
|
||||||
@@ -86,19 +65,12 @@ public class AddressShortener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string faileds = "Folgende Adressen wurden entfernt:\n(refsid - Name, Vorname)\n\n";
|
|
||||||
// delete doubled addresses by refsid
|
// delete doubled addresses by refsid
|
||||||
foreach (int id in toRemove)
|
foreach (int id in toRemove)
|
||||||
{
|
{
|
||||||
// does this remove both of the doubled addresses?
|
// does this remove both of the doubled addresses?
|
||||||
var pers = list.KasPersons.Find(x => x.id == id);
|
list.KasPersons.Remove(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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
+62
-94
@@ -92,8 +92,6 @@ public class PdfBuilder
|
|||||||
public void CreateAddressLabelPdfFromAddressSetWithPlaceholder(int addressSetId, string placeholderText, bool pvst,
|
public void CreateAddressLabelPdfFromAddressSetWithPlaceholder(int addressSetId, string placeholderText, bool pvst,
|
||||||
string outputPath)
|
string outputPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Find the AddressSet by ID
|
// Find the AddressSet by ID
|
||||||
@@ -122,21 +120,18 @@ public class PdfBuilder
|
|||||||
senderLine = null;
|
senderLine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<KasPerson> failed = new();
|
|
||||||
// national addresses
|
// national addresses
|
||||||
foreach (var person in addressSet.KasPersons
|
for (var i = 0; i < addressSet.KasPersons.Count; i++)
|
||||||
.Where(person => person.IsGermany())
|
|
||||||
.OrderBy(person => person.used_plz))
|
|
||||||
{
|
{
|
||||||
string senderLineID = senderLine;
|
string senderLineID = senderLine;
|
||||||
var addr = AddressCreator.CreateFinalMarkdownString(person.id);
|
if (!addressSet.KasPersons[i].IsGermany()) continue;
|
||||||
if(addr == null) failed.Add(person);
|
var addr = AddressCreator.CreateFinalMarkdownString(addressSet.KasPersons[i].id);
|
||||||
if (string.IsNullOrWhiteSpace(addr)) continue;
|
if (string.IsNullOrWhiteSpace(addr)) continue;
|
||||||
if (pvst)
|
if (pvst)
|
||||||
senderLineID += $"</font6>**PvSt, DP AG, Entgelt bezahlt, ZKZ {Settings._instance.pdfExport.rsZKZ}**\n<font6>";
|
senderLineID += $"</font6>**PvSt, DP AG, Entgelt bezahlt, ZKZ {Settings._instance.pdfExport.rsZKZ}**\n<font6>";
|
||||||
|
|
||||||
if (person.refsid != null || person.refsid != 0)
|
if (addressSet.KasPersons[i].refsid != null || addressSet.KasPersons[i].refsid != 0)
|
||||||
senderLineID += $"ID: {person.refsid}\n</font6>";
|
senderLineID += $"ID: {addressSet.KasPersons[i].refsid}\n</font6>";
|
||||||
else
|
else
|
||||||
senderLineID += "\n</font6>";
|
senderLineID += "\n</font6>";
|
||||||
if (!string.IsNullOrEmpty(senderLineID))
|
if (!string.IsNullOrEmpty(senderLineID))
|
||||||
@@ -146,20 +141,17 @@ public class PdfBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// international addresses
|
// international addresses
|
||||||
foreach (var person in addressSet.KasPersons
|
for (var i = 0; i < addressSet.KasPersons.Count; i++)
|
||||||
.Where(person => !person.IsGermany())
|
|
||||||
.OrderBy(person => person.land)
|
|
||||||
.ThenBy(person => person.used_plz))
|
|
||||||
{
|
{
|
||||||
string senderLineID = senderLine;
|
string senderLineID = senderLine;
|
||||||
var addr = AddressCreator.CreateFinalMarkdownString(person.id);
|
if (addressSet.KasPersons[i].IsGermany()) continue;
|
||||||
if(addr == null) failed.Add(person);
|
var addr = AddressCreator.CreateFinalMarkdownString(addressSet.KasPersons[i].id);
|
||||||
if (string.IsNullOrWhiteSpace(addr)) continue;
|
if (string.IsNullOrWhiteSpace(addr)) continue;
|
||||||
if (pvst)
|
if (pvst)
|
||||||
senderLineID += $"</font6>**PvSt, DP AG, Entgelt bezahlt, ZKZ {Settings._instance.pdfExport.rsZKZ}**\n<font6>";
|
senderLineID += $"</font6>**PvSt, DP AG, Entgelt bezahlt, ZKZ {Settings._instance.pdfExport.rsZKZ}**\n<font6>";
|
||||||
|
|
||||||
if (person.refsid != null || person.refsid != 0)
|
if (addressSet.KasPersons[i].refsid != null || addressSet.KasPersons[i].refsid != 0)
|
||||||
senderLineID += $"ID: {person.refsid}\n</font6>";
|
senderLineID += $"ID: {addressSet.KasPersons[i].refsid}\n</font6>";
|
||||||
else
|
else
|
||||||
senderLineID += "\n</font6>";
|
senderLineID += "\n</font6>";
|
||||||
if (!string.IsNullOrEmpty(senderLineID))
|
if (!string.IsNullOrEmpty(senderLineID))
|
||||||
@@ -176,29 +168,13 @@ public class PdfBuilder
|
|||||||
|
|
||||||
string output_inter = outputPath.Replace(".pdf", "-international.pdf");
|
string output_inter = outputPath.Replace(".pdf", "-international.pdf");
|
||||||
|
|
||||||
if(Settings._instance.pdfExport.expLabEnable == false)
|
if(addresses_german.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath, pvst);
|
||||||
{
|
if(addresses_inter.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter, pvst);
|
||||||
Logger.Log("Skipping label pdf generation cause it was disabled by user");
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
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.exportRunningSheets)
|
if (_settings.exportRunningSheets)
|
||||||
{
|
{
|
||||||
ExportRunningSheets(addressSetId, outputPath);
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -733,14 +709,12 @@ public class PdfBuilder
|
|||||||
var fontBig = new XFont("Arial", 30, XFontStyleEx.Bold);
|
var fontBig = new XFont("Arial", 30, XFontStyleEx.Bold);
|
||||||
|
|
||||||
int firstIndex = pageIndex * 2;
|
int firstIndex = pageIndex * 2;
|
||||||
int? palletNumber = null;
|
int palletNumber =
|
||||||
int? bundleOnPallet = null;
|
Settings._instance.pdfExport.rsPalNr +
|
||||||
if (Settings._instance.pdfExport.rsBundNrPal > 0)
|
(firstIndex / Settings._instance.pdfExport.rsBundNrPal);
|
||||||
{
|
|
||||||
palletNumber = Settings._instance.pdfExport.rsPalNr +
|
int bundleOnPallet =
|
||||||
(firstIndex / Settings._instance.pdfExport.rsBundNrPal);
|
(firstIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
||||||
bundleOnPallet = (firstIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawGermanyRunningSheet(
|
DrawGermanyRunningSheet(
|
||||||
gfx,
|
gfx,
|
||||||
@@ -761,14 +735,12 @@ public class PdfBuilder
|
|||||||
|
|
||||||
int secondIndex = firstIndex + 1;
|
int secondIndex = firstIndex + 1;
|
||||||
|
|
||||||
int? palletNumber2 = null;
|
int palletNumber2 =
|
||||||
int? bundleOnPallet2 = null;
|
Settings._instance.pdfExport.rsPalNr +
|
||||||
if (Settings._instance.pdfExport.rsBundNrPal > 0)
|
(secondIndex / Settings._instance.pdfExport.rsBundNrPal);
|
||||||
{
|
|
||||||
palletNumber2 = Settings._instance.pdfExport.rsPalNr +
|
int bundleOnPallet2 =
|
||||||
(secondIndex / Settings._instance.pdfExport.rsBundNrPal);
|
(secondIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
||||||
bundleOnPallet2 = (secondIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstIndex + 1 < grouped_nums.Count)
|
if (firstIndex + 1 < grouped_nums.Count)
|
||||||
{
|
{
|
||||||
@@ -794,7 +766,7 @@ public class PdfBuilder
|
|||||||
document.Save(path);
|
document.Save(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -942,20 +914,20 @@ public class PdfBuilder
|
|||||||
new XRect(valueX, blY1 + 4, valueW, 14),
|
new XRect(valueX, blY1 + 4, valueW, 14),
|
||||||
XStringFormats.TopRight);
|
XStringFormats.TopRight);
|
||||||
|
|
||||||
if (options.rsBundNrPal > 0)
|
if (options.rsBundNrPal == null) goto nopal;
|
||||||
{
|
gfx.DrawString(pal_nr.ToString(), fontText, XBrushes.Black,
|
||||||
gfx.DrawString(pal_nr?.ToString() ?? string.Empty, fontText, XBrushes.Black,
|
new XRect(valueX, blY3 + 4, valueW, 14),
|
||||||
new XRect(valueX, blY3 + 4, valueW, 14),
|
XStringFormats.TopRight);
|
||||||
XStringFormats.TopRight);
|
|
||||||
|
|
||||||
gfx.DrawString(
|
|
||||||
$"{bundleOnPallet}/{options.rsBundNrPal}",
|
|
||||||
fontText,
|
|
||||||
XBrushes.Black,
|
|
||||||
new XRect(valueX, blY4 + 4, valueW, 14),
|
|
||||||
XStringFormats.TopRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
gfx.DrawString(
|
||||||
|
$"{bundleOnPallet}/{Settings._instance.pdfExport.rsBundNrPal}",
|
||||||
|
fontText,
|
||||||
|
XBrushes.Black,
|
||||||
|
new XRect(valueX, blY4 + 4, valueW, 14),
|
||||||
|
XStringFormats.TopRight);
|
||||||
|
|
||||||
|
nopal:
|
||||||
gfx.DrawString(
|
gfx.DrawString(
|
||||||
$"{totalBundleNumber}/{grouped_nums.Count}",
|
$"{totalBundleNumber}/{grouped_nums.Count}",
|
||||||
fontText,
|
fontText,
|
||||||
@@ -1012,14 +984,12 @@ public class PdfBuilder
|
|||||||
|
|
||||||
int firstIndex = pageIndex * 2;
|
int firstIndex = pageIndex * 2;
|
||||||
|
|
||||||
int? palletNumber = null;
|
int palletNumber =
|
||||||
int? bundleOnPallet = null;
|
Settings._instance.pdfExport.rsPalNr +
|
||||||
if (Settings._instance.pdfExport.rsBundNrPal > 0)
|
(firstIndex / Settings._instance.pdfExport.rsBundNrPal);
|
||||||
{
|
|
||||||
palletNumber = Settings._instance.pdfExport.rsPalNr +
|
int bundleOnPallet =
|
||||||
(firstIndex / Settings._instance.pdfExport.rsBundNrPal);
|
(firstIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
||||||
bundleOnPallet = (firstIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1044,14 +1014,12 @@ public class PdfBuilder
|
|||||||
{
|
{
|
||||||
int secondIndex = firstIndex + 1;
|
int secondIndex = firstIndex + 1;
|
||||||
|
|
||||||
int? palletNumber2 = null;
|
int palletNumber2 =
|
||||||
int? bundleOnPallet2 = null;
|
Settings._instance.pdfExport.rsPalNr +
|
||||||
if (Settings._instance.pdfExport.rsBundNrPal > 0)
|
(secondIndex / Settings._instance.pdfExport.rsBundNrPal);
|
||||||
{
|
|
||||||
palletNumber2 = Settings._instance.pdfExport.rsPalNr +
|
int bundleOnPallet2 =
|
||||||
(secondIndex / Settings._instance.pdfExport.rsBundNrPal);
|
(secondIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
||||||
bundleOnPallet2 = (secondIndex % Settings._instance.pdfExport.rsBundNrPal) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawInternationalRunningSheet(
|
DrawInternationalRunningSheet(
|
||||||
gfx,
|
gfx,
|
||||||
@@ -1074,7 +1042,7 @@ public class PdfBuilder
|
|||||||
|
|
||||||
document.Save(path);
|
document.Save(path);
|
||||||
}
|
}
|
||||||
private void DrawInternationalRunningSheet(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, string category = "ECONOMY Non-EU")
|
private void DrawInternationalRunningSheet(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, string category = "ECONOMY Non-EU")
|
||||||
{
|
{
|
||||||
double line = 1.0;
|
double line = 1.0;
|
||||||
|
|
||||||
@@ -1226,20 +1194,20 @@ public class PdfBuilder
|
|||||||
new XRect(valueX, blY2 + 4, valueW, 14),
|
new XRect(valueX, blY2 + 4, valueW, 14),
|
||||||
XStringFormats.TopRight);
|
XStringFormats.TopRight);
|
||||||
|
|
||||||
if (options.rsBundNrPal > 0)
|
if (options.rsBundNrPal == 0) goto nopal;
|
||||||
{
|
gfx.DrawString(pal_nr.ToString(), fontText, XBrushes.Black,
|
||||||
gfx.DrawString(pal_nr?.ToString() ?? string.Empty, fontText, XBrushes.Black,
|
new XRect(valueX, blY3 + 4, valueW, 14),
|
||||||
new XRect(valueX, blY3 + 4, valueW, 14),
|
XStringFormats.TopRight);
|
||||||
XStringFormats.TopRight);
|
|
||||||
|
|
||||||
gfx.DrawString(
|
|
||||||
$"{bundleOnPallet}/{options.rsBundNrPal}",
|
|
||||||
fontText,
|
|
||||||
XBrushes.Black,
|
|
||||||
new XRect(valueX, blY4 + 4, valueW, 14),
|
|
||||||
XStringFormats.TopRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
gfx.DrawString(
|
||||||
|
$"{bundleOnPallet}/{Settings._instance.pdfExport.rsBundNrPal}",
|
||||||
|
fontText,
|
||||||
|
XBrushes.Black,
|
||||||
|
new XRect(valueX, blY4 + 4, valueW, 14),
|
||||||
|
XStringFormats.TopRight);
|
||||||
|
|
||||||
|
nopal:
|
||||||
gfx.DrawString(
|
gfx.DrawString(
|
||||||
$"{totalBundleNumber}/{grouped_nums.Count}",
|
$"{totalBundleNumber}/{grouped_nums.Count}",
|
||||||
fontText,
|
fontText,
|
||||||
|
|||||||
Reference in New Issue
Block a user