diff --git a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs index f590da8e5..3cadbca15 100644 --- a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs +++ b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs @@ -139,7 +139,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing /// Only a release version registers a workplace TracingDB.DB.RegisterWorkplace(session, workplace, - Users.GlobalData.GetCurrentUserName(), + Users.CurrentUser.UserName(), (ipAddress != null) ? ipAddress.ToString() : "1.2.3.4", "", WorkstepName, diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index ed8049141..89432cf2c 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -2408,6 +2408,12 @@ PicturesTabPageCtrl.cs + + Form + + + DummyDlg.cs + diff --git a/TBF/UI/DummyDlg.Designer.cs b/TBF/UI/DummyDlg.Designer.cs new file mode 100644 index 000000000..fdc3c83d9 --- /dev/null +++ b/TBF/UI/DummyDlg.Designer.cs @@ -0,0 +1,38 @@ +namespace TBF.UI +{ + partial class DummyDlg + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "DummyDlg"; + } + + #endregion + } +} \ No newline at end of file diff --git a/TBF/UI/DummyDlg.cs b/TBF/UI/DummyDlg.cs new file mode 100644 index 000000000..5a0462830 --- /dev/null +++ b/TBF/UI/DummyDlg.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace TBF.UI +{ + public partial class DummyDlg : Form + { + public DummyDlg() + { + InitializeComponent(); + } + } +} diff --git a/TBF/UI/ResultsMI/PreviousResultCtrl.cs b/TBF/UI/ResultsMI/PreviousResultCtrl.cs index 90ad12017..7be8f73d8 100644 --- a/TBF/UI/ResultsMI/PreviousResultCtrl.cs +++ b/TBF/UI/ResultsMI/PreviousResultCtrl.cs @@ -1,8 +1,9 @@ /// -/// Copyright (c) 2016-2019 Sensus Slovensko a.s. +/// Copyright (c) 2016-2022 Sensus Slovensko a.s. /// using System; using System.Windows.Forms; +using Common; using TBF.Resources; namespace TBF.UI.ResultsMI @@ -22,7 +23,7 @@ namespace TBF.UI.ResultsMI public int FailedCount; public bool Sent; - protected PreviousResultCtrl() + PreviousResultCtrl() { InitializeComponent(); } @@ -106,13 +107,15 @@ namespace TBF.UI.ResultsMI else if (mode == PreviousResultsMode.Fix) { /// Access only to thise who manage production tracing - Common.GID[] rqrdGroupMembership = new Common.GID[] { Common.GID.TraceabilityManagement }; + GID[] rqrdGroupMembership = new GID[] { GID.TraceabilityManagement }; - if ((new Users.Forms.LoginDlg(Users.GlobalData.CurrentUser.UserName, rqrdGroupMembership)).ShowDialog() != DialogResult.OK) + if ((new Users.Forms.LoginDlg(Users.CurrentUser.UserName(), rqrdGroupMembership, parent)).ShowDialog() != DialogResult.OK) { return; } + Program.MainWnd.UpdateUser(); + parent.OnReloadAndFix(this, new PreviousResultIdEventArgs(BatchNr)); } #endif diff --git a/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs b/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs index 914ec1c64..84df5b2c6 100644 --- a/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs +++ b/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs @@ -35,13 +35,13 @@ this.vertSplitContainer = new System.Windows.Forms.SplitContainer(); this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); this.filterGroupBox = new System.Windows.Forms.GroupBox(); + this.reloadButton = new System.Windows.Forms.Button(); this.procedureTextBox = new System.Windows.Forms.TextBox(); this.procedureLabel = new System.Windows.Forms.Label(); this.toLabel = new System.Windows.Forms.Label(); this.fromLabel = new System.Windows.Forms.Label(); this.toDateTimePicker = new System.Windows.Forms.DateTimePicker(); this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker(); - this.reloadButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.vertSplitContainer)).BeginInit(); this.vertSplitContainer.Panel1.SuspendLayout(); this.vertSplitContainer.Panel2.SuspendLayout(); @@ -154,6 +154,16 @@ this.filterGroupBox.TabStop = false; this.filterGroupBox.Text = "Filter"; // + // reloadButton + // + this.reloadButton.Location = new System.Drawing.Point(1005, 23); + this.reloadButton.Name = "reloadButton"; + this.reloadButton.Size = new System.Drawing.Size(37, 23); + this.reloadButton.TabIndex = 0; + this.reloadButton.Text = "@"; + this.reloadButton.UseVisualStyleBackColor = true; + this.reloadButton.Click += new System.EventHandler(this.reloadButton_Click); + // // procedureTextBox // this.procedureTextBox.Location = new System.Drawing.Point(460, 25); @@ -206,16 +216,6 @@ this.fromDateTimePicker.Size = new System.Drawing.Size(82, 20); this.fromDateTimePicker.TabIndex = 17; // - // reloadButton - // - this.reloadButton.Location = new System.Drawing.Point(1005, 23); - this.reloadButton.Name = "reloadButton"; - this.reloadButton.Size = new System.Drawing.Size(37, 23); - this.reloadButton.TabIndex = 0; - this.reloadButton.Text = "@"; - this.reloadButton.UseVisualStyleBackColor = true; - this.reloadButton.Click += new System.EventHandler(this.reloadButton_Click); - // // PreviousResultsDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -228,6 +228,7 @@ this.Name = "PreviousResultsDlg"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.Text = "Previous results"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PreviousResultsDlg_FormClosing); this.Load += new System.EventHandler(this.PreviousResultsDlg_Load); this.vertSplitContainer.Panel1.ResumeLayout(false); this.vertSplitContainer.Panel2.ResumeLayout(false); diff --git a/TBF/UI/ResultsMI/PreviousResultsDlg.cs b/TBF/UI/ResultsMI/PreviousResultsDlg.cs index a9efe02c9..271e79879 100644 --- a/TBF/UI/ResultsMI/PreviousResultsDlg.cs +++ b/TBF/UI/ResultsMI/PreviousResultsDlg.cs @@ -398,5 +398,10 @@ namespace TBF.UI.ResultsMI UpdateButtons(); Redraw(); } + + private void PreviousResultsDlg_FormClosing(object sender, FormClosingEventArgs e) + { + if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser(); + } } } diff --git a/TBF/UI/Shared/BenchControlPanel.cs b/TBF/UI/Shared/BenchControlPanel.cs index d065be4b7..1f0f86a9f 100644 --- a/TBF/UI/Shared/BenchControlPanel.cs +++ b/TBF/UI/Shared/BenchControlPanel.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using log4net; +using Common; using Config.Entities; using TBF.UiBridge; using TBF.Resources; @@ -180,12 +181,11 @@ namespace TBF.UI.Shared string oriTestName = testComboBox.Text; - IList procedures = TBF.DB.CreateSession(Program.MainWnd.SelectedProcedure.IsRemote ? - Common.DBKind.RemoteConfig : Common.DBKind.Config) - .QueryOver() - .Where(x => (x.ProcedureState == Common.ProcedureState.Active)) - .And(x => (x.Name == Program.MainWnd.SelectedProcedure.Name)) - .List(); + IList procedures = TBF.DB.CreateSession(Program.MainWnd.SelectedProcedure.IsRemote ? DBKind.RemoteConfig : DBKind.Config) + .QueryOver() + .Where(x => (x.ProcedureState == ProcedureState.Active)) + .And(x => (x.Name == Program.MainWnd.SelectedProcedure.Name)) + .List(); if (procedures.Count != 1) { testComboBox.Text = string.Empty; @@ -277,13 +277,14 @@ namespace TBF.UI.Shared { #if TURA_IPERL || TURA_IPERL_NEW /// Prevent 'Stop draining' by password - if (drain1Highlighted && !Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.TestingSpecialists)) + if (drain1Highlighted && !Users.CurrentUser.IsMemberOf(GID.TestingSpecialists)) { - if ((new Users.Forms.LoginDlg(new Common.GID[] { Common.GID.TestingSpecialists })).ShowDialog() != DialogResult.OK) + var dlg = new DummyDlg(); + if ((new Users.Forms.LoginDlg(new GID[] { GID.TestingSpecialists }, dlg)).ShowDialog() != DialogResult.OK) return; - if (Program.MainWnd != null) Program.MainWnd.UpdateUser(); Bridge.Ui2Bench(UI2BenchCmd.StopDrainingTank1); + Users.CurrentUser.Restore(dlg); return; } #endif @@ -294,13 +295,14 @@ namespace TBF.UI.Shared { #if TURA_IPERL || TURA_IPERL_NEW /// Prevent 'Stop draining' by password - if (drain1Highlighted && !Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.TestingSpecialists)) + if (drain1Highlighted && !Users.CurrentUser.IsMemberOf(GID.TestingSpecialists)) { - if ((new Users.Forms.LoginDlg(new Common.GID[] { Common.GID.TestingSpecialists })).ShowDialog() != DialogResult.OK) + var dlg = new DummyDlg(); + if ((new Users.Forms.LoginDlg(new GID[] { GID.TestingSpecialists }, dlg)).ShowDialog() != DialogResult.OK) return; - if (Program.MainWnd != null) Program.MainWnd.UpdateUser(); Bridge.Ui2Bench(UI2BenchCmd.StopDrainingTank2); + Users.CurrentUser.Restore(dlg); return; } #endif @@ -311,13 +313,14 @@ namespace TBF.UI.Shared { #if TURA_IPERL || TURA_IPERL_NEW /// Prevent 'Stop draining' by password - if (drain1Highlighted && !Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.TestingSpecialists)) + if (drain1Highlighted && !Users.CurrentUser.IsMemberOf(GID.TestingSpecialists)) { - if ((new Users.Forms.LoginDlg(new Common.GID[] { Common.GID.TestingSpecialists })).ShowDialog() != DialogResult.OK) + var dlg = new DummyDlg(); + if ((new Users.Forms.LoginDlg(new GID[] { GID.TestingSpecialists }, dlg)).ShowDialog() != DialogResult.OK) return; - if (Program.MainWnd != null) Program.MainWnd.UpdateUser(); Bridge.Ui2Bench(UI2BenchCmd.StopDrainingTank3); + Users.CurrentUser.Restore(dlg); return; } #endif