From 05665288abf01a39b5f6baa19598402775b5edb2 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 6 Dec 2023 12:03:26 +0100 Subject: [PATCH] 1. LabelPrinting project created (based on Prod..Mon..SNPrinting), 2. Minor changes in Label.Printer --- .gitignore | 2 + LabelPrinting/App.config | 6 + LabelPrinting/Cnst.cs | 7 + LabelPrinting/LabelPrinting.csproj | 177 +++++++ LabelPrinting/LocalSettings.cs | 245 +++++++++ LabelPrinting/MainWnd.Designer.cs | 197 +++++++ LabelPrinting/MainWnd.cs | 480 ++++++++++++++++++ LabelPrinting/MainWnd.resx | 123 +++++ .../Printers/DataMatrixAndTextPrintDoc.cs | 120 +++++ LabelPrinting/Program.cs | 251 +++++++++ LabelPrinting/Properties/AssemblyInfo.cs | 35 ++ .../Properties/Resources.Designer.cs | 71 +++ LabelPrinting/Properties/Resources.resx | 117 +++++ LabelPrinting/Properties/Settings.Designer.cs | 30 ++ LabelPrinting/Properties/Settings.settings | 7 + LabelPrinting/Resources/Strings.Designer.cs | 414 +++++++++++++++ LabelPrinting/Resources/Strings.cs.resx | 234 +++++++++ LabelPrinting/Resources/Strings.resx | 237 +++++++++ LabelPrinting/Resources/Strings.sk.resx | 234 +++++++++ LabelPrinting/SampleConfig/log4netConfig.xml | 23 + LabelPrinting/SettingsDlg.Designer.cs | 283 +++++++++++ LabelPrinting/SettingsDlg.cs | 170 +++++++ LabelPrinting/SettingsDlg.resx | 120 +++++ .../Printers/Label/LabelPrintDocument.cs | 4 +- TBF.sln | 14 + TBF/Rig/Output/Printers/Label/Printer.cs | 8 +- clean.bat | 2 + 27 files changed, 3604 insertions(+), 7 deletions(-) create mode 100644 LabelPrinting/App.config create mode 100644 LabelPrinting/Cnst.cs create mode 100644 LabelPrinting/LabelPrinting.csproj create mode 100644 LabelPrinting/LocalSettings.cs create mode 100644 LabelPrinting/MainWnd.Designer.cs create mode 100644 LabelPrinting/MainWnd.cs create mode 100644 LabelPrinting/MainWnd.resx create mode 100644 LabelPrinting/Printers/DataMatrixAndTextPrintDoc.cs create mode 100644 LabelPrinting/Program.cs create mode 100644 LabelPrinting/Properties/AssemblyInfo.cs create mode 100644 LabelPrinting/Properties/Resources.Designer.cs create mode 100644 LabelPrinting/Properties/Resources.resx create mode 100644 LabelPrinting/Properties/Settings.Designer.cs create mode 100644 LabelPrinting/Properties/Settings.settings create mode 100644 LabelPrinting/Resources/Strings.Designer.cs create mode 100644 LabelPrinting/Resources/Strings.cs.resx create mode 100644 LabelPrinting/Resources/Strings.resx create mode 100644 LabelPrinting/Resources/Strings.sk.resx create mode 100644 LabelPrinting/SampleConfig/log4netConfig.xml create mode 100644 LabelPrinting/SettingsDlg.Designer.cs create mode 100644 LabelPrinting/SettingsDlg.cs create mode 100644 LabelPrinting/SettingsDlg.resx diff --git a/.gitignore b/.gitignore index 1099e451e..a5460d2a6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ GenericTest/bin/ GenericTest/obj/ GraphLib/bin/ GraphLib/obj/ +LabelPrinting/bin/ +LabelPrinting/obj/ MergeResultsDBs/bin/ MergeResultsDBs/obj/ OrderManagement/bin/ diff --git a/LabelPrinting/App.config b/LabelPrinting/App.config new file mode 100644 index 000000000..56efbc7b5 --- /dev/null +++ b/LabelPrinting/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LabelPrinting/Cnst.cs b/LabelPrinting/Cnst.cs new file mode 100644 index 000000000..4141b3563 --- /dev/null +++ b/LabelPrinting/Cnst.cs @@ -0,0 +1,7 @@ +namespace LabelPrinting +{ + public class Cnst + { + public const int ExtraPieces = 10; + } +} diff --git a/LabelPrinting/LabelPrinting.csproj b/LabelPrinting/LabelPrinting.csproj new file mode 100644 index 000000000..495dc5515 --- /dev/null +++ b/LabelPrinting/LabelPrinting.csproj @@ -0,0 +1,177 @@ + + + + + Debug + AnyCPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF} + WinExe + Properties + LabelPrinting + LabelPrinting + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + LabelPrinting.Program + + + + False + ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll + + + ..\packages\QrCode.Net.0.4.0.0\net40\Gma.QrCodeNet.Encoding.dll + + + False + ..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll + + + ..\packages\log4net.2.0.2\lib\net40-full\log4net.dll + + + ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll + + + False + ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll + + + + + + + + + + + + + + + + + Form + + + MainWnd.cs + + + Component + + + + + True + True + Strings.resx + + + Form + + + SettingsDlg.cs + + + MainWnd.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + ResXFileCodeGenerator + Strings.Designer.cs + + + + SettingsDlg.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {c8939821-ba5c-4988-a3d0-bf53b74865c7} + Common + + + {743df7db-c7b6-42eb-986d-0f485e5588e4} + Config + + + {7cd2b5b4-3304-4151-b8b4-76a8b8af9b06} + DataMatrix4Net + + + {32817bf9-e380-4467-9c7f-936f4b122bc7} + GenCode128 + + + {9d0dcc88-dc81-47eb-9fdd-4c3907871bfb} + Results + + + {211b5e3f-9996-48a7-abde-c878dd2d71c2} + SharedDatabase + + + {8648fd92-cda1-4c3a-b5f9-fe547ce1fa48} + TBF + + + {6e5cb0e9-e1b6-4e5d-ac6e-b1049e180f2b} + Users + + + + + + Always + + + + + \ No newline at end of file diff --git a/LabelPrinting/LocalSettings.cs b/LabelPrinting/LocalSettings.cs new file mode 100644 index 000000000..63c8cff49 --- /dev/null +++ b/LabelPrinting/LocalSettings.cs @@ -0,0 +1,245 @@ +/// +/// Copyright (c) 2021-2023 Sensus Slovensko a.s. +/// +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; +using System.Xml.Serialization; + +namespace LabelPrinting +{ + /// + /// Class to be serialized to an XML file... + /// + [XmlRootAttribute("SNPrinting")] + public class LocalSettings + { + static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0]; + + /// Configuration file ecryption/decryption key and initialization vector + static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 }; + static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 }; + + public Mode Mode; + public string Language; /// User interface language used as CultureInfo(..) constructor argument + public int DelayBetweenLabels; /// Delay between printing two consecutive labels in ms + public bool IsUserLoginRequired; /// true = require user login on program start-up + public string LabelPrinterCfg; + public string TracingDBConnString; /// Connection string to MySQL database with production tracing records + public string UsersDBConnString; /// Connection string to MySQL database with authorized users + public string[] SapNumberHistory; /// SAP number history + public string[] SeparatorHistory; /// Separator history + public int CurrentSNTrail; /// Serial number trail to be printed now + public int RemainingSNsCount; /// Remaining count of serial numbers to be printed in this session + + + /// Parameterless constructor required by serialization + public LocalSettings() { } + + public LocalSettings(bool createNew) + { + if (createNew) + { + Mode = Mode.TbfLabelPrinter; + Language = "EN"; + DelayBetweenLabels = 1000; + IsUserLoginRequired = false; + LabelPrinterCfg = new TBF.Rig.Output.Printers.Label.Factory().DefaultConfig().CreateDbEntity().Parameters; + TracingDBConnString = string.Empty; + UsersDBConnString = string.Empty; + SapNumberHistory = new string[] { }; + SeparatorHistory = new string[] { "4VQ" }; + CurrentSNTrail = 1; + RemainingSNsCount = 1; + } + } + + /// + /// Load public fields of this class from the XML file. + /// + /// LocalSettings object or null when Load() fails + public static LocalSettings Load(string fileName) + { + try + { + bool isEncrypted = true; + using (StreamReader reader = new StreamReader(fileName)) + { + isEncrypted = !reader.ReadLine().StartsWith(" + /// Save public fields of this class to the XML file. + /// + public void Save() + { + try + { + /// Encrypt and write to file 'Program.LocalSettingsFileName' + using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros }) + { + using (FileStream fsCrypt = new FileStream(Program.LocalSettingsFileName, FileMode.Create)) + { + using (ICryptoTransform encryptor = aes.CreateEncryptor(key, IV)) + { + using (CryptoStream cs = new CryptoStream(fsCrypt, encryptor, CryptoStreamMode.Write)) + { + using (MemoryStream mStream = new MemoryStream()) + { + using (var writer = new StreamWriter(mStream)) + { + /// Serialize and write settings to a memory stream + serializer.Serialize(writer, this); + writer.Flush(); + mStream.Position = 0; + + using (var reader = new StreamReader(mStream)) + { + /// Encrypt and write to file 'Program.LocalSettingsFileName' + int data; + while ((data = mStream.ReadByte()) != -1) cs.WriteByte((byte)data); + } + } + } + } + } + } + } + } + catch (Exception e) + { + string msg = e.Message; + } + } + + /// + /// Updates history stored in a string array by a new latest string. + /// + /// Last entered string + /// true = history updated + public static bool UpdateHistory(string lastStrValue, ref string[] history) + { + const int MaxHistoryLen = 10; + + if (string.IsNullOrEmpty(lastStrValue)) return false; + + int currentHistoryLength = (history != null) ? history.Length : 0; + + int match = -1; + for (int i = 0; i < currentHistoryLength; i++) + { + if (history[i] == lastStrValue) + { + match = i; + break; + } + } + + if (match >= 0 || currentHistoryLength >= MaxHistoryLen) + { + /// History does not have to be extended (because of a match) or should not be extended (because of the lenght) + if (match < 0) match = currentHistoryLength - 1; + + for (int j = match; j > 0; j--) + { + history[j] = history[j - 1]; + } + history[0] = lastStrValue; + } + else + { + /// History wiil be extended, new item inserted at the beginning + string[] newHistory = new string[currentHistoryLength + 1]; + newHistory[0] = lastStrValue; + for (int j = 1; j <= currentHistoryLength; j++) + { + newHistory[j] = history[j - 1]; + } + history = newHistory; + } + + return true; + } + + /// + /// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array + /// + /// Puchase order ComboBox + public static void PrepareCombo(string[] history, System.Windows.Forms.ComboBox comboBox) + { + if (history != null) + { + for (int i = 0; i < history.Length; i++) + { + comboBox.Items.Add(history[i]); + } + } + + if (comboBox.Items.Count > 0) + { + comboBox.Text = comboBox.Items[0].ToString(); + } + } + } + + + public enum Mode + { + TbfLabelPrinter, + Standalone, + WithDatabase, + } +} diff --git a/LabelPrinting/MainWnd.Designer.cs b/LabelPrinting/MainWnd.Designer.cs new file mode 100644 index 000000000..38dc20b4d --- /dev/null +++ b/LabelPrinting/MainWnd.Designer.cs @@ -0,0 +1,197 @@ +namespace LabelPrinting +{ + partial class MainWnd + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.snTrailTextBox = new System.Windows.Forms.TextBox(); + this.countTextBox = new System.Windows.Forms.TextBox(); + this.snTrailLabel = new System.Windows.Forms.Label(); + this.countLabel = new System.Windows.Forms.Label(); + this.sapNumberLabel = new System.Windows.Forms.Label(); + this.separatorLabel = new System.Windows.Forms.Label(); + this.startButton = new System.Windows.Forms.Button(); + this.sapNumberComboBox = new System.Windows.Forms.ComboBox(); + this.separatorComboBox = new System.Windows.Forms.ComboBox(); + this.interruptButton = new System.Windows.Forms.Button(); + this.mainMenuStrip = new System.Windows.Forms.MenuStrip(); + this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mainMenuStrip.SuspendLayout(); + this.SuspendLayout(); + // + // snTrailTextBox + // + this.snTrailTextBox.Location = new System.Drawing.Point(230, 97); + this.snTrailTextBox.Name = "snTrailTextBox"; + this.snTrailTextBox.Size = new System.Drawing.Size(121, 20); + this.snTrailTextBox.TabIndex = 8; + // + // countTextBox + // + this.countTextBox.Location = new System.Drawing.Point(230, 123); + this.countTextBox.Name = "countTextBox"; + this.countTextBox.Size = new System.Drawing.Size(72, 20); + this.countTextBox.TabIndex = 1; + // + // snTrailLabel + // + this.snTrailLabel.AutoSize = true; + this.snTrailLabel.Location = new System.Drawing.Point(35, 100); + this.snTrailLabel.Name = "snTrailLabel"; + this.snTrailLabel.Size = new System.Drawing.Size(110, 13); + this.snTrailLabel.TabIndex = 7; + this.snTrailLabel.Text = "First S/N trail (9 digits)"; + // + // countLabel + // + this.countLabel.AutoSize = true; + this.countLabel.Location = new System.Drawing.Point(35, 126); + this.countLabel.Name = "countLabel"; + this.countLabel.Size = new System.Drawing.Size(65, 13); + this.countLabel.TabIndex = 0; + this.countLabel.Text = "S/N-s count"; + // + // sapNumberLabel + // + this.sapNumberLabel.AutoSize = true; + this.sapNumberLabel.Location = new System.Drawing.Point(35, 48); + this.sapNumberLabel.Name = "sapNumberLabel"; + this.sapNumberLabel.Size = new System.Drawing.Size(111, 13); + this.sapNumberLabel.TabIndex = 3; + this.sapNumberLabel.Text = "SAP number ( 8 digits)"; + // + // separatorLabel + // + this.separatorLabel.AutoSize = true; + this.separatorLabel.Location = new System.Drawing.Point(35, 74); + this.separatorLabel.Name = "separatorLabel"; + this.separatorLabel.Size = new System.Drawing.Size(124, 13); + this.separatorLabel.TabIndex = 5; + this.separatorLabel.Text = "Separator ( 3 characters)"; + // + // startButton + // + this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.startButton.Location = new System.Drawing.Point(439, 63); + this.startButton.Name = "startButton"; + this.startButton.Size = new System.Drawing.Size(117, 54); + this.startButton.TabIndex = 2; + this.startButton.Text = "Start printing"; + this.startButton.UseVisualStyleBackColor = true; + this.startButton.Click += new System.EventHandler(this.startButton_Click); + // + // sapNumberComboBox + // + this.sapNumberComboBox.FormattingEnabled = true; + this.sapNumberComboBox.Location = new System.Drawing.Point(230, 45); + this.sapNumberComboBox.Name = "sapNumberComboBox"; + this.sapNumberComboBox.Size = new System.Drawing.Size(121, 21); + this.sapNumberComboBox.TabIndex = 9; + // + // separatorComboBox + // + this.separatorComboBox.FormattingEnabled = true; + this.separatorComboBox.Location = new System.Drawing.Point(230, 71); + this.separatorComboBox.Name = "separatorComboBox"; + this.separatorComboBox.Size = new System.Drawing.Size(72, 21); + this.separatorComboBox.TabIndex = 10; + // + // interruptButton + // + this.interruptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.interruptButton.Enabled = false; + this.interruptButton.Location = new System.Drawing.Point(590, 63); + this.interruptButton.Name = "interruptButton"; + this.interruptButton.Size = new System.Drawing.Size(117, 54); + this.interruptButton.TabIndex = 11; + this.interruptButton.Text = "Interrupt"; + this.interruptButton.UseVisualStyleBackColor = true; + this.interruptButton.Click += new System.EventHandler(this.interruptButton_Click); + // + // mainMenuStrip + // + this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.settingsToolStripMenuItem}); + this.mainMenuStrip.Location = new System.Drawing.Point(0, 0); + this.mainMenuStrip.Name = "mainMenuStrip"; + this.mainMenuStrip.Size = new System.Drawing.Size(742, 24); + this.mainMenuStrip.TabIndex = 12; + this.mainMenuStrip.Text = "mainMenuStrip"; + // + // settingsToolStripMenuItem + // + this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); + this.settingsToolStripMenuItem.Text = "Settings"; + this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click); + // + // MainWnd + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(742, 168); + this.Controls.Add(this.interruptButton); + this.Controls.Add(this.separatorComboBox); + this.Controls.Add(this.sapNumberComboBox); + this.Controls.Add(this.startButton); + this.Controls.Add(this.separatorLabel); + this.Controls.Add(this.sapNumberLabel); + this.Controls.Add(this.countLabel); + this.Controls.Add(this.snTrailLabel); + this.Controls.Add(this.countTextBox); + this.Controls.Add(this.snTrailTextBox); + this.Controls.Add(this.mainMenuStrip); + this.MainMenuStrip = this.mainMenuStrip; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MainWnd"; + this.Text = "S/N Printing"; + this.Load += new System.EventHandler(this.MainWnd_Load); + this.mainMenuStrip.ResumeLayout(false); + this.mainMenuStrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox snTrailTextBox; + private System.Windows.Forms.TextBox countTextBox; + private System.Windows.Forms.Label snTrailLabel; + private System.Windows.Forms.Label countLabel; + private System.Windows.Forms.Label sapNumberLabel; + private System.Windows.Forms.Label separatorLabel; + private System.Windows.Forms.Button startButton; + private System.Windows.Forms.ComboBox sapNumberComboBox; + private System.Windows.Forms.ComboBox separatorComboBox; + private System.Windows.Forms.Button interruptButton; + private System.Windows.Forms.MenuStrip mainMenuStrip; + private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + } +} + diff --git a/LabelPrinting/MainWnd.cs b/LabelPrinting/MainWnd.cs new file mode 100644 index 000000000..27e58d08a --- /dev/null +++ b/LabelPrinting/MainWnd.cs @@ -0,0 +1,480 @@ +/// +/// Copyright (c) 2021-2023 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using log4net; +using DataMatrix4Net; +using SharedDatabase.Entities; +using LabelPrinting.Resources; +using TBF.Rig.Output.Printers.Label; +using NHibernate; +using Common; +using Results.Entities; + +namespace LabelPrinting +{ + public partial class MainWnd : Form + { + private static readonly ILog log = LogManager.GetLogger(typeof(MainWnd)); + + private readonly Factory factory; + private readonly Printer printer; + + string programNameAndVer; + string prefix; /// S/N prefix after parsing/verification by the UI + string separator; /// Separator after parsing/verification by the UI + int currentSNTrail; /// Current S/N trai (1st S/N trail after parsing/verification by the UI) + int totalCount; /// Total S/N count after parsing/verification by the UI + int remainingCount; /// Remaining S/N-s count + IList orderInfos; /// null in Standalone mode + Timer timer; + bool interrupt; + + public MainWnd() + { + InitializeComponent(); + Text = programNameAndVer = string.Format("{0} v.{1}", Program.ProgramName, Program.Version); ; + factory = new Factory(); + } + + public MainWnd(IList orderInfos) + : this() + { + this.orderInfos = orderInfos; + + if (Program.LocalSettings.Mode == Mode.TbfLabelPrinter) + { + try + { + var cmpntEntity = Config.Entities.Component.CreateFromCfg("Printer", factory.ClassName, string.Empty, 1, + DebugMode.Normal, LogLevel.Off, + Program.LocalSettings.LabelPrinterCfg); + printer = factory.GetComponent(factory.CmpntCfgFromCmpntEntity(cmpntEntity), null) as Printer; + printer.Initialize(); + } + catch (Exception) + { + MessageBox.Show("Cannot create or initialize a printer", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); + } + } + + try + { + string culture = Program.LocalSettings.Language.Replace('_', '-'); + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); + } + catch (Exception) + { + MessageBox.Show("Selected language is not supported.\nUsing English.", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); + System.Threading.Thread.CurrentThread.CurrentUICulture = + new System.Globalization.CultureInfo("en"); + } + + timer = new Timer(); + timer.Interval = Program.LocalSettings.DelayBetweenLabels; /// [ms] default = 1000 + timer.Tick += new EventHandler(timer_Tick); + } + + void Localize() + { + startButton.Text = Strings.Start_printing; + interruptButton.Text = Strings.Interrupt; + settingsToolStripMenuItem.Text = Strings.Settings; + + if (Program.LocalSettings.Mode == Mode.TbfLabelPrinter) + { + sapNumberLabel.Text = Strings.Order; + separatorLabel.Text = string.Empty; + separatorComboBox.Visible = false; + snTrailLabel.Text = Strings.Serial_number; + } + else + { + sapNumberLabel.Text = Strings.SAP_number_8_digits; + separatorLabel.Text = Strings.Separator_3_characters; + snTrailLabel.Text = Strings.First_SN_trail_9_digits; + } + + countLabel.Text = Strings.Labels_count; + } + + private void MainWnd_Load(object sender, EventArgs e) + { + Localize(); + + LocalSettings.PrepareCombo(Program.LocalSettings.SapNumberHistory, sapNumberComboBox); + LocalSettings.PrepareCombo(Program.LocalSettings.SeparatorHistory, separatorComboBox); + + if (Program.LocalSettings.Mode == Mode.TbfLabelPrinter) + { + snTrailTextBox.Text = string.Empty; + countTextBox.Text = Math.Max(Program.LocalSettings.RemainingSNsCount, 1).ToString(); + + snTrailLabel.Top -= 26; + snTrailTextBox.Top -= 26; + countLabel.Top -= 26; + countTextBox.Top -= 26; + + this.ActiveControl = snTrailTextBox; + } + else if (Program.LocalSettings.Mode == Mode.Standalone) + { + snTrailTextBox.Text = Program.LocalSettings.CurrentSNTrail.ToString("D9"); + countTextBox.Text = Math.Max(Program.LocalSettings.RemainingSNsCount, 1).ToString(); + } + else + { + if (orderInfos == null) throw new Exception("Missing OrderInfo-s from production tracing database"); + + currentSNTrail = 0; + foreach (var oi in orderInfos) + { + if (oi.BaseNr1 + oi.PiecesCount + Cnst.ExtraPieces > currentSNTrail) + { + currentSNTrail = oi.BaseNr1 + oi.PiecesCount + Cnst.ExtraPieces; + } + } + + snTrailTextBox.Text = currentSNTrail.ToString("D9"); + snTrailTextBox.Enabled = false; + } + } + + /// + /// Start printing labels + /// + private void startButton_Click(object sender, EventArgs e) + { + if (!int.TryParse(countTextBox.Text, out totalCount) || totalCount <= 0) + { + MessageBox.Show(Strings.Invalid_SNs_count); + return; + } + remainingCount = totalCount; + + if (Program.LocalSettings.Mode == Mode.TbfLabelPrinter) + { + var wm = new Results.Entities.WaterMeter(); + wm.PurchaseOrder = string.IsNullOrEmpty(sapNumberComboBox.Text) ? string.Empty : sapNumberComboBox.Text; + wm.SerialNr = string.IsNullOrEmpty(snTrailTextBox.Text) ? string.Empty : snTrailTextBox.Text; + + LocalSettings.UpdateHistory(sapNumberComboBox.Text, ref Program.LocalSettings.SapNumberHistory); + //Program.LocalSettings.CurrentSNTrail = snTrailTextBox.Text; + Program.LocalSettings.RemainingSNsCount = remainingCount; + Program.LocalSettings.Save(); + + startButton.Enabled = false; + interruptButton.Enabled = true; + interrupt = false; + + printer.PrintResults(wm, "document name"); + + remainingCount--; + IncrementSN(snTrailTextBox); + } + else + { + /// Program.LocalSettings.Mode == Mode.Standalone || Program.LocalSettings.Mode == Mode.WithDatabase + + int sapNumber; + if (sapNumberComboBox.Text.Length != 8 || !int.TryParse(sapNumberComboBox.Text, out sapNumber) || sapNumber <= 0 || sapNumber > 99999999) + { + MessageBox.Show(Strings.Invalid_SAP_number); + return; + } + + if (separatorComboBox.Text.Length != 3) + { + MessageBox.Show(Strings.Invalid_separator); + return; + } + + if (snTrailTextBox.Text.Length != 9 || !int.TryParse(snTrailTextBox.Text, out currentSNTrail)) + { + MessageBox.Show(Strings.Invalid_first_SN_trail); + return; + } + else if (Program.LocalSettings.Mode == Mode.Standalone && currentSNTrail < Program.LocalSettings.CurrentSNTrail) + { + MessageBox.Show(string.Format("{0}, {1} {2:D9}", Strings.Invalid_first_SN_trail, Strings.min, Program.LocalSettings.CurrentSNTrail)); + return; + } + + if (Program.LocalSettings.Mode == Mode.Standalone && currentSNTrail > Program.LocalSettings.CurrentSNTrail) + { + if (MessageBox.Show(string.Format("{0} {1:D9}{2}{3}{4}", + Strings.You_are_skipping, + Program.LocalSettings.CurrentSNTrail, + (currentSNTrail == Program.LocalSettings.CurrentSNTrail + 1) ? "" : string.Format(" ... {0:D9}", currentSNTrail - 1), + Environment.NewLine, + Strings.Are_you_sure), + string.Empty, + MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + } + + if (Program.LocalSettings.Mode == Mode.WithDatabase) + { + SaveNewOrderInfo(ref currentSNTrail, totalCount); + } + + prefix = sapNumberComboBox.Text; + separator = separatorComboBox.Text; + + sapNumberComboBox.Enabled = false; + separatorComboBox.Enabled = false; + snTrailTextBox.Enabled = false; + countTextBox.Enabled = false; + + LocalSettings.UpdateHistory(sapNumberComboBox.Text, ref Program.LocalSettings.SapNumberHistory); + LocalSettings.UpdateHistory(separatorComboBox.Text, ref Program.LocalSettings.SeparatorHistory); + + Program.LocalSettings.CurrentSNTrail = currentSNTrail; + Program.LocalSettings.RemainingSNsCount = remainingCount; + Program.LocalSettings.Save(); + + startButton.Enabled = false; + interruptButton.Enabled = true; + interrupt = false; + + PrintOneLabel(); + } + + if (remainingCount > 0) + { + timer.Start(); + } + else + { + Text = string.Format("{0} ... {1}", programNameAndVer, Strings.completed); + MessageBox.Show(string.Format(Strings.x_labels_printed, totalCount)); + SaveSettingsUpdateAndEnableUI(); + } + } + + /// + /// Save a record tp OrderInfo table that coresponds to printed labels + /// + /// Start S/N trail number + /// Printed labels count + /// true when successful + bool SaveNewOrderInfo(ref int currentSNTrail, int totalCount) + { + ISession session = SharedDatabase.TracingDB.CreateSession(Program.LocalSettings.TracingDBConnString); + ITransaction transaction = session.BeginTransaction(); + OrderInfo oi = new OrderInfo(); + bool successfullySaved = false; + try + { + var orders = session.QueryOver().List(); + + /// Determine current S/N trail once again + int snTrail = 0; + foreach (var o in orders) + { + if (o.BaseNr1 + o.PiecesCount + Cnst.ExtraPieces > snTrail) + { + snTrail = o.BaseNr1 + o.PiecesCount + Cnst.ExtraPieces; + } + } + + /// Compare current S/N trail with the newly obtained one, update if necessary + if (snTrail > currentSNTrail) currentSNTrail = snTrail; + + oi.POName = "0000000"; + oi.PiecesCount = totalCount; + oi.TestProcedure = string.Empty; + oi.BaseNr1 = currentSNTrail; + oi.BaseNr2 = 0; + oi.BaseNr3 = 0; + oi.BaseNr4 = 0; + oi.BaseNr5 = 0; + oi.Remark = "Manual S/N printing"; + oi.Workflow = null; + orders.Add(oi); + session.SaveOrUpdate(oi); + transaction.Commit(); + successfullySaved = true; + } + catch (Exception exc) + { + log.ErrorFormat("MySQL database transaction rolled back, data not comitted: {0}", exc.Message); + transaction.Rollback(); + } + + return successfullySaved; + } + + + void timer_Tick(object sender, EventArgs args) + { + timer.Stop(); + + if (interrupt) + { + Text = string.Format("{0} ... {1}", programNameAndVer, Strings.interrupted); + MessageBox.Show(string.Format(Strings.x_labels_printed, totalCount - remainingCount)); + SaveSettingsUpdateAndEnableUI(); + } + else if (Program.LocalSettings.Mode == Mode.TbfLabelPrinter) + { + var wm = new Results.Entities.WaterMeter(); + wm.PurchaseOrder = string.IsNullOrEmpty(sapNumberComboBox.Text) ? string.Empty : sapNumberComboBox.Text; + wm.SerialNr = string.IsNullOrEmpty(snTrailTextBox.Text) ? string.Empty : snTrailTextBox.Text; + + printer.PrintResults(wm, "document name"); + + remainingCount--; + IncrementSN(snTrailTextBox); + + if (remainingCount > 0) + { + timer.Enabled = true; + } + else + { + Text = string.Format("{0} ... {1}", programNameAndVer, Strings.completed); + MessageBox.Show(string.Format(Strings.x_labels_printed, totalCount)); + SaveSettingsUpdateAndEnableUI(); + } + } + else + { + /// Program.LocalSettings.Mode == Mode.Standalone || Program.LocalSettings.Mode == Mode.WithDatabase + + PrintOneLabel(); + + if (remainingCount > 0) + { + timer.Enabled = true; + } + else + { + Text = string.Format("{0} ... {1}", programNameAndVer, Strings.completed); + MessageBox.Show(string.Format(Strings.x_labels_printed, totalCount)); + SaveSettingsUpdateAndEnableUI(); + } + } + } + + char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; + /// + void IncrementSN(TextBox tb) + { + if (tb != null) + { + string currentSN = tb.Text; + + int currentSnNr; + int startIx = currentSN.IndexOfAny(digits); + if (startIx >= 0) + { + int lastDigitPosPlus1 = startIx + 1; + var listOfDigits = new List(digits); + while (lastDigitPosPlus1 < currentSN.Length && listOfDigits.Contains(currentSN[lastDigitPosPlus1])) + { + lastDigitPosPlus1++; + } + int digitsCount = lastDigitPosPlus1 - startIx; + + if (int.TryParse(currentSN.Substring(startIx, digitsCount), out currentSnNr) && currentSnNr >= 0) + { + currentSnNr++; + string newSN = currentSnNr.ToString(); + int len = newSN.Length; + if (len <= digitsCount) + { + tb.Text = currentSN.Substring(0, startIx + digitsCount - len) + newSN + currentSN.Substring(startIx + digitsCount); + } + else + { + tb.Text = currentSN.Substring(0, startIx) + newSN + currentSN.Substring(startIx + digitsCount); ; + } + } + } + + } + } + + void PrintOneLabel() + { + if (remainingCount > 0) + { + string code = string.Format("{0}{1}{2:D9}", prefix, separator, currentSNTrail); + Text = string.Format("{0} ... {1} ... {2} / {3}", programNameAndVer, code, totalCount - remainingCount + 1, totalCount); + DataMatrix matrix = new DataMatrix(code, SymbolSize.SquareAuto); + new Printers.DataMatrixAndTextPrintDoc(matrix.Matrix, code.Replace(separator.Substring(0, 2), "\n")).Print(); + currentSNTrail++; + remainingCount--; + } + } + + void SaveSettingsUpdateAndEnableUI() + { + if (Program.LocalSettings.Mode != Mode.TbfLabelPrinter) snTrailTextBox.Text = currentSNTrail.ToString("D9"); + countTextBox.Text = remainingCount.ToString(); + + Program.LocalSettings.CurrentSNTrail = currentSNTrail; + Program.LocalSettings.RemainingSNsCount = remainingCount; + Program.LocalSettings.Save(); + + sapNumberComboBox.Enabled = true; + separatorComboBox.Enabled = true; + snTrailTextBox.Enabled = (Program.LocalSettings.Mode == Mode.TbfLabelPrinter || Program.LocalSettings.Mode == Mode.Standalone); + countTextBox.Enabled = true; + + startButton.Enabled = true; + interruptButton.Enabled = false; + } + + private void interruptButton_Click(object sender, EventArgs e) + { + interrupt = true; + } + + private void settingsToolStripMenuItem_Click(object sender, EventArgs e) + { + /// Connect to the database of users and log in a user + try + { + SharedDatabase.UsersDB.ConnectionString = Program.LocalSettings.UsersDBConnString; + SharedDatabase.UsersDB.DbType = Common.DBType.MySql; + + DialogResult dr = new SharedDatabase.Forms.LoginDlg().ShowDialog(); + if (dr != DialogResult.OK) return; + } + catch (Exception exc) + { + string msg = string.Format("Failed to connect to the database of users:{0}{1}", Environment.NewLine, exc.Message); + log.Error(msg); + MessageBox.Show(msg); + return; + } + + /// Modify program settings + try + { + DialogResult dr = new SettingsDlg(Program.LocalSettings).ShowDialog(); + if (dr == DialogResult.OK) + { + Program.LocalSettings.Save(); + MessageBox.Show(Strings.Program_restart_is_required); + Close(); + } + } + catch (Exception exc) + { + string msg = string.Format("Error occurred, settings were not modified:{0}{1}", Environment.NewLine, exc.Message); + log.Error(msg); + MessageBox.Show(msg); + } + } + } +} diff --git a/LabelPrinting/MainWnd.resx b/LabelPrinting/MainWnd.resx new file mode 100644 index 000000000..f80b0f339 --- /dev/null +++ b/LabelPrinting/MainWnd.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/LabelPrinting/Printers/DataMatrixAndTextPrintDoc.cs b/LabelPrinting/Printers/DataMatrixAndTextPrintDoc.cs new file mode 100644 index 000000000..c95e55f5e --- /dev/null +++ b/LabelPrinting/Printers/DataMatrixAndTextPrintDoc.cs @@ -0,0 +1,120 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Printing; +using Gma.QrCodeNet.Encoding; +using DataMatrix4Net; + +namespace LabelPrinting.Printers +{ + public class DataMatrixAndTextPrintDoc : PrintDocument + { + const float mm = 1 / 0.254F; /// 1 mm expressed in 1/100 inch + + int printWidth; + int printHeight; + int leftMargin; + int topMargin; + + + BitMatrix bitMatrix; + string text; + + + /// + /// Constructor + /// + /// Bitmap to be printed + /// Label width + /// Label height + /// true = landscape + public DataMatrixAndTextPrintDoc(BitMatrix bitMatrix, string text, bool landscape = false) + { + this.bitMatrix = bitMatrix; + this.text = text; + + DefaultPageSettings.Landscape = landscape; + + /// Set print area size and margins (in dots using 80 dpi) + if (landscape) + { + printWidth = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom; + printHeight = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right; + leftMargin = base.DefaultPageSettings.Margins.Top; /// X + topMargin = base.DefaultPageSettings.Margins.Left; /// Y + } + else + { + printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom; + printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right; + leftMargin = base.DefaultPageSettings.Margins.Left; /// X + topMargin = base.DefaultPageSettings.Margins.Top; /// Y + } + } + + protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) + { + base.OnBeginPrint(e); /// Run base code + } + + protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) + { + base.OnPrintPage(e); /// Run base code + DrawLabel(e.Graphics, bitMatrix, text); + e.HasMorePages = false; + } + + public static void DrawLabel(Graphics g, BitMatrix bitMatrix, string text) + { + string[] lines = text.Split(new char[] { '\n' }); + + /// Assuming 100 dpi (printer), drawing size: 2 inch (width) x 1 inch (height) + const float W = 18 * mm; + const float H = 10 * mm; + + const float L1 = 7.0f * mm; + const float L2 = 7.0f * mm; + const float T1 = 3.5f * mm; + const float T2 = 5.5f * mm; + + const float QRL = 1.0f * mm; + const float QRT = 2.5f * mm; + const float QrSize = 5.5f * mm; + + string fontFamily = "Arial"; + Font font = new Font(fontFamily, 4.5f, FontStyle.Bold); + + g.SmoothingMode = SmoothingMode.AntiAlias; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + g.Clear(Color.White); + + if (lines.Length > 0) + { + g.DrawString(lines[0], font, Brushes.Black, new RectangleF(L1, T1, W - L1, H - T1)); + } + + if (lines.Length > 1) + { + g.DrawString(lines[1], font, Brushes.Black, new RectangleF(L2, T2, W - L2, H - T2)); + } + + g.Flush(); + + float QrPixSize = QrSize / bitMatrix.Width; + for (int i = 0; i < bitMatrix.Height; i++) + { + for (int j = 0; j < bitMatrix.Width; j++) + { + if (bitMatrix[j, i]) + { + g.FillRectangle(Brushes.Black, new RectangleF(QRL + QrPixSize * j, QRT + QrPixSize * i, QrPixSize, QrPixSize)); + } + } + } + } + } +} diff --git a/LabelPrinting/Program.cs b/LabelPrinting/Program.cs new file mode 100644 index 000000000..1020178c9 --- /dev/null +++ b/LabelPrinting/Program.cs @@ -0,0 +1,251 @@ +/// +/// Copyright (c) 2021-2023 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Windows.Forms; +using log4net; +using NHibernate; +using Common; +using SharedDatabase; +using SharedDatabase.Entities; +using LabelPrinting.Resources; + +namespace LabelPrinting +{ + static class Program + { + /// Constants + public static GID[] SettingsAccessLevel = new GID[] { GID.TraceabilityManagement }; /// Group membership to access settings + public const string ProgramName = "LabelPrinting"; + public const string ConfigFName = "config.xml"; + public const string BackupConfigFName = "config.backup.xml"; + public const string Log4NetConfigFName = "log4netConfig.xml"; + + /// Program information + public static readonly string Version; /// version string + public static readonly DateTime BuildDateTime; /// date and time of program build + public static readonly string ExeDirectory; + public static readonly string ConfigDirectory; + public static readonly string LogDirectory; + public static readonly string LocalSettingsFileName; + public static readonly string LocalSettingsBackupName; + + /// Local settings + public static LocalSettings LocalSettings; + + /// log4net + static ILog log; + + + static Program() + { + /// Program version string + Assembly thisAssembly = Assembly.GetExecutingAssembly(); + Version ver = thisAssembly.GetName().Version; + Version = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); + BuildDateTime = new FileInfo(thisAssembly.Location).LastWriteTime; + + /// Local program configuration directory including the trailing backslash + ExeDirectory = Path.GetDirectoryName(thisAssembly.Location); + ConfigDirectory = Path.Combine(ExeDirectory, "..\\Cfg"); + LogDirectory = Path.Combine(ExeDirectory, "..", "Logs"); + LocalSettingsFileName = Path.Combine(ConfigDirectory, ConfigFName); + LocalSettingsBackupName = Path.Combine(ConfigDirectory, BackupConfigFName); + } + + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + /// + /// Check if another instance is running + /// + Assembly thisAssembly = Assembly.GetExecutingAssembly(); + string processName = Path.GetFileNameWithoutExtension(thisAssembly.Location); + if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1) + { + MessageBox.Show(string.Format("{0}{1}{2}", string.Format(Strings.Program_0_is_running_already, ProgramName), + Environment.NewLine, + Strings.Close_it_please), + Strings.Error, + MessageBoxButtons.OK, + MessageBoxIcon.Asterisk); + return; + } + + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); + + bool configDirectoryCreated = false; + if (!Directory.Exists(ConfigDirectory) || new DirectoryInfo(ConfigDirectory).GetFileSystemInfos().Length == 0) + { + MessageBox.Show(string.Format("{0}{1}{2}", Strings.Program_is_running_for_the_1st_time_on_this_PC, + Environment.NewLine, + Strings.Default_settings_are_used), + Strings.Warning, + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation); + /// + /// Create a new config subdirectory + /// + Directory.CreateDirectory(ConfigDirectory); + configDirectoryCreated = true; + + LocalSettings = new LocalSettings(true); + LocalSettings.Save(); + + if (File.Exists(Path.Combine(ExeDirectory, "SampleConfig", Log4NetConfigFName))) + { + File.Copy(Path.Combine(ExeDirectory, "SampleConfig", Log4NetConfigFName), + Path.Combine(ConfigDirectory, Log4NetConfigFName)); + } + + File.SetAttributes(Path.Combine(ConfigDirectory, Log4NetConfigFName), FileAttributes.Normal); + } + + /// + /// Configue and start logging + /// + log4net.Config.XmlConfigurator.Configure(new FileInfo(Path.Combine(ConfigDirectory, Log4NetConfigFName))); + log = LogManager.GetLogger(typeof(Program)); + log.Fatal("--------------------------------------------------------------------------------"); + log.FatalFormat("{0} ver.{1}", ProgramName, Version); + log.FatalFormat("Executable directory is {0}", ExeDirectory); + if (configDirectoryCreated) + { + log.Fatal("A new config directory and configuration files created !"); + } + + /// + /// Load the local settings + /// + LocalSettings = LocalSettings.Load(LocalSettingsFileName); + if (LocalSettings == null) + { + /// Loading local seetings from regular config file failed. Use the backup + LocalSettings = LocalSettings.Load(LocalSettingsBackupName); + if (LocalSettings == null) + { + log.FatalFormat("Local settings: Could not load file {0}, nor {1}.", ConfigFName, BackupConfigFName); + log.Fatal("Application terminated."); + MessageBox.Show(string.Format("Could not load file {0}, nor {1}.", ConfigFName, BackupConfigFName), "Fatal error"); + return; /// Fatal error + } + else + { + LocalSettings.Save(); /// Save the settings to overwrite the wrong file + log.FatalFormat("Local settings: Could not load file {0}, successfully loaded {1}", ConfigFName, BackupConfigFName); + } + } + else + { + /// Loading local seetings from the regular config file was successful. Update the backup + File.Copy(LocalSettingsFileName, LocalSettingsBackupName, true); + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + /// + /// User login + /// + if (LocalSettings.IsUserLoginRequired && !string.IsNullOrEmpty(LocalSettings.UsersDBConnString)) + { + try + { + UsersDB.ConnectionString = LocalSettings.UsersDBConnString; + UsersDB.DbType = DBType.MySql; + + DialogResult dr = new SharedDatabase.Forms.LoginDlg().ShowDialog(); + if (dr != DialogResult.OK) return; + } + catch (Exception exc) + { + log.ErrorFormat("Failed to connect to database of users: {0}", exc.Message); + } + } + + IList orderInfos = null; + while (LocalSettings.Mode == Mode.WithDatabase) + { + try + { + ISession session = TracingDB.CreateSession(LocalSettings.TracingDBConnString); + orderInfos = session.QueryOver().List(); + break; + } + catch (Exception exc) + { + log.FatalFormat("Failed to connect to production tracing database: {0}", exc.Message); + if (exc.InnerException != null) + { + log.FatalFormat("InnerException: {0}", exc.InnerException.Message); + } + + MessageBox.Show(string.Format("Failed to connect to production tracing database:{0}{1}", Environment.NewLine, exc.Message)); + + if (new SettingsDlg(LocalSettings).ShowDialog() == DialogResult.OK) + { + LocalSettings.Save(); + } + else + { + return; + } + } + } + + try + { + MainWnd dlg = new MainWnd(orderInfos); + Application.Run(dlg); + } + catch (Exception e) + { + LogException(log, "Exception in Application.Run(MainWnd)", e); + + MessageBox.Show("Program crashed:" + + Environment.NewLine + Environment.NewLine + e.Message + + ((e.InnerException == null) ? string.Empty : (Environment.NewLine + e.InnerException.Message)) + + Environment.NewLine + e.StackTrace, + "Fatal error", + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation); + } + } + + + static void MyHandler(object sender, UnhandledExceptionEventArgs args) + { + Exception e = args.ExceptionObject as Exception; + if (e == null) return; + + LogException(log, "Unhandled exception", e); + + MessageBox.Show("Program crashed:" + + Environment.NewLine + Environment.NewLine + e.Message + + ((e.InnerException == null) ? string.Empty : (Environment.NewLine + e.InnerException.Message)) + + Environment.NewLine + e.StackTrace, + "Fatal error", + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation); + } + + static void LogException(ILog log, string description, Exception e) + { + log.FatalFormat("---------------( {0} )---------------", description); + log.FatalFormat("Message : {0}", e.Message); + if (e.InnerException != null) + { + log.FatalFormat("InnerMessage : {0}", e.InnerException.Message); + } + log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace); + log.Fatal("--------------------------------------"); + } + } +} diff --git a/LabelPrinting/Properties/AssemblyInfo.cs b/LabelPrinting/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9e70f7b48 --- /dev/null +++ b/LabelPrinting/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("LabelPrinting")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LabelPrinting")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("270db60d-5938-40be-b15c-e2bc3c7ddb86")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.6.0")] +[assembly: AssemblyFileVersion("1.0.6.0")] diff --git a/LabelPrinting/Properties/Resources.Designer.cs b/LabelPrinting/Properties/Resources.Designer.cs new file mode 100644 index 000000000..741cb5e67 --- /dev/null +++ b/LabelPrinting/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LabelPrinting.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SNPrinting.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/LabelPrinting/Properties/Resources.resx b/LabelPrinting/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/LabelPrinting/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LabelPrinting/Properties/Settings.Designer.cs b/LabelPrinting/Properties/Settings.Designer.cs new file mode 100644 index 000000000..5c61b50dc --- /dev/null +++ b/LabelPrinting/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LabelPrinting.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/LabelPrinting/Properties/Settings.settings b/LabelPrinting/Properties/Settings.settings new file mode 100644 index 000000000..39645652a --- /dev/null +++ b/LabelPrinting/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/LabelPrinting/Resources/Strings.Designer.cs b/LabelPrinting/Resources/Strings.Designer.cs new file mode 100644 index 000000000..3ed69c192 --- /dev/null +++ b/LabelPrinting/Resources/Strings.Designer.cs @@ -0,0 +1,414 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LabelPrinting.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Strings { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Strings() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LabelPrinting.Resources.Strings", typeof(Strings).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Are you sure?. + /// + internal static string Are_you_sure { + get { + return ResourceManager.GetString("Are_you_sure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + internal static string Cancel { + get { + return ResourceManager.GetString("Cancel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close it please using 'Task manager'.. + /// + internal static string Close_it_please { + get { + return ResourceManager.GetString("Close_it_please", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to completed. + /// + internal static string completed { + get { + return ResourceManager.GetString("completed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Connection string for production tracing database. + /// + internal static string Connection_string_tracing_DB { + get { + return ResourceManager.GetString("Connection_string_tracing_DB", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Connection string for database of users. + /// + internal static string Connection_string_users_DB { + get { + return ResourceManager.GetString("Connection_string_users_DB", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Database. + /// + internal static string Database { + get { + return ResourceManager.GetString("Database", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Default settings are used.. + /// + internal static string Default_settings_are_used { + get { + return ResourceManager.GetString("Default_settings_are_used", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delay between labels. + /// + internal static string Delay_between_labes { + get { + return ResourceManager.GetString("Delay_between_labes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Error. + /// + internal static string Error { + get { + return ResourceManager.GetString("Error", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to First S/N trail (9 digits). + /// + internal static string First_SN_trail_9_digits { + get { + return ResourceManager.GetString("First_SN_trail_9_digits", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Interrupt. + /// + internal static string Interrupt { + get { + return ResourceManager.GetString("Interrupt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to interrupted. + /// + internal static string interrupted { + get { + return ResourceManager.GetString("interrupted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid. + /// + internal static string Invalid { + get { + return ResourceManager.GetString("Invalid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid first S/N trail. + /// + internal static string Invalid_first_SN_trail { + get { + return ResourceManager.GetString("Invalid_first_SN_trail", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid language. + /// + internal static string Invalid_language { + get { + return ResourceManager.GetString("Invalid_language", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid SAP number. + /// + internal static string Invalid_SAP_number { + get { + return ResourceManager.GetString("Invalid_SAP_number", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid separator. + /// + internal static string Invalid_separator { + get { + return ResourceManager.GetString("Invalid_separator", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid labels count. + /// + internal static string Invalid_SNs_count { + get { + return ResourceManager.GetString("Invalid_SNs_count", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Labels count. + /// + internal static string Labels_count { + get { + return ResourceManager.GetString("Labels_count", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Language, Sprache, Jazyk. + /// + internal static string Language_etc { + get { + return ResourceManager.GetString("Language_etc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to min.. + /// + internal static string min { + get { + return ResourceManager.GetString("min", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mode. + /// + internal static string Mode { + get { + return ResourceManager.GetString("Mode", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Order. + /// + internal static string Order { + get { + return ResourceManager.GetString("Order", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Program '{0}' is running already.. + /// + internal static string Program_0_is_running_already { + get { + return ResourceManager.GetString("Program_0_is_running_already", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Program is running for the 1st time on this PC.. + /// + internal static string Program_is_running_for_the_1st_time_on_this_PC { + get { + return ResourceManager.GetString("Program_is_running_for_the_1st_time_on_this_PC", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Program restart is required. + /// + internal static string Program_restart_is_required { + get { + return ResourceManager.GetString("Program_restart_is_required", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to SAP number (8 digits). + /// + internal static string SAP_number_8_digits { + get { + return ResourceManager.GetString("SAP_number_8_digits", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Save. + /// + internal static string Save { + get { + return ResourceManager.GetString("Save", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Separator (3 characters). + /// + internal static string Separator_3_characters { + get { + return ResourceManager.GetString("Separator_3_characters", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Serial number. + /// + internal static string Serial_number { + get { + return ResourceManager.GetString("Serial_number", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settings. + /// + internal static string Settings { + get { + return ResourceManager.GetString("Settings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Standalone. + /// + internal static string Standalone { + get { + return ResourceManager.GetString("Standalone", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Start printing. + /// + internal static string Start_printing { + get { + return ResourceManager.GetString("Start_printing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to User login is required. + /// + internal static string User_login_is_required { + get { + return ResourceManager.GetString("User_login_is_required", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Warning. + /// + internal static string Warning { + get { + return ResourceManager.GetString("Warning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to With a database. + /// + internal static string With_database { + get { + return ResourceManager.GetString("With_database", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} labels printed. + /// + internal static string x_labels_printed { + get { + return ResourceManager.GetString("x_labels_printed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You are skipping. + /// + internal static string You_are_skipping { + get { + return ResourceManager.GetString("You_are_skipping", resourceCulture); + } + } + } +} diff --git a/LabelPrinting/Resources/Strings.cs.resx b/LabelPrinting/Resources/Strings.cs.resx new file mode 100644 index 000000000..a91cde2f3 --- /dev/null +++ b/LabelPrinting/Resources/Strings.cs.resx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Zrušit + + + Zavřete ho prosím 'Správcem úloh' (Task manager). + + + dokončeno + + + Konfigurace databáze sledování výroby + + + Konfigurace databáze uživatelů + + + Databáze + + + Použijí sa výchozí nastavení + + + Zpoždění mezi tiskemm štítků + + + Chyba + + + Prerušit + + + prerušeno + + + Neplatný konec sériového čísla + + + Neplatné číslo součástky (SAP číslo) + + + Neplatný oddělovač + + + Neplatný počet štítků + + + Language, Sprache, Jazyk + + + min. + + + Režim činnosti + + + Program '{0}' už běží. + + + Program byl spuštěn na tomto počítači poprvé. + + + Uložit + + + Nastavení + + + Samostatný + + + Spustit tisk + + + Vyžaduje se prihlášení užívatele + + + Upozornení + + + S databází + + + Vynechávate + + + První konec sériového čísla (9 číslic) + + + SAP číslo (8 číslic) + + + Oddělovač (3 znaky) + + + Počet štítků + + + Je potřebný restart programu + + + Bylo vytištěných {0} štítků + + + Neplatný + + + Neplatný jazyk + + + Objednávka + + + Sériové číslo + + \ No newline at end of file diff --git a/LabelPrinting/Resources/Strings.resx b/LabelPrinting/Resources/Strings.resx new file mode 100644 index 000000000..812fc330f --- /dev/null +++ b/LabelPrinting/Resources/Strings.resx @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Close it please using 'Task manager'. + + + Default settings are used. + + + Error + + + Interrupt + + + Invalid first S/N trail + + + Invalid SAP number + + + Invalid separator + + + Invalid labels count + + + Program '{0}' is running already. + + + Program is running for the 1st time on this PC. + + + Start printing + + + Warning + + + completed + + + interrupted + + + Are you sure? + + + min. + + + You are skipping + + + Cancel + + + Connection string for production tracing database + + + Connection string for database of users + + + Database + + + Delay between labels + + + Language, Sprache, Jazyk + + + Mode + + + Save + + + Settings + + + Standalone + + + User login is required + + + With a database + + + First S/N trail (9 digits) + + + SAP number (8 digits) + + + Separator (3 characters) + + + Labels count + + + Program restart is required + + + {0} labels printed + + + Invalid + + + Invalid language + + + Order + + + Serial number + + \ No newline at end of file diff --git a/LabelPrinting/Resources/Strings.sk.resx b/LabelPrinting/Resources/Strings.sk.resx new file mode 100644 index 000000000..929937087 --- /dev/null +++ b/LabelPrinting/Resources/Strings.sk.resx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Zrušiť + + + Zavrite ho prosím 'Správcom úloh' (Task manager). + + + dokončené + + + Konfigurácia databáze sledovania výroby + + + Konfigurácia databáze užívateľov + + + Databáza + + + Použijú sa základné nastavenia + + + Oneskorenie medzi tlačením štítkov + + + Chyba + + + Prerušiť + + + prerušené + + + Neplatný chvost sériového čísla + + + Neplatné číslo súčiastky (SAP číslo) + + + Neplatný oddelovač + + + Neplatný počet štítkov + + + Language, Sprache, Jazyk + + + min. + + + Režim činnosti + + + Program '{0}' už beží. + + + Program bol spustený na tomto počítači prvý krát. + + + Uložiť + + + Nastavenia + + + Samostatný + + + Začať tlačiť + + + Vyžaduje sa prihlásenie používateľa + + + Upozornenie + + + S databázou + + + Vynechávate + + + Prvý chvost sériového čísla (9 číslic) + + + SAP číslo (8 číslic) + + + Oddeľovač (3 znaky) + + + Počet štítkov + + + Je potrebný reštart programu + + + Bolo vytlačených {0} štítkov + + + Neplatný + + + Neplatný jazyk + + + Objednávka + + + Sériové číslo + + \ No newline at end of file diff --git a/LabelPrinting/SampleConfig/log4netConfig.xml b/LabelPrinting/SampleConfig/log4netConfig.xml new file mode 100644 index 000000000..417552fef --- /dev/null +++ b/LabelPrinting/SampleConfig/log4netConfig.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LabelPrinting/SettingsDlg.Designer.cs b/LabelPrinting/SettingsDlg.Designer.cs new file mode 100644 index 000000000..f7dcab858 --- /dev/null +++ b/LabelPrinting/SettingsDlg.Designer.cs @@ -0,0 +1,283 @@ +namespace LabelPrinting +{ + partial class SettingsDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.modeGroupBox = new System.Windows.Forms.GroupBox(); + this.tbfLabelPrinterRadioButton = new System.Windows.Forms.RadioButton(); + this.standaloneRadioButton = new System.Windows.Forms.RadioButton(); + this.withDBRadioButton = new System.Windows.Forms.RadioButton(); + this.commonGroupBox = new System.Windows.Forms.GroupBox(); + this.labelPrinterConfigButton = new System.Windows.Forms.Button(); + this.msLabel = new System.Windows.Forms.Label(); + this.delayTextBox = new System.Windows.Forms.TextBox(); + this.delayLabel = new System.Windows.Forms.Label(); + this.loginRequiredCheckBox = new System.Windows.Forms.CheckBox(); + this.languageComboBox = new System.Windows.Forms.ComboBox(); + this.languageLabel = new System.Windows.Forms.Label(); + this.connStrForTracingGroupBox = new System.Windows.Forms.GroupBox(); + this.tracingDBConnStringTextBox = new System.Windows.Forms.TextBox(); + this.connStrForUsersGroupBox = new System.Windows.Forms.GroupBox(); + this.usersDBConnStringTextBox = new System.Windows.Forms.TextBox(); + this.saveButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.modeGroupBox.SuspendLayout(); + this.commonGroupBox.SuspendLayout(); + this.connStrForTracingGroupBox.SuspendLayout(); + this.connStrForUsersGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // modeGroupBox + // + this.modeGroupBox.Controls.Add(this.tbfLabelPrinterRadioButton); + this.modeGroupBox.Controls.Add(this.standaloneRadioButton); + this.modeGroupBox.Controls.Add(this.withDBRadioButton); + this.modeGroupBox.Location = new System.Drawing.Point(12, 12); + this.modeGroupBox.Name = "modeGroupBox"; + this.modeGroupBox.Size = new System.Drawing.Size(197, 105); + this.modeGroupBox.TabIndex = 15; + this.modeGroupBox.TabStop = false; + this.modeGroupBox.Text = "Mode"; + // + // tbfLabelPrinterRadioButton + // + this.tbfLabelPrinterRadioButton.AutoSize = true; + this.tbfLabelPrinterRadioButton.Location = new System.Drawing.Point(19, 23); + this.tbfLabelPrinterRadioButton.Name = "tbfLabelPrinterRadioButton"; + this.tbfLabelPrinterRadioButton.Size = new System.Drawing.Size(156, 17); + this.tbfLabelPrinterRadioButton.TabIndex = 0; + this.tbfLabelPrinterRadioButton.TabStop = true; + this.tbfLabelPrinterRadioButton.Text = "TBF compatible label printer"; + this.tbfLabelPrinterRadioButton.UseVisualStyleBackColor = true; + // + // standaloneRadioButton + // + this.standaloneRadioButton.AutoSize = true; + this.standaloneRadioButton.Location = new System.Drawing.Point(18, 46); + this.standaloneRadioButton.Name = "standaloneRadioButton"; + this.standaloneRadioButton.Size = new System.Drawing.Size(143, 17); + this.standaloneRadioButton.TabIndex = 1; + this.standaloneRadioButton.TabStop = true; + this.standaloneRadioButton.Text = "20 char s/n - Standalone"; + this.standaloneRadioButton.UseVisualStyleBackColor = true; + // + // withDBRadioButton + // + this.withDBRadioButton.AutoSize = true; + this.withDBRadioButton.Location = new System.Drawing.Point(18, 69); + this.withDBRadioButton.Name = "withDBRadioButton"; + this.withDBRadioButton.Size = new System.Drawing.Size(158, 17); + this.withDBRadioButton.TabIndex = 2; + this.withDBRadioButton.TabStop = true; + this.withDBRadioButton.Text = "20 char s/n - With database"; + this.withDBRadioButton.UseVisualStyleBackColor = true; + // + // commonGroupBox + // + this.commonGroupBox.Controls.Add(this.labelPrinterConfigButton); + this.commonGroupBox.Controls.Add(this.msLabel); + this.commonGroupBox.Controls.Add(this.delayTextBox); + this.commonGroupBox.Controls.Add(this.delayLabel); + this.commonGroupBox.Controls.Add(this.loginRequiredCheckBox); + this.commonGroupBox.Controls.Add(this.languageComboBox); + this.commonGroupBox.Controls.Add(this.languageLabel); + this.commonGroupBox.Location = new System.Drawing.Point(222, 12); + this.commonGroupBox.Name = "commonGroupBox"; + this.commonGroupBox.Size = new System.Drawing.Size(316, 105); + this.commonGroupBox.TabIndex = 16; + this.commonGroupBox.TabStop = false; + // + // labelPrinterConfigButton + // + this.labelPrinterConfigButton.Location = new System.Drawing.Point(198, 73); + this.labelPrinterConfigButton.Name = "labelPrinterConfigButton"; + this.labelPrinterConfigButton.Size = new System.Drawing.Size(93, 23); + this.labelPrinterConfigButton.TabIndex = 6; + this.labelPrinterConfigButton.Text = "TBF label config"; + this.labelPrinterConfigButton.UseVisualStyleBackColor = true; + this.labelPrinterConfigButton.Click += new System.EventHandler(this.labelPrinterConfigButton_Click); + // + // msLabel + // + this.msLabel.AutoSize = true; + this.msLabel.Location = new System.Drawing.Point(262, 51); + this.msLabel.Name = "msLabel"; + this.msLabel.Size = new System.Drawing.Size(20, 13); + this.msLabel.TabIndex = 5; + this.msLabel.Text = "ms"; + // + // delayTextBox + // + this.delayTextBox.Location = new System.Drawing.Point(198, 46); + this.delayTextBox.Name = "delayTextBox"; + this.delayTextBox.Size = new System.Drawing.Size(52, 20); + this.delayTextBox.TabIndex = 4; + // + // delayLabel + // + this.delayLabel.AutoSize = true; + this.delayLabel.Location = new System.Drawing.Point(19, 51); + this.delayLabel.Name = "delayLabel"; + this.delayLabel.Size = new System.Drawing.Size(108, 13); + this.delayLabel.TabIndex = 3; + this.delayLabel.Text = "Delay between labels"; + // + // loginRequiredCheckBox + // + this.loginRequiredCheckBox.AutoSize = true; + this.loginRequiredCheckBox.Location = new System.Drawing.Point(22, 79); + this.loginRequiredCheckBox.Name = "loginRequiredCheckBox"; + this.loginRequiredCheckBox.Size = new System.Drawing.Size(114, 17); + this.loginRequiredCheckBox.TabIndex = 2; + this.loginRequiredCheckBox.Text = "User login required"; + this.loginRequiredCheckBox.UseVisualStyleBackColor = true; + // + // languageComboBox + // + this.languageComboBox.FormattingEnabled = true; + this.languageComboBox.Location = new System.Drawing.Point(198, 17); + this.languageComboBox.Name = "languageComboBox"; + this.languageComboBox.Size = new System.Drawing.Size(93, 21); + this.languageComboBox.TabIndex = 1; + // + // languageLabel + // + this.languageLabel.AutoSize = true; + this.languageLabel.Location = new System.Drawing.Point(19, 20); + this.languageLabel.Name = "languageLabel"; + this.languageLabel.Size = new System.Drawing.Size(134, 13); + this.languageLabel.TabIndex = 0; + this.languageLabel.Text = "Language, Sprache, Jazyk"; + // + // connStrForTracingGroupBox + // + this.connStrForTracingGroupBox.Controls.Add(this.tracingDBConnStringTextBox); + this.connStrForTracingGroupBox.Location = new System.Drawing.Point(12, 127); + this.connStrForTracingGroupBox.Name = "connStrForTracingGroupBox"; + this.connStrForTracingGroupBox.Size = new System.Drawing.Size(709, 50); + this.connStrForTracingGroupBox.TabIndex = 17; + this.connStrForTracingGroupBox.TabStop = false; + this.connStrForTracingGroupBox.Text = "Connection string for production tracing records"; + // + // tracingDBConnStringTextBox + // + this.tracingDBConnStringTextBox.Location = new System.Drawing.Point(19, 18); + this.tracingDBConnStringTextBox.Name = "tracingDBConnStringTextBox"; + this.tracingDBConnStringTextBox.Size = new System.Drawing.Size(672, 20); + this.tracingDBConnStringTextBox.TabIndex = 0; + // + // connStrForUsersGroupBox + // + this.connStrForUsersGroupBox.Controls.Add(this.usersDBConnStringTextBox); + this.connStrForUsersGroupBox.Location = new System.Drawing.Point(12, 186); + this.connStrForUsersGroupBox.Name = "connStrForUsersGroupBox"; + this.connStrForUsersGroupBox.Size = new System.Drawing.Size(709, 50); + this.connStrForUsersGroupBox.TabIndex = 18; + this.connStrForUsersGroupBox.TabStop = false; + this.connStrForUsersGroupBox.Text = "Connection string for central DB of users"; + // + // usersDBConnStringTextBox + // + this.usersDBConnStringTextBox.Location = new System.Drawing.Point(19, 18); + this.usersDBConnStringTextBox.Name = "usersDBConnStringTextBox"; + this.usersDBConnStringTextBox.Size = new System.Drawing.Size(672, 20); + this.usersDBConnStringTextBox.TabIndex = 0; + // + // saveButton + // + this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.saveButton.Location = new System.Drawing.Point(559, 18); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(74, 47); + this.saveButton.TabIndex = 19; + this.saveButton.Text = "Save"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.Location = new System.Drawing.Point(649, 18); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(71, 47); + this.cancelButton.TabIndex = 20; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // SettingsDlg + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(737, 250); + this.ControlBox = false; + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.connStrForUsersGroupBox); + this.Controls.Add(this.connStrForTracingGroupBox); + this.Controls.Add(this.commonGroupBox); + this.Controls.Add(this.modeGroupBox); + this.Name = "SettingsDlg"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "`"; + this.Load += new System.EventHandler(this.SettingsDlg_Load); + this.modeGroupBox.ResumeLayout(false); + this.modeGroupBox.PerformLayout(); + this.commonGroupBox.ResumeLayout(false); + this.commonGroupBox.PerformLayout(); + this.connStrForTracingGroupBox.ResumeLayout(false); + this.connStrForTracingGroupBox.PerformLayout(); + this.connStrForUsersGroupBox.ResumeLayout(false); + this.connStrForUsersGroupBox.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox modeGroupBox; + private System.Windows.Forms.RadioButton standaloneRadioButton; + private System.Windows.Forms.RadioButton withDBRadioButton; + private System.Windows.Forms.GroupBox commonGroupBox; + private System.Windows.Forms.ComboBox languageComboBox; + private System.Windows.Forms.Label languageLabel; + private System.Windows.Forms.Label msLabel; + private System.Windows.Forms.TextBox delayTextBox; + private System.Windows.Forms.Label delayLabel; + private System.Windows.Forms.CheckBox loginRequiredCheckBox; + private System.Windows.Forms.GroupBox connStrForTracingGroupBox; + private System.Windows.Forms.TextBox tracingDBConnStringTextBox; + private System.Windows.Forms.GroupBox connStrForUsersGroupBox; + private System.Windows.Forms.TextBox usersDBConnStringTextBox; + private System.Windows.Forms.Button saveButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.RadioButton tbfLabelPrinterRadioButton; + private System.Windows.Forms.Button labelPrinterConfigButton; + } +} \ No newline at end of file diff --git a/LabelPrinting/SettingsDlg.cs b/LabelPrinting/SettingsDlg.cs new file mode 100644 index 000000000..b6640c643 --- /dev/null +++ b/LabelPrinting/SettingsDlg.cs @@ -0,0 +1,170 @@ +/// +/// Copyright (c) 2021-2023 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using Common; +using TBF.Rig.Output.Printers.Label; +using LabelPrinting.Resources; + +namespace LabelPrinting +{ + public partial class SettingsDlg : Form + { + private readonly LocalSettings ls; + private readonly Factory factory; + + public SettingsDlg() + { + InitializeComponent(); + factory = new Factory(); + } + + public SettingsDlg(LocalSettings localSettings) + : this() + { + this.ls = localSettings; + } + + void Localize() + { + Text = Strings.Settings; + modeGroupBox.Text = Strings.Mode; + standaloneRadioButton.Text = "20 char s/n - " + Strings.Standalone; + withDBRadioButton.Text = "20 char s/n - " + Strings.With_database; + languageLabel.Text = Strings.Language_etc; + delayLabel.Text = Strings.Delay_between_labes; + loginRequiredCheckBox.Text = Strings.User_login_is_required; + saveButton.Text = Strings.Save; + cancelButton.Text = Strings.Cancel; + connStrForTracingGroupBox.Text = Strings.Connection_string_tracing_DB; + connStrForUsersGroupBox.Text = Strings.Connection_string_users_DB; + } + + private void SettingsDlg_Load(object sender, EventArgs e) + { + Localize(); + + languageComboBox.Items.Add("CS"); + languageComboBox.Items.Add("DE"); + languageComboBox.Items.Add("EN"); + languageComboBox.Items.Add("SK"); + languageComboBox.Items.Add("ZH_CN"); + languageComboBox.Text = ls.Language; + + if (ls == null) return; + + tbfLabelPrinterRadioButton.Checked = (ls.Mode == Mode.TbfLabelPrinter); + standaloneRadioButton.Checked = (ls.Mode == Mode.Standalone); + withDBRadioButton.Checked = (ls.Mode == Mode.WithDatabase); + + loginRequiredCheckBox.Checked = ls.IsUserLoginRequired; + + delayTextBox.Text = ls.DelayBetweenLabels.ToString(); + + tracingDBConnStringTextBox.Text = ls.TracingDBConnString; + usersDBConnStringTextBox.Text = ls.UsersDBConnString; + } + + /// + /// Verifies UI content + /// + /// None-empty string (message) when invalid + string IsUIContentValid() + { + if (!languageComboBox.Items.Contains(languageComboBox.Text)) + { + return Strings.Invalid_language; + } + + int idummy; + if (!int.TryParse(delayTextBox.Text, out idummy) || idummy < 0 || idummy > 5000) + { + return string.Format("{0} {1}", Strings.Invalid, delayLabel.Text); + } + + return null; + } + + /// + /// Updates settings, checks for differences compared to previous setrtings + /// + /// true when settings are different + bool UpdateSettings() + { + if (ls == null) return false; + + bool isDifferent = false; + + Mode mode = tbfLabelPrinterRadioButton.Checked ? Mode.TbfLabelPrinter : standaloneRadioButton.Checked ? Mode.Standalone : Mode.WithDatabase; + if (ls.Mode != mode) + { + ls.Mode = mode; + isDifferent = true; + } + + if (ls.Language != languageComboBox.Text) + { + ls.Language = languageComboBox.Text; + isDifferent = true; + } + + if (ls.IsUserLoginRequired != loginRequiredCheckBox.Checked) + { + ls.IsUserLoginRequired = loginRequiredCheckBox.Checked; + isDifferent = true; + } + + if (ls.TracingDBConnString != tracingDBConnStringTextBox.Text) + { + ls.TracingDBConnString = tracingDBConnStringTextBox.Text; + isDifferent = true; + } + + if (ls.UsersDBConnString != usersDBConnStringTextBox.Text) + { + ls.UsersDBConnString = usersDBConnStringTextBox.Text; + isDifferent = true; + } + + return isDifferent; + } + + private void saveButton_Click(object sender, EventArgs e) + { + string message = IsUIContentValid(); + if (string.IsNullOrEmpty(message)) + { + UpdateSettings(); + DialogResult = DialogResult.OK; + Close(); + } + else + { + MessageBox.Show(message); + } + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void labelPrinterConfigButton_Click(object sender, EventArgs e) + { + var cmpntEntity = Config.Entities.Component.CreateFromCfg("Printer", factory.ClassName, string.Empty, 1, + DebugMode.Normal, LogLevel.Off, ls.LabelPrinterCfg); + + var cfgForm = new TBF.UI.Bench.Components.ComponentParametersDlg(this); + cfgForm.ComponentCfgCtrl = new PrinterCfgCtrl(); + cfgForm.ComponentCfgCtrl.Config = factory.CmpntCfgFromCmpntEntity(cmpntEntity); + cfgForm.UnlockAfterStart = true; + + if (cfgForm.ShowDialog() == DialogResult.OK) + { + ls.LabelPrinterCfg = cfgForm.ComponentCfgCtrl.Config.CreateDbEntity().Parameters; + } + } + } +} diff --git a/LabelPrinting/SettingsDlg.resx b/LabelPrinting/SettingsDlg.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/LabelPrinting/SettingsDlg.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Results/Output/Printers/Label/LabelPrintDocument.cs b/Results/Output/Printers/Label/LabelPrintDocument.cs index 612f22ef0..67ca31cd4 100644 --- a/Results/Output/Printers/Label/LabelPrintDocument.cs +++ b/Results/Output/Printers/Label/LabelPrintDocument.cs @@ -28,7 +28,6 @@ namespace Results.Output.Printers.Label readonly Font font; /// Data to print - Results.Entities.Batch batch; LabelPrinterCfg cfg; Results.Entities.WaterMeter wm; @@ -36,11 +35,10 @@ namespace Results.Output.Printers.Label /// Constructor /// /// Text to be printed - public LabelPrintDocument(Results.Entities.Batch batch, LabelPrinterCfg cfg, Results.Entities.WaterMeter wm, string documentName) + public LabelPrintDocument(LabelPrinterCfg cfg, Results.Entities.WaterMeter wm, string documentName) { DocumentName = documentName; - this.batch = batch; this.cfg = cfg; this.wm = wm; this.itemsToPrint = WMeterRsltItemSpec.FromStrArray(cfg.ItemsToPrint); diff --git a/TBF.sln b/TBF.sln index 620754022..1f970391a 100644 --- a/TBF.sln +++ b/TBF.sln @@ -98,6 +98,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductionTracing", "Produc EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S640TestApp", "S640TestApp\S640TestApp.csproj", "{EE097B5A-8162-45B1-9643-4969FC3A8921}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabelPrinting", "LabelPrinting\LabelPrinting.csproj", "{E4531D13-317C-4D9F-809F-5533B5C3C8BF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -432,6 +434,18 @@ Global {EE097B5A-8162-45B1-9643-4969FC3A8921}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {EE097B5A-8162-45B1-9643-4969FC3A8921}.Release|Mixed Platforms.Build.0 = Release|Any CPU {EE097B5A-8162-45B1-9643-4969FC3A8921}.Release|x86.ActiveCfg = Release|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Debug|x86.ActiveCfg = Debug|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Debug|x86.Build.0 = Debug|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|Any CPU.Build.0 = Release|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|x86.ActiveCfg = Release|Any CPU + {E4531D13-317C-4D9F-809F-5533B5C3C8BF}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TBF/Rig/Output/Printers/Label/Printer.cs b/TBF/Rig/Output/Printers/Label/Printer.cs index e906bbcd0..80b104fab 100644 --- a/TBF/Rig/Output/Printers/Label/Printer.cs +++ b/TBF/Rig/Output/Printers/Label/Printer.cs @@ -148,7 +148,7 @@ namespace TBF.Rig.Output.Printers.Label { if (wm != null && !wm.Disabled && wm.PrintLabel && (!printerCfg.GoodOnly || wm.Passed)) { - PrintResults(batch, wm, string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition)); + PrintResults(wm, string.Format("{0}-{1}", batch.BatchNr, wm.WMPosition)); } } @@ -176,7 +176,7 @@ namespace TBF.Rig.Output.Printers.Label } - void PrintResults(Results.Entities.Batch batch, Results.Entities.WaterMeter wm, string documentName) + public void PrintResults(Results.Entities.WaterMeter wm, string documentName) { LabelPrinterCfg cfg = new LabelPrinterCfg { @@ -199,8 +199,8 @@ namespace TBF.Rig.Output.Printers.Label for (int i = 1; i <= printerCfg.NrOfCopies; i++) { - string docNameEx = string.Format(((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}_{1}"), documentName, i); - var pd = new Results.Output.Printers.Label.LabelPrintDocument(batch, cfg, wm, docNameEx); + string docNameEx = string.Format((printerCfg.NrOfCopies == 1) ? "{0}" : "{0}_{1}", documentName, i); + var pd = new LabelPrintDocument(cfg, wm, docNameEx); if (!string.IsNullOrEmpty(printerCfg.PrinterName)) pd.PrinterSettings.PrinterName = printerCfg.PrinterName; pd.Print(); } diff --git a/clean.bat b/clean.bat index 0407b9eaa..e10237b58 100644 --- a/clean.bat +++ b/clean.bat @@ -26,6 +26,8 @@ rmdir /s /q GenericTest\bin rmdir /s /q GenericTest\obj rmdir /s /q GraphLib\bin rmdir /s /q GraphLib\obj +rmdir /s /q LabelPrinting\bin +rmdir /s /q LabelPrinting\obj rmdir /s /q MergeResultsDBs\bin rmdir /s /q MergeResultsDBs\obj rmdir /s /q OrderManagement\bin\Debug