diff --git a/DataStore/SchemaMigration.cs b/DataStore/SchemaMigration.cs index 2c32d65..e757d69 100644 --- a/DataStore/SchemaMigration.cs +++ b/DataStore/SchemaMigration.cs @@ -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> Migrations = new() @@ -24,6 +24,7 @@ public static class SchemaMigration // Example: Migration from v2 to v3 { 4, MigrateV3ToV4 }, + { 5, MigrateV4ToV5 }, }; /// @@ -104,6 +105,16 @@ 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); + } + + return obj; + } /// /// Registers a new migration function that will be called when upgrading to a specific version. diff --git a/DataStore/Settings.cs b/DataStore/Settings.cs index b81e7ba..cfeb223 100644 --- a/DataStore/Settings.cs +++ b/DataStore/Settings.cs @@ -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; diff --git a/MainWindow.axaml b/MainWindow.axaml index 8a98bc9..e29141c 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -315,6 +315,7 @@ + diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index 993a58d..06e83ad 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -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; @@ -1031,6 +1033,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, diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs index b0a68b4..adedf21 100644 --- a/Tasks/PdfBuilder.cs +++ b/Tasks/PdfBuilder.cs @@ -92,6 +92,8 @@ public class PdfBuilder public void CreateAddressLabelPdfFromAddressSetWithPlaceholder(int addressSetId, string placeholderText, bool pvst, string outputPath) { + + try { // Find the AddressSet by ID @@ -174,9 +176,16 @@ 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) CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath, pvst); + if(addresses_inter.Count > 0) CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter, pvst); + } + if (_settings.exportRunningSheets) { ExportRunningSheets(addressSetId, outputPath);