diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index b3dbc1b8a..5569e352a 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Sensus")] [assembly: AssemblyProduct("TestBenchFramework")] -[assembly: AssemblyCopyright("Copyright © 2013 - 2022 Sensus Slovensko, a.s.")] +[assembly: AssemblyCopyright("Copyright © 2013 - 2023 Sensus Slovensko, a.s.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.6.2030.0")] -[assembly: AssemblyFileVersion("3.6.2030.0")] +[assembly: AssemblyVersion("3.6.2035.0")] +[assembly: AssemblyFileVersion("3.6.2035.0")] diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index 6f9af88ad..268eb2022 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -3939,6 +3939,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Print. + /// + internal static string Print { + get { + return ResourceManager.GetString("Print", resourceCulture); + } + } + /// /// Looks up a localized string similar to Print again. /// @@ -4002,6 +4011,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Printer selection. + /// + internal static string Printer_selection { + get { + return ResourceManager.GetString("Printer_selection", resourceCulture); + } + } + /// /// Looks up a localized string similar to Printer. /// diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 4a76a4ffa..1462cd409 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2398,4 +2398,10 @@ default printer + + Print + + + Printer selection + \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 8dbb83a42..b0ef9b0e0 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -2394,6 +2394,12 @@ PreviousResultsDlg.cs + + Form + + + PrintResultsSelectionDlg.cs + Form @@ -3262,6 +3268,9 @@ PreviousResultsDlg.cs + + PrintResultsSelectionDlg.cs + ResultsArrangementDlg.cs diff --git a/TBF/UI/Process/ProcessTabPageCtrl.cs b/TBF/UI/Process/ProcessTabPageCtrl.cs index 5f8502897..27815a952 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl.cs @@ -1076,7 +1076,7 @@ namespace TBF.UI.Process void OnCompoundDetection(object sender, CompoundDetectionEventArgs args) { - compoundDetectionTextBox.Text += args.Message + Environment.NewLine; + compoundDetectionTextBox.AppendText(args.Message + Environment.NewLine); } void OnTestCompleted(object sender, TestCompletedEventArgs args) diff --git a/TBF/UI/ResultsMI/PreviousResultCtrl.Designer.cs b/TBF/UI/ResultsMI/PreviousResultCtrl.Designer.cs index 15069f89e..d9c96740e 100644 --- a/TBF/UI/ResultsMI/PreviousResultCtrl.Designer.cs +++ b/TBF/UI/ResultsMI/PreviousResultCtrl.Designer.cs @@ -60,6 +60,7 @@ this.sentCheckBox.TabIndex = 14; this.sentCheckBox.Text = "Sent"; this.sentCheckBox.UseVisualStyleBackColor = true; + this.sentCheckBox.Visible = false; // // failedCountLabel // diff --git a/TBF/UI/ResultsMI/PreviousResultCtrl.cs b/TBF/UI/ResultsMI/PreviousResultCtrl.cs index 3d598fd1c..e9120f2b0 100644 --- a/TBF/UI/ResultsMI/PreviousResultCtrl.cs +++ b/TBF/UI/ResultsMI/PreviousResultCtrl.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2016-2022 Sensus Slovensko a.s. +/// Copyright (c) 2016-2023 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -13,7 +13,8 @@ namespace TBF.UI.ResultsMI { readonly PreviousResultsDlg parent; readonly PreviousResultsMode mode; - + readonly bool sendBtnIsPrint; + public int BatchNr; public DateTime StarTime; public DateTime EndTime; @@ -57,27 +58,39 @@ namespace TBF.UI.ResultsMI passedCountLabel.Text = string.Format("{0}: {1}", Strings.Passed, PassedCount); failedCountLabel.Text = string.Format("{0}: {1}", Strings.Failed, FailedCount); - switch (mode) - { - case PreviousResultsMode.Show: sendReloadButton.Text = Strings.Save_again; break; - case PreviousResultsMode.Reload: sendReloadButton.Text = Strings.Restore; break; - case PreviousResultsMode.Fix: sendReloadButton.Text = Strings.Fix; break; - } - showButton.Text = Strings.Show; -#if MUNICH - if (mode == PreviousResultsMode.Show) sendReloadButton.Text = Strings.Print_again; - sentCheckBox.Text = Strings.Printed; - sentCheckBox.Checked = Sent; - sendReloadButton.Enabled = true; /// 'Print again' function always available -#elif ORACLE_DB + /// 'Sent' check box +#if ORACLE_DB + sentCheckBox.Visible = (mode == PreviousResultsMode.Show); sentCheckBox.Text = Strings.Sent; sentCheckBox.Checked = Sent; - sendReloadButton.Enabled = (mode != PreviousResultsMode.Show) || !Sent; -#else - sentCheckBox.Visible = false; - sendReloadButton.Enabled = (mode != PreviousResultsMode.Show); - sendReloadButton.Visible = (mode != PreviousResultsMode.Show); #endif + + /// 'Send again'/'Print' button + sendBtnIsPrint = false; + switch (mode) + { + case PreviousResultsMode.Show: +#if ORACLE_DB + sendReloadButton.Enabled = !Sent; + sendReloadButton.Text = Strings.Save_again; +#else + sendReloadButton.Enabled = true; /// 'Print' function always available + sendReloadButton.Text = Strings.Print; + sendBtnIsPrint = true; +#endif + break; + case PreviousResultsMode.Reload: + sendReloadButton.Enabled = true; + sendReloadButton.Text = Strings.Restore; + break; + case PreviousResultsMode.Fix: + sendReloadButton.Enabled = true; + sendReloadButton.Text = Strings.Fix; + break; + } + + /// 'Show' button + showButton.Text = Strings.Show; } public void UpdateSentState(bool sent) @@ -99,7 +112,11 @@ namespace TBF.UI.ResultsMI private void sendReloadButton_MouseClick(object sender, MouseEventArgs e) { - if (mode == PreviousResultsMode.Show) + if (sendBtnIsPrint) + { + parent.OnPrint(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs)); + } + else if (mode == PreviousResultsMode.Show) { parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs)); } diff --git a/TBF/UI/ResultsMI/PreviousResultsDlg.cs b/TBF/UI/ResultsMI/PreviousResultsDlg.cs index e2c847d81..67619b9df 100644 --- a/TBF/UI/ResultsMI/PreviousResultsDlg.cs +++ b/TBF/UI/ResultsMI/PreviousResultsDlg.cs @@ -15,6 +15,8 @@ using Common; using Results; using Results.Entities; using TBF.Resources; +using TBF.Rig.Generic; +using TBF.Rig.GenericDevices; using TBF.Rig.Output.DB.SensusOracle; using TBF.Rig.Sequences; @@ -48,6 +50,12 @@ namespace TBF.UI.ResultsMI this.mode = mode; currentBatchNr = Program.LocalSettings.BatchNr; + PrintHandler += delegate(object sndr, PreviousResultIdEventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(DoPrint), sndr, args); } + else DoPrint(sndr, args); + }; + SendAgainHandler += delegate(object sndr, PreviousResultIdEventArgs args) { if (InvokeRequired) { Invoke(new EventHandler(DoSendAgain), sndr, args); } @@ -208,9 +216,52 @@ namespace TBF.UI.ResultsMI - public event EventHandler SendAgainHandler; + public event EventHandler PrintHandler; - /// + /// + /// Called from PreviousResultCtrl when 'Print' button pressed. + /// + public void OnPrint(object sender, PreviousResultIdEventArgs data) + { + if (PrintHandler == null) return; + try + { + PrintHandler(sender, data); + } + catch (Exception e) + { + log.Error("PrintHandler(...) failed", e); + } + } + + public void DoPrint(object sender, PreviousResultIdEventArgs data) + { + foreach (var b in batches) + { + if (b.BatchNr == data.BatchNr) + { + IList printers = new List(); + foreach (var c in TBF.Rig.StateMachine.Components) + { + if (c is IResultsPrinter) printers.Add(c as IResultsPrinter); + } + var dlg = new PrintResultsSelectionDlg(printers); + if (dlg.ShowDialog() != DialogResult.OK) return; + + TBF.Rig.IOperation printResultsOp = dlg.SelectedPrinter.ProcessResultsOp(b); + printResultsOp.Start(); + TBF.Rig.Event e; + do { e = printResultsOp.Run(); } + while (e != TBF.Rig.Event.ResultsPrinted && e != TBF.Rig.Event.ErrorProcessingResults); + printResultsOp.Stop(); + } + } + } + + + public event EventHandler SendAgainHandler; + + /// /// Called from PreviousResultCtrl when 'Send again' button pressed. /// public void OnSendAgain(object sender, PreviousResultIdEventArgs data) diff --git a/TBF/UI/ResultsMI/PrintResultsSelectionDlg.Designer.cs b/TBF/UI/ResultsMI/PrintResultsSelectionDlg.Designer.cs new file mode 100644 index 000000000..1ed538db9 --- /dev/null +++ b/TBF/UI/ResultsMI/PrintResultsSelectionDlg.Designer.cs @@ -0,0 +1,100 @@ +namespace TBF.UI.ResultsMI +{ + partial class PrintResultsSelectionDlg + { + /// + /// 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.printersComboBox = new System.Windows.Forms.ComboBox(); + this.printerLabel = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // printersComboBox + // + this.printersComboBox.FormattingEnabled = true; + this.printersComboBox.Location = new System.Drawing.Point(121, 27); + this.printersComboBox.Name = "printersComboBox"; + this.printersComboBox.Size = new System.Drawing.Size(392, 21); + this.printersComboBox.TabIndex = 0; + // + // printerLabel + // + this.printerLabel.AutoSize = true; + this.printerLabel.Location = new System.Drawing.Point(36, 30); + this.printerLabel.Name = "printerLabel"; + this.printerLabel.Size = new System.Drawing.Size(37, 13); + this.printerLabel.TabIndex = 1; + this.printerLabel.Text = "Printer"; + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.Location = new System.Drawing.Point(305, 68); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(92, 40); + this.okButton.TabIndex = 4; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.Location = new System.Drawing.Point(421, 68); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(92, 40); + this.cancelButton.TabIndex = 5; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // PrintResultsSelectionDlg + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(546, 127); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.printerLabel); + this.Controls.Add(this.printersComboBox); + this.Name = "PrintResultsSelectionDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Database and water meter selection"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox printersComboBox; + private System.Windows.Forms.Label printerLabel; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + } +} \ No newline at end of file diff --git a/TBF/UI/ResultsMI/PrintResultsSelectionDlg.cs b/TBF/UI/ResultsMI/PrintResultsSelectionDlg.cs new file mode 100644 index 000000000..01a4cb943 --- /dev/null +++ b/TBF/UI/ResultsMI/PrintResultsSelectionDlg.cs @@ -0,0 +1,62 @@ +/// +/// Copyright (c) 2023 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using TBF.Resources; +using TBF.Rig.GenericDevices; + +namespace TBF.UI.ResultsMI +{ + public partial class PrintResultsSelectionDlg : Form + { + readonly IList printers; + public IResultsPrinter SelectedPrinter; + + public PrintResultsSelectionDlg(IList printers) + { + this.printers = printers; + + InitializeComponent(); + + Localize(); + + if (printers != null) + foreach (var p in printers) + printersComboBox.Items.Add(p.Name); + } + + void Localize() + { + Text = Strings.Printer_selection; + printerLabel.Text = Strings.Printer; + okButton.Text = Strings.OkBtnText; + cancelButton.Text = Strings.CancelBtnText; + } + + private void okButton_Click(object sender, EventArgs e) + { + if (printersComboBox.SelectedItem != null) + { + SelectedPrinter = printers.FirstOrDefault(x => x.Name == printersComboBox.SelectedItem.ToString()); + } + + if (SelectedPrinter == null) + { + MessageBox.Show("Invalid selection"); + return; + } + + DialogResult = DialogResult.OK; + Close(); + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/TBF/UI/ResultsMI/PrintResultsSelectionDlg.resx b/TBF/UI/ResultsMI/PrintResultsSelectionDlg.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/UI/ResultsMI/PrintResultsSelectionDlg.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