Procházet zdrojové kódy

### 1.2.1 (2025-04-01)

- Přidána možnost definovat agregaci při generování štítků a přidávání kalkulovaných sloupců
- Rozšíření nastavení (konfigurace) tisku štítků

konfigurace je nefunkční (quick-win)
Dalibor Votruba před 1 rokem
rodič
revize
516e300ceb

+ 7 - 1
App.config

@@ -72,11 +72,17 @@
                 <value>8</value>
             </setting>
             <setting name="LabelTemplate" serializeAs="String">
-                <value>^^18^**Objednávka: {order_no}**^^{cr}^^14^**{prod_cat}**^^{cr}{prod_var_type}{cr}Počet: {qty}</value>
+                <value>^^18^**Objednávka: {order_no}**^^{cr}^^14^**{prod_cat}**^^{cr}{prod_var_type_list}</value>
             </setting>
             <setting name="CSVDelimiter" serializeAs="String">
                 <value>,</value>
             </setting>
+            <setting name="LabelAggregateColumns" serializeAs="String">
+                <value>order_no, prod_cat</value>
+            </setting>
+            <setting name="LabelAggegationDataExpression" serializeAs="String">
+                <value>prod_var_type_list={prod_var_type} : {qty}{cr}</value>
+            </setting>
         </qdr.app.studiou.orders2printpack.Properties.AppSettings>
     </userSettings>
 </configuration>

+ 40 - 0
FormLabelPrint.cs

@@ -58,6 +58,8 @@ namespace qdr.app.studiou.orders2printpack
                 if (!File.Exists(_csvPath)) throw new Exception($"Vstupní CSV soubor '{_csvPath}' neexistuje, vyberte existující soubor.");
                 if (_data == null) throw new Exception($"Vstupní CSV soubor '{_csvPath}' musí být otevřen.");
 
+                _data = ProcessData(_data);
+
                 var generator = new ExcelLabelGenerator(AppSettings.Default.LabelTemplate.Replace("{cr}","\n"));
 
                 if (generator.GenerateLabels(_data, _xlsPath, int.Parse(AppSettings.Default.LabelPerRow), int.Parse(AppSettings.Default.LabelPerCol), double.Parse(AppSettings.Default.LabelWidth), double.Parse(AppSettings.Default.LabelHeight)))
@@ -67,6 +69,40 @@ namespace qdr.app.studiou.orders2printpack
             });
         }
 
+        private DataTable ProcessData(DataTable data)
+        {
+            //LabelAggegationDataExpression
+            var expressionParts = AppSettings.Default.LabelAggegationDataExpression.Split('=');
+            var expressionColumnName = expressionParts[0];
+            var expressionValue = expressionParts[1];
+            data.Columns.Add(expressionColumnName, typeof(string));
+
+            var result = data.Clone();
+            result.Rows.Clear();
+
+            foreach (DataRow row in data.Rows)
+            {
+                var rowNew = result.Select($"order_no = '{row["order_no"]}' AND prod_cat = '{row["prod_cat"]}'");
+                if (rowNew.Length == 0)
+                {
+                    var newRow = result.NewRow();
+                    newRow.ItemArray = row.ItemArray.ToArray();
+                    newRow[expressionColumnName] = expressionValue.Replace("{prod_var_type}", row["prod_var_type"].ToString())
+                        .Replace("{qty}",row["qty"].ToString()).Replace("{cr}","\n");
+                    result.Rows.Add(newRow);
+                }
+                else
+                {
+                    rowNew[0][expressionColumnName] = rowNew[0][expressionColumnName] + expressionValue.Replace("{prod_var_type}", row["prod_var_type"].ToString())
+                        .Replace("{qty}", row["qty"].ToString()).Replace("{cr}", "\n");
+                }
+            }
+            return result;
+
+        }
+
+
+
         private void butConfig_Click(object sender, EventArgs e)
         {
             var dlg = new dlgLabelSettings();
@@ -105,5 +141,9 @@ namespace qdr.app.studiou.orders2printpack
             }
         }
         #endregion
+
+        #region *** Nested classes ***
+
+        #endregion
     }
 }

+ 26 - 2
Properties/AppSettings.Designer.cs

@@ -278,8 +278,8 @@ namespace qdr.app.studiou.orders2printpack.Properties {
         
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("^^18^**Objednávka: {order_no}**^^{cr}^^14^**{prod_cat}**^^{cr}{prod_var_type}{cr}" +
-            "Počet: {qty}")]
+        [global::System.Configuration.DefaultSettingValueAttribute("^^18^**Objednávka: {order_no}**^^{cr}^^14^**{prod_cat}**^^{cr}{prod_var_type_list" +
+            "}")]
         public string LabelTemplate {
             get {
                 return ((string)(this["LabelTemplate"]));
@@ -300,5 +300,29 @@ namespace qdr.app.studiou.orders2printpack.Properties {
                 this["CSVDelimiter"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("order_no, prod_cat")]
+        public string LabelAggregateColumns {
+            get {
+                return ((string)(this["LabelAggregateColumns"]));
+            }
+            set {
+                this["LabelAggregateColumns"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("prod_var_type_list={prod_var_type} : {qty}{cr}")]
+        public string LabelAggegationDataExpression {
+            get {
+                return ((string)(this["LabelAggegationDataExpression"]));
+            }
+            set {
+                this["LabelAggegationDataExpression"] = value;
+            }
+        }
     }
 }

+ 7 - 1
Properties/AppSettings.settings

@@ -67,10 +67,16 @@
       <Value Profile="(Default)">8</Value>
     </Setting>
     <Setting Name="LabelTemplate" Type="System.String" Scope="User">
-      <Value Profile="(Default)">^^18^**Objednávka: {order_no}**^^{cr}^^14^**{prod_cat}**^^{cr}{prod_var_type}{cr}Počet: {qty}</Value>
+      <Value Profile="(Default)">^^18^**Objednávka: {order_no}**^^{cr}^^14^**{prod_cat}**^^{cr}{prod_var_type_list}</Value>
     </Setting>
     <Setting Name="CSVDelimiter" Type="System.String" Scope="User">
       <Value Profile="(Default)">,</Value>
     </Setting>
+    <Setting Name="LabelAggregateColumns" Type="System.String" Scope="User">
+      <Value Profile="(Default)">order_no, prod_cat</Value>
+    </Setting>
+    <Setting Name="LabelAggegationDataExpression" Type="System.String" Scope="User">
+      <Value Profile="(Default)">prod_var_type_list={prod_var_type} : {qty}{cr}</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

+ 4 - 0
README.md

@@ -4,6 +4,10 @@ Proprietální řešení zpracování WooCommerce objednávek pro online tiskovo
 
 ## Changelog
 
+### 1.2.1 (2025-04-01)
+- Přidána možnost definovat agregaci při generování štítků a přidávání kalkulovaných sloupců
+- Rozšíření nastavení (konfigurace) tisku štítků
+
 ### 1.2.0 (2025-03-13)
 - Upgrade na .NET 9.0
 - Přidána podpora pro tisk štítků podle importovaného .CSV do xlsx (Excel)

+ 4 - 4
Setup/Setup.vdproj

@@ -198,15 +198,15 @@
         {
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:Order2PrintPack"
-        "ProductCode" = "8:{6C91447D-8838-4610-BA8A-459AFE932E81}"
-        "PackageCode" = "8:{22834C86-369C-4B27-B4F0-B50D173BDBA3}"
+        "ProductCode" = "8:{EC4F37FF-8CB1-42BE-B0DF-B171C15C34D3}"
+        "PackageCode" = "8:{546B1AEA-5D3A-4345-A5C5-592E1E638DC0}"
         "UpgradeCode" = "8:{38F8DC1E-8290-49ED-A3D2-32BC6DD74325}"
         "AspNetVersion" = "8:2.0.50727.0"
         "RestartWWWService" = "11:FALSE"
         "RemovePreviousVersions" = "11:TRUE"
         "DetectNewerInstalledVersion" = "11:TRUE"
         "InstallAllUsers" = "11:FALSE"
-        "ProductVersion" = "8:1.2.0"
+        "ProductVersion" = "8:1.2.1"
         "Manufacturer" = "8:Quadarax"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:"
@@ -734,7 +734,7 @@
         {
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_401EDA760B6F46889C1BF580F3C37DBF"
             {
-            "SourcePath" = "8:..\\obj\\x64\\Debug\\net9.0-windows7.0\\apphost.exe"
+            "SourcePath" = "8:..\\obj\\x64\\Release\\net9.0-windows7.0\\apphost.exe"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_96DC0B7F01834A1BA713E7E8A0904D3E"

+ 1 - 1
dlgLabelSettings.Designer.cs

@@ -91,7 +91,7 @@
             label2.Name = "label2";
             label2.Size = new Size(100, 120);
             label2.TabIndex = 4;
-            label2.Text = "Použité proměné:\r\norder_no\r\nprod_cat\r\nprod_name\r\nprod_var\r\nprod_var_type\r\nprod_img_url\r\nqty";
+            label2.Text = "Použité proměné:\r\norder_no\r\nprod_cat\r\nprod_name\r\nprod_var\r\nprod_var_type\r\nprod_img_url\r\nqty\r\ncr";
             // 
             // label3
             // 

+ 3 - 2
dlgLabelSettings.cs

@@ -28,8 +28,8 @@ namespace qdr.app.studiou.orders2printpack
             AppSettings.Default.LabelTemplate = tbTemplate.Text;
             AppSettings.Default.LabelPerCol = tbLPerCol.Text;
             AppSettings.Default.LabelPerRow = tbLPerRow.Text;
-             AppSettings.Default.LabelWidth = tbLWidth.Text;
-            AppSettings.Default.LabelHeight =tbLHeight.Text ;
+            AppSettings.Default.LabelWidth = tbLWidth.Text;
+            AppSettings.Default.LabelHeight = tbLHeight.Text;
             AppSettings.Default.Save();
             Close();
         }
@@ -40,5 +40,6 @@ namespace qdr.app.studiou.orders2printpack
         {
             Close();
         }
+
     }
 }

+ 1 - 1
qdr.app.studiou.orders2printpack.csproj

@@ -18,7 +18,7 @@
     <Platforms>AnyCPU;x86;x64</Platforms>
     <AssemblyVersion>1.2.0.0</AssemblyVersion>
     <FileVersion>1.2.0.0</FileVersion>
-    <Version>1.2.0</Version>
+    <Version>1.2.1</Version>
 	<ForceDesignerDpiUnaware>true</ForceDesignerDpiUnaware>
   </PropertyGroup>