diff --git a/Common/Common.csproj b/Common/Common.csproj
index 687c9aa4e..d760f782b 100644
--- a/Common/Common.csproj
+++ b/Common/Common.csproj
@@ -60,7 +60,6 @@
ModelessForm.cs
-
diff --git a/Common/GlobalData.cs b/Common/GlobalData.cs
deleted file mode 100644
index 44b7e9260..000000000
--- a/Common/GlobalData.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-///
-/// Copyright (c) 2021 Sensus Slovensko a.s.
-///
-using System;
-
-namespace Common
-{
- public class GlobalData
- {
- public static double SampleDensity = 0; /// sample water density measured in an accredited labo [kg/m3]
- public static double SampleTemp = 0; /// sample temperature when density measured in an accredited labo [°C]
- public static double Buoyancy = 0;
-
- public const string AdminUsername = "admin";
- public const string AdminPassword = "staratura";
-
- public static DBSettings RemoteUsersDB = null;
- public static DBSettings LocalUsersDB = null;
-
- public static IUser CurrentUser;
- public static IUser CurrentUser2;
- public static IUser CurrentUser3;
-
- public static Common.AuthorizedAs AuthorizedAs;
- public static DateTime LastAuthorization = DateTime.Now;
-
- public static int MinPasswdLength = 0;
- public static int PasswdExpirationPeriodDays = 0;
-
- public static string GetCurrentUserName()
- {
- if (CurrentUser == null || CurrentUser.UserName == null)
- return string.Empty;
- else if (CurrentUser2 == null || CurrentUser2.UserName == null)
- return CurrentUser.UserName;
- else if (CurrentUser3 == null || CurrentUser3.UserName == null)
- return string.Format("{0},{1}", CurrentUser.UserName, CurrentUser2.UserName);
- else
- return string.Format("{0},{1},{2}", CurrentUser.UserName, CurrentUser2.UserName, CurrentUser3.UserName);
- }
- }
-}
diff --git a/Config/Data.cs b/Config/Data.cs
index db346ae93..d9d00e694 100644
--- a/Config/Data.cs
+++ b/Config/Data.cs
@@ -2,7 +2,7 @@
namespace Config
{
- public class Data : Users.GlobalData
+ public class Data : Users.CurrentUser
{
public const string AdminUsername = "admin";
public const string AdminPassword = "staratura";
diff --git a/Config/Entities/Procedure.cs b/Config/Entities/Procedure.cs
index 1bf4fccf6..f9b4dca94 100644
--- a/Config/Entities/Procedure.cs
+++ b/Config/Entities/Procedure.cs
@@ -75,7 +75,7 @@ namespace Config.Entities
///
/// Default values
///
- CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
+ CreationUser = Users.CurrentUser.UserName();
CreationTime = DateTime.Now;
LastChgUser = CreationUser;
LastChgTime = CreationTime;
diff --git a/Config/Entities/Profile.cs b/Config/Entities/Profile.cs
index 13672a0b3..cf39b31b3 100644
--- a/Config/Entities/Profile.cs
+++ b/Config/Entities/Profile.cs
@@ -36,7 +36,7 @@ namespace Config.Entities
///
/// Default values
///
- CreationUser = (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.UserName : null;
+ CreationUser = Users.CurrentUser.UserName();
CreationTime = DateTime.Now;
LastChgUser = CreationUser;
LastChgTime = CreationTime;
diff --git a/DeviceTest/DeviceTestDlg.cs b/DeviceTest/DeviceTestDlg.cs
index 7628cd03c..2cf92bddb 100644
--- a/DeviceTest/DeviceTestDlg.cs
+++ b/DeviceTest/DeviceTestDlg.cs
@@ -422,7 +422,7 @@ namespace DeviceTest
{
parentCfg = parentFactory.DefaultConfig();
}
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
cfgForm.CmpntEntities = new List();
IComponentCfgCtrl cfgControl = parentCfg.GetControl(cfgForm.CmpntEntities);
@@ -451,7 +451,7 @@ namespace DeviceTest
{
component1Cfg = component1Factory.DefaultConfig();
}
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
///
var compEntities = new List();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -485,7 +485,7 @@ namespace DeviceTest
{
component2Cfg = component2Factory.DefaultConfig();
}
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
///
var compEntities = new List();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
@@ -520,7 +520,7 @@ namespace DeviceTest
{
component3Cfg = component3Factory.DefaultConfig();
}
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
///
var compEntities = new List();
if (parentFactory != null && parentCfg != null) compEntities.Add(parentCfg.CreateDbEntity());
diff --git a/EventViewer/EventViewerWnd.cs b/EventViewer/EventViewerWnd.cs
index 0c1ebc8d8..6c33ec5fa 100644
--- a/EventViewer/EventViewerWnd.cs
+++ b/EventViewer/EventViewerWnd.cs
@@ -291,7 +291,7 @@ namespace EventViewer
{
try
{
- Users.GlobalData.RemoteUsersDB = new Common.DBSettings(Common.DBType.MySql, Program.LocalSettings.UsersDBConnString);
+ Users.CurrentUser.RemoteUsersDB = new Common.DBSettings(Common.DBType.MySql, Program.LocalSettings.UsersDBConnString);
Users.Forms.LoginDlg dlg = new Users.Forms.LoginDlg();
if (dlg.ShowDialog() == DialogResult.OK)
{
diff --git a/ResultsBrowser/Forms/PrinterConfigDlg.Designer.cs b/ResultsBrowser/Forms/PrinterConfigDlg.Designer.cs
index 439835110..30c795977 100644
--- a/ResultsBrowser/Forms/PrinterConfigDlg.Designer.cs
+++ b/ResultsBrowser/Forms/PrinterConfigDlg.Designer.cs
@@ -107,6 +107,7 @@
this.Controls.Add(this.printerClassComboBox);
this.Name = "PrinterConfigDlg";
this.Text = "Printer configuration";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PrinterConfigDlg_FormClosing);
this.Load += new System.EventHandler(this.PrinterClassDlg_Load);
this.ResumeLayout(false);
this.PerformLayout();
diff --git a/ResultsBrowser/Forms/PrinterConfigDlg.cs b/ResultsBrowser/Forms/PrinterConfigDlg.cs
index 9434fbc62..573caa485 100644
--- a/ResultsBrowser/Forms/PrinterConfigDlg.cs
+++ b/ResultsBrowser/Forms/PrinterConfigDlg.cs
@@ -88,7 +88,7 @@ namespace ResultsBrowser.Forms
printerCfg = printerFactory.CmpntCfgFromCmpntEntity(cmpnt);
}
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
cfgForm.CmpntEntities = new List();
IComponentCfgCtrl cfgControl = printerCfg.GetControl(cfgForm.CmpntEntities);
@@ -167,5 +167,10 @@ namespace ResultsBrowser.Forms
return null;
}
+
+ private void PrinterConfigDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ Users.CurrentUser.Restore(this);
+ }
}
}
diff --git a/TBF/Program.cs b/TBF/Program.cs
index edc4f2a18..08db13ab7 100644
--- a/TBF/Program.cs
+++ b/TBF/Program.cs
@@ -256,8 +256,8 @@ namespace TBF
{
log.FatalFormat("Test bench name: {0}", loginDlgBench.BenchName);
- Users.GlobalData.RemoteUsersDB = LocalSettings.TestBenches[i].UsersDBSettings;
- Users.GlobalData.LocalUsersDB = LocalSettings.TestBenches[i].ProceduresDBSettings;
+ Users.CurrentUser.RemoteUsersDB = LocalSettings.TestBenches[i].UsersDBSettings;
+ Users.CurrentUser.LocalUsersDB = LocalSettings.TestBenches[i].ProceduresDBSettings;
Users.Entities.User loadedUser = null;
try
@@ -273,10 +273,10 @@ namespace TBF
if (Users.Entities.User.IsPowerUser(loginDlgBench.Alias, loginDlgBench.Password))
{
loadedUser = new Users.Entities.User(loginDlgBench.Alias, 6, true);
- authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership);
+ authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
if (authorized)
{
- Users.GlobalData.AuthorizedAs = Common.AuthorizedAs.PowerUser;
+ Users.CurrentUser.AuthorizedAs = Common.AuthorizedAs.PowerUser;
}
}
@@ -285,7 +285,7 @@ namespace TBF
///
if (!authorized)
{
- DBSettings[] dbs = new DBSettings[] { Users.GlobalData.RemoteUsersDB, Users.GlobalData.LocalUsersDB };
+ DBSettings[] dbs = new DBSettings[] { Users.CurrentUser.RemoteUsersDB, Users.CurrentUser.LocalUsersDB };
authorizedAs = Common.AuthorizedAs.RemoteUser; /// Try remote DB first
@@ -297,7 +297,7 @@ namespace TBF
if (loginDlgBench.Password == LoginDlgWithBenchSelection.UseTheTagPassword)
{
loadedUser = Users.Entities.User.LoadUserByTag(loginDlgBench.Alias, db);
- if (loadedUser != null) authorized = loadedUser.AuthorizeTag(loginDlgBench.Alias, reqGrpMembership);
+ if (loadedUser != null) authorized = loadedUser.AuthorizeTag(loginDlgBench.Alias, reqGrpMembership, null);
}
else
{
@@ -306,17 +306,17 @@ namespace TBF
default:
case Common.LoginMethod.UserName:
loadedUser = Users.Entities.User.LoadUserByName(loginDlgBench.Alias, db);
- if (loadedUser != null) authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership);
+ if (loadedUser != null) authorized = loadedUser.Authorize(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
break;
case Common.LoginMethod.FullName:
loadedUser = Users.Entities.User.LoadUserByFullName(loginDlgBench.Alias, db);
- if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership);
+ if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlgBench.Alias, loginDlgBench.Password, reqGrpMembership, null);
break;
case Common.LoginMethod.Number:
int number;
if (!int.TryParse(loginDlgBench.Alias, out number)) break;
loadedUser = Users.Entities.User.LoadUserByNumber(number, db);
- if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlgBench.Password, reqGrpMembership);
+ if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlgBench.Password, reqGrpMembership, null);
break;
}
}
@@ -335,7 +335,7 @@ namespace TBF
if (authorized)
{
loadedUser.SetLegalizator(loginDlgBench.Legalizator);
- Users.GlobalData.AuthorizedAs = authorizedAs;
+ Users.CurrentUser.AuthorizedAs = authorizedAs;
LocalSettings.LoginMethod = loginDlgBench.Method; /// Save the login method actually used
diff --git a/TBF/Rig/DataContainers/BackupAndSecurityOptions/Component.cs b/TBF/Rig/DataContainers/BackupAndSecurityOptions/Component.cs
index d8308fea7..b0af900a7 100644
--- a/TBF/Rig/DataContainers/BackupAndSecurityOptions/Component.cs
+++ b/TBF/Rig/DataContainers/BackupAndSecurityOptions/Component.cs
@@ -29,8 +29,8 @@ namespace TBF.Rig.DataContainers.BackupAndSecurityOptions
public override void Initialize()
{
- Users.GlobalData.MinPasswdLength = myCfg.MinPasswdLength;
- Users.GlobalData.PasswdExpirationPeriodDays = myCfg.PasswdExpirationPeriodDays;
+ Users.CurrentUser.MinPasswdLength = myCfg.MinPasswdLength;
+ Users.CurrentUser.PasswdExpirationPeriodDays = myCfg.PasswdExpirationPeriodDays;
log.FatalFormat("{0} initialized: {1}", Name, this);
}
}
diff --git a/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs b/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs
index 058f40405..0a31374f2 100644
--- a/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs
+++ b/TBF/Rig/DataEntry/S620/FormForMechanicalMetersWithTracing.cs
@@ -734,7 +734,7 @@ namespace TBF.Rig.DataEntry.S620
ReferenceRecord refRecord = new ReferenceRecord(currentWorkflow,
currentWStep,
bodyNrBoxes[wmNr0].Text,
- Users.GlobalData.GetCurrentUserName(),
+ Users.CurrentUser.UserName(),
workplace,
passed ? 1 : 0);
if (uniqueCodeParts.Count >= 2)
diff --git a/TBF/Rig/Elde/CoverTest/CoverTestForm.cs b/TBF/Rig/Elde/CoverTest/CoverTestForm.cs
index da2bf18e3..c1fc888ea 100644
--- a/TBF/Rig/Elde/CoverTest/CoverTestForm.cs
+++ b/TBF/Rig/Elde/CoverTest/CoverTestForm.cs
@@ -54,19 +54,17 @@ namespace TBF.Rig.Elde.CoverTest
private void bypassButton_Click(object sender, EventArgs e)
{
- if (!Users.GlobalData.CurrentUser.IsMemberOf(bypassLevel))
+ if (!Users.CurrentUser.IsMemberOf(bypassLevel))
{
- if ((new Users.Forms.LoginDlg(bypassLevel)).ShowDialog() != DialogResult.OK)
+ if ((new Users.Forms.LoginDlg(bypassLevel, this)).ShowDialog() != DialogResult.OK)
{
return;
}
- else
- {
- if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
- }
+
+ Program.MainWnd.UpdateUser();
}
- bypassLog.InfoFormat("{0} bypassed by {1}", message, Users.GlobalData.CurrentUser.UserName);
+ bypassLog.InfoFormat("{0} bypassed by {1}", message, Users.CurrentUser.UserName());
completed = true;
Close();
@@ -109,5 +107,10 @@ namespace TBF.Rig.Elde.CoverTest
}
#endregion
+
+ private void CoverTestForm_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/Rig/Elde/CoverTest/CoverTestForm.designer.cs b/TBF/Rig/Elde/CoverTest/CoverTestForm.designer.cs
index d5c829add..8fd62bd6f 100644
--- a/TBF/Rig/Elde/CoverTest/CoverTestForm.designer.cs
+++ b/TBF/Rig/Elde/CoverTest/CoverTestForm.designer.cs
@@ -68,6 +68,7 @@ namespace TBF.Rig.Elde.CoverTest
this.Name = "CoverTestForm";
this.Text = "Message";
this.TopMost = true;
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CoverTestForm_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
diff --git a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
index cfbbd5250..f590da8e5 100644
--- a/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
+++ b/TBF/Rig/Output/DB/ProductionTracing/Tracing.cs
@@ -601,7 +601,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
else if ((currentProcess != null) && (wm.ProcessId == currentProcess.Id))
{
/// Process is already loaded => save a reference record for this WM
- session.SaveOrUpdate(new ReferenceRecord(currentProcess, currentWorkstep, wm.SerialNr, Users.GlobalData.CurrentUser.UserName, workplace, wm.Passed ? 0 : 1));
+ session.SaveOrUpdate(new ReferenceRecord(currentProcess, currentWorkstep, wm.SerialNr, Users.CurrentUser.UserName(), workplace, wm.Passed ? 0 : 1));
return 1;
}
else if (wm.ProcessId != 0)
@@ -616,7 +616,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
{
if (ws.Name == WorkstepName)
{
- session.SaveOrUpdate(new ReferenceRecord(processes[0], ws, wm.SerialNr, Users.GlobalData.CurrentUser.UserName, workplace, wm.Passed ? 0 : 1));
+ session.SaveOrUpdate(new ReferenceRecord(processes[0], ws, wm.SerialNr, Users.CurrentUser.UserName(), workplace, wm.Passed ? 0 : 1));
return 1;
}
}
@@ -648,7 +648,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
IList worksteps;
if ((refRecords.Count > 0) && workstepsDictionary.TryGetValue(refRecords[0].Process.Id, out worksteps) && (worksteps.Count == 1))
{
- session.SaveOrUpdate(new ReferenceRecord(refRecords[0].Process, worksteps[0], wm.SerialNr, Users.GlobalData.CurrentUser.UserName, workplace, wm.Passed ? 0 : 1));
+ session.SaveOrUpdate(new ReferenceRecord(refRecords[0].Process, worksteps[0], wm.SerialNr, Users.CurrentUser.UserName(), workplace, wm.Passed ? 0 : 1));
return 1;
}
diff --git a/TBF/Rig/Output/FlexFlow/FlexFlow.cs b/TBF/Rig/Output/FlexFlow/FlexFlow.cs
index 62bc2746b..517307518 100644
--- a/TBF/Rig/Output/FlexFlow/FlexFlow.cs
+++ b/TBF/Rig/Output/FlexFlow/FlexFlow.cs
@@ -28,7 +28,7 @@ namespace TBF.Rig.Output.FlexFlow
}
}
- public string UserId { get { return Users.GlobalData.GetCurrentUserName(); } }
+ public string UserId { get { return Users.CurrentUser.UserName(); } }
enum Retv
diff --git a/TBF/Rig/Sequences/MainSeq.cs b/TBF/Rig/Sequences/MainSeq.cs
index 7577e4121..f31561cae 100644
--- a/TBF/Rig/Sequences/MainSeq.cs
+++ b/TBF/Rig/Sequences/MainSeq.cs
@@ -467,10 +467,10 @@ namespace TBF.Rig.Sequences
/// Water meter failed but the failure is not an assembly error
wm.Disabled = true;
}
- else if (!wm.Disabled && (Users.GlobalData.GetCurrentUserName() == "milan" ||
- Users.GlobalData.GetCurrentUserName() == "augustin" ||
- Users.GlobalData.GetCurrentUserName() == "michal" ||
- Users.GlobalData.GetCurrentUserName() == "michal2"))
+ else if (!wm.Disabled && (Users.CurrentUser.UserName() == "milan" ||
+ Users.CurrentUser.UserName() == "augustin" ||
+ Users.CurrentUser.UserName() == "michal" ||
+ Users.CurrentUser.UserName() == "michal2"))
{
/// Water meter failed, is not disabled, there is an assembly error and user is one of above
/// ... => reset flag E28
@@ -673,7 +673,7 @@ namespace TBF.Rig.Sequences
log.ErrorFormat("StartInfoReader failed to read data from the database");
/// TODO: Message for an operator? Error?
}
- else if ((selection == Selection.RestoreAndFixBatch) && (Users.GlobalData.GetCurrentUserName() != "milan"))
+ else if ((selection == Selection.RestoreAndFixBatch) && (Users.CurrentUser.UserName() != "milan"))
{
/// Restore and fix a batch - part 2
for (int i = 0; i < BatchRslts.Batch.WaterMeters.Count; i++)
diff --git a/TBF/Rig/Sequences/MainSeqUtils.cs b/TBF/Rig/Sequences/MainSeqUtils.cs
index 1fd386fa5..9548cfd02 100644
--- a/TBF/Rig/Sequences/MainSeqUtils.cs
+++ b/TBF/Rig/Sequences/MainSeqUtils.cs
@@ -629,8 +629,8 @@ namespace TBF.Rig.Sequences
(BenchInfo != null) ? BenchInfo.Address3 : string.Empty,
(BenchInfo != null) ? BenchInfo.Address4 : string.Empty,
(BenchInfo != null) ? BenchInfo.Address5 : string.Empty,
- (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.ToEncodedStr() : "none",
- (Users.GlobalData.CurrentUser != null) ? Users.GlobalData.CurrentUser.Number : 0,
+ (Users.CurrentUser.User() != null) ? Users.CurrentUser.User().ToEncodedStr() : "none",
+ Users.CurrentUser.Number(),
Program.Version,
StateMachine.Procedure,
waterMeterData,
diff --git a/TBF/Rig/TestMethods/Endurance/CycleDlg.cs b/TBF/Rig/TestMethods/Endurance/CycleDlg.cs
index 1baeda58d..cae3283a9 100644
--- a/TBF/Rig/TestMethods/Endurance/CycleDlg.cs
+++ b/TBF/Rig/TestMethods/Endurance/CycleDlg.cs
@@ -34,9 +34,9 @@ namespace TBF.Rig.TestMethods.Endurance
ITabWithListViewEx seqStepsCtrl;
- public CycleDlg()
- : this(new List())
+ CycleDlg()
{
+ EnduranceCycle = new List();
}
public CycleDlg(IList cycle)
@@ -47,6 +47,7 @@ namespace TBF.Rig.TestMethods.Endurance
InitializeComponent();
/// SharedDlgButtons configuration
+ sharedButtons.ParentForm = this;
sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
SharedButtons.Buttons.Remove |
@@ -260,5 +261,10 @@ namespace TBF.Rig.TestMethods.Endurance
UpdateButtonStates(SharedButtons.SelectedItemPos.Middle);
}
}
+
+ private void CycleDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/Rig/TestMethods/Endurance/CycleDlg.designer.cs b/TBF/Rig/TestMethods/Endurance/CycleDlg.designer.cs
index a89e77b15..f2b0a1693 100644
--- a/TBF/Rig/TestMethods/Endurance/CycleDlg.designer.cs
+++ b/TBF/Rig/TestMethods/Endurance/CycleDlg.designer.cs
@@ -31,54 +31,55 @@ namespace TBF.Rig.TestMethods.Endurance
///
private void InitializeComponent()
{
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleDlg));
- this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
- this.tabControl = new System.Windows.Forms.TabControl();
- this.sharedButtons = new TBF.UI.Shared.SharedButtons();
- ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
- this.mainSplitContainer.Panel1.SuspendLayout();
- this.mainSplitContainer.Panel2.SuspendLayout();
- this.mainSplitContainer.SuspendLayout();
- this.SuspendLayout();
- //
- // mainSplitContainer
- //
- resources.ApplyResources(this.mainSplitContainer, "mainSplitContainer");
- this.mainSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
- this.mainSplitContainer.Name = "mainSplitContainer";
- //
- // mainSplitContainer.Panel1
- //
- this.mainSplitContainer.Panel1.Controls.Add(this.tabControl);
- //
- // mainSplitContainer.Panel2
- //
- this.mainSplitContainer.Panel2.Controls.Add(this.sharedButtons);
- //
- // tabControl
- //
- resources.ApplyResources(this.tabControl, "tabControl");
- this.tabControl.Name = "tabControl";
- this.tabControl.SelectedIndex = 0;
- this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);
- //
- // sharedButtons
- //
- resources.ApplyResources(this.sharedButtons, "sharedButtons");
- this.sharedButtons.Name = "sharedButtons";
- //
- // CycleDlg
- //
- resources.ApplyResources(this, "$this");
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.mainSplitContainer);
- this.Name = "CycleDlg";
- this.Load += new System.EventHandler(this.CycleDlg_Load);
- this.mainSplitContainer.Panel1.ResumeLayout(false);
- this.mainSplitContainer.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).EndInit();
- this.mainSplitContainer.ResumeLayout(false);
- this.ResumeLayout(false);
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleDlg));
+ this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
+ this.tabControl = new System.Windows.Forms.TabControl();
+ this.sharedButtons = new TBF.UI.Shared.SharedButtons();
+ ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
+ this.mainSplitContainer.Panel1.SuspendLayout();
+ this.mainSplitContainer.Panel2.SuspendLayout();
+ this.mainSplitContainer.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // mainSplitContainer
+ //
+ resources.ApplyResources(this.mainSplitContainer, "mainSplitContainer");
+ this.mainSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+ this.mainSplitContainer.Name = "mainSplitContainer";
+ //
+ // mainSplitContainer.Panel1
+ //
+ this.mainSplitContainer.Panel1.Controls.Add(this.tabControl);
+ //
+ // mainSplitContainer.Panel2
+ //
+ this.mainSplitContainer.Panel2.Controls.Add(this.sharedButtons);
+ //
+ // tabControl
+ //
+ resources.ApplyResources(this.tabControl, "tabControl");
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);
+ //
+ // sharedButtons
+ //
+ resources.ApplyResources(this.sharedButtons, "sharedButtons");
+ this.sharedButtons.Name = "sharedButtons";
+ //
+ // CycleDlg
+ //
+ resources.ApplyResources(this, "$this");
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.mainSplitContainer);
+ this.Name = "CycleDlg";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CycleDlg_FormClosing);
+ this.Load += new System.EventHandler(this.CycleDlg_Load);
+ this.mainSplitContainer.Panel1.ResumeLayout(false);
+ this.mainSplitContainer.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).EndInit();
+ this.mainSplitContainer.ResumeLayout(false);
+ this.ResumeLayout(false);
}
diff --git a/TBF/Rig/TestMethods/Endurance/CycleDlg.resx b/TBF/Rig/TestMethods/Endurance/CycleDlg.resx
index cd69c302b..5a32fe793 100644
--- a/TBF/Rig/TestMethods/Endurance/CycleDlg.resx
+++ b/TBF/Rig/TestMethods/Endurance/CycleDlg.resx
@@ -181,7 +181,7 @@
sharedButtons
- TBF.UiControls.SharedButtons, TBF, Version=2.12.404.1, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Shared.SharedButtons, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
mainSplitContainer.Panel2
diff --git a/TBF/UI/Bench/Components/ComponentParametersDlg.cs b/TBF/UI/Bench/Components/ComponentParametersDlg.cs
index da1fe6ee1..361430564 100644
--- a/TBF/UI/Bench/Components/ComponentParametersDlg.cs
+++ b/TBF/UI/Bench/Components/ComponentParametersDlg.cs
@@ -38,25 +38,31 @@ namespace TBF.UI.Bench.Components
int cmpntEntityId;
+ ComponentParametersDlg()
+ {
+ InitializeComponent();
+ }
+
///
/// Create a window to edit component configuration
///
/// Config.Entities.Component.Id or 0 when this is a new/copied/immported component
- public ComponentParametersDlg(int cmpntEntityId = 0)
+ public ComponentParametersDlg(Form parentForm, int cmpntEntityId = 0)
+ : this()
{
- InitializeComponent();
-
this.cmpntEntityId = cmpntEntityId;
- Flags = CfgUpdateFlags.None;
- /// SharedDlgButtons configuration
- sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists };
+ /// SharedDlgButtons configuration
+ sharedButtons.ParentForm = parentForm;
+ sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists };
sharedButtons.MoreButtonTop = ComponentCfgCtrlHeight - 45;
sharedButtons.OptionalButtons = SharedButtons.Buttons.None;
- sharedButtons.Unlocked += Unlock;
- sharedButtons.OKClicked += okButton_Click;
- sharedButtons.CancelClicked += cancelButton_Click;
- sharedButtons.MoreClicked += moreButton_Click;
+ sharedButtons.Unlocked += Unlock;
+ sharedButtons.OKClicked += okButton_Click;
+ sharedButtons.CancelClicked += cancelButton_Click;
+ sharedButtons.MoreClicked += moreButton_Click;
+
+ Flags = CfgUpdateFlags.None;
}
private void ComponentCfgForm_Load(object sender, EventArgs e)
diff --git a/TBF/UI/Bench/Components/ComponentsManagerDlg.cs b/TBF/UI/Bench/Components/ComponentsManagerDlg.cs
index 37d8a5749..f8a958d7e 100644
--- a/TBF/UI/Bench/Components/ComponentsManagerDlg.cs
+++ b/TBF/UI/Bench/Components/ComponentsManagerDlg.cs
@@ -8,8 +8,8 @@ using System.Windows.Forms;
using log4net;
using NHibernate;
using Common;
-using Config.Entities;
using Common.Forms;
+using Config.Entities;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
@@ -69,7 +69,8 @@ namespace TBF.UI.Bench.Components
selectComponentTypeDlg = new SelectComponentClassDlg();
/// SharedDlgButtons configuration
- sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
+ sharedButtons.ParentForm = this;
+ sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
SharedButtons.Buttons.Remove |
@@ -421,7 +422,7 @@ namespace TBF.UI.Bench.Components
cfgControl.Config = cfg;
cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1;
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
cfgForm.CmpntEntities = cmpntEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
@@ -502,7 +503,7 @@ namespace TBF.UI.Bench.Components
IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(component);
if (cfg != null)
{
- ComponentParametersDlg cfgForm = new ComponentParametersDlg(component.Id);
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this, component.Id);
cfgForm.CmpntEntities = cmpntEntities;
cfgForm.ComponentCfgCtrl = cfg.GetControl(cmpntEntities);
cfgForm.ComponentCfgCtrl.Config = cfg;
@@ -544,7 +545,7 @@ namespace TBF.UI.Bench.Components
cfgControl.Config = cfg;
cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1;
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
cfgForm.CmpntEntities = cmpntEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
@@ -589,7 +590,7 @@ namespace TBF.UI.Bench.Components
cfgControl.Config.Name = cfgControl.Config.Name + " imported";
cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1;
- ComponentParametersDlg cfgForm = new ComponentParametersDlg();
+ ComponentParametersDlg cfgForm = new ComponentParametersDlg(this);
cfgForm.CmpntEntities = cmpntEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
@@ -698,8 +699,10 @@ namespace TBF.UI.Bench.Components
SaveDBChanges(session);
}
}
+
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
}
-
+
///
/// Updates component configuration from a script file
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlg.Designer.cs b/TBF/UI/Bench/Metrology/MetrologyDlg.Designer.cs
index b4cc7be62..03a1aa15b 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlg.Designer.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlg.Designer.cs
@@ -31,66 +31,67 @@ namespace TBF.UI.Bench.Metrology
///
private void InitializeComponent()
{
- this.splitContainer = new System.Windows.Forms.SplitContainer();
- this.metrologyTabControl = new System.Windows.Forms.TabControl();
- this.sharedButtons = new TBF.UI.Shared.SharedButtons();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
- this.splitContainer.Panel1.SuspendLayout();
- this.splitContainer.Panel2.SuspendLayout();
- this.splitContainer.SuspendLayout();
- this.SuspendLayout();
- //
- // splitContainer
- //
- this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
- this.splitContainer.Location = new System.Drawing.Point(0, 0);
- this.splitContainer.Name = "splitContainer";
- //
- // splitContainer.Panel1
- //
- this.splitContainer.Panel1.Controls.Add(this.metrologyTabControl);
- //
- // splitContainer.Panel2
- //
- this.splitContainer.Panel2.Controls.Add(this.sharedButtons);
- this.splitContainer.Size = new System.Drawing.Size(965, 344);
- this.splitContainer.SplitterDistance = 863;
- this.splitContainer.TabIndex = 0;
- //
- // metrologyTabControl
- //
- this.metrologyTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
- this.metrologyTabControl.ItemSize = new System.Drawing.Size(60, 30);
- this.metrologyTabControl.Location = new System.Drawing.Point(0, 0);
- this.metrologyTabControl.Name = "metrologyTabControl";
- this.metrologyTabControl.SelectedIndex = 0;
- this.metrologyTabControl.Size = new System.Drawing.Size(863, 344);
- this.metrologyTabControl.TabIndex = 0;
- this.metrologyTabControl.SelectedIndexChanged += new System.EventHandler(this.metrologyTabControl_SelectedIndexChanged);
- //
- // sharedButtons
- //
- this.sharedButtons.Location = new System.Drawing.Point(-2, 0);
- this.sharedButtons.Name = "sharedButtons";
- this.sharedButtons.Size = new System.Drawing.Size(100, 400);
- this.sharedButtons.TabIndex = 0;
- //
- // MetrologyDlg
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(965, 344);
- this.Controls.Add(this.splitContainer);
- this.Name = "MetrologyDlg";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "Metrology";
- this.Load += new System.EventHandler(this.MetrologyDlg_Load);
- this.splitContainer.Panel1.ResumeLayout(false);
- this.splitContainer.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
- this.splitContainer.ResumeLayout(false);
- this.ResumeLayout(false);
+ this.splitContainer = new System.Windows.Forms.SplitContainer();
+ this.metrologyTabControl = new System.Windows.Forms.TabControl();
+ this.sharedButtons = new TBF.UI.Shared.SharedButtons();
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
+ this.splitContainer.Panel1.SuspendLayout();
+ this.splitContainer.Panel2.SuspendLayout();
+ this.splitContainer.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // splitContainer
+ //
+ this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+ this.splitContainer.Location = new System.Drawing.Point(0, 0);
+ this.splitContainer.Name = "splitContainer";
+ //
+ // splitContainer.Panel1
+ //
+ this.splitContainer.Panel1.Controls.Add(this.metrologyTabControl);
+ //
+ // splitContainer.Panel2
+ //
+ this.splitContainer.Panel2.Controls.Add(this.sharedButtons);
+ this.splitContainer.Size = new System.Drawing.Size(965, 344);
+ this.splitContainer.SplitterDistance = 863;
+ this.splitContainer.TabIndex = 0;
+ //
+ // metrologyTabControl
+ //
+ this.metrologyTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.metrologyTabControl.ItemSize = new System.Drawing.Size(60, 30);
+ this.metrologyTabControl.Location = new System.Drawing.Point(0, 0);
+ this.metrologyTabControl.Name = "metrologyTabControl";
+ this.metrologyTabControl.SelectedIndex = 0;
+ this.metrologyTabControl.Size = new System.Drawing.Size(863, 344);
+ this.metrologyTabControl.TabIndex = 0;
+ this.metrologyTabControl.SelectedIndexChanged += new System.EventHandler(this.metrologyTabControl_SelectedIndexChanged);
+ //
+ // sharedButtons
+ //
+ this.sharedButtons.Location = new System.Drawing.Point(-2, 0);
+ this.sharedButtons.Name = "sharedButtons";
+ this.sharedButtons.Size = new System.Drawing.Size(100, 400);
+ this.sharedButtons.TabIndex = 0;
+ //
+ // MetrologyDlg
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(965, 344);
+ this.Controls.Add(this.splitContainer);
+ this.Name = "MetrologyDlg";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Metrology";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MetrologyDlg_FormClosing);
+ this.Load += new System.EventHandler(this.MetrologyDlg_Load);
+ this.splitContainer.Panel1.ResumeLayout(false);
+ this.splitContainer.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
+ this.splitContainer.ResumeLayout(false);
+ this.ResumeLayout(false);
}
diff --git a/TBF/UI/Bench/Metrology/MetrologyDlg.cs b/TBF/UI/Bench/Metrology/MetrologyDlg.cs
index dc46a1614..bc9896fcf 100644
--- a/TBF/UI/Bench/Metrology/MetrologyDlg.cs
+++ b/TBF/UI/Bench/Metrology/MetrologyDlg.cs
@@ -26,6 +26,7 @@ namespace TBF.UI.Bench.Metrology
InitializeComponent();
/// SharedDlgButtons configuration
+ sharedButtons.ParentForm = this;
sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists, Common.GID.MetrologicalAuthority };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove;
sharedButtons.Unlocked += unlockButton_Click;
@@ -342,5 +343,10 @@ namespace TBF.UI.Bench.Metrology
{
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove);
}
+
+ private void MetrologyDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/Bench/Paths/PathsDlg.Designer.cs b/TBF/UI/Bench/Paths/PathsDlg.Designer.cs
index 6b862410f..f59ad339a 100644
--- a/TBF/UI/Bench/Paths/PathsDlg.Designer.cs
+++ b/TBF/UI/Bench/Paths/PathsDlg.Designer.cs
@@ -162,6 +162,7 @@ namespace TBF.UI.Bench.Paths
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer);
this.Name = "PathsDlg";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PathsDlg_FormClosing);
this.Load += new System.EventHandler(this.PathsDlg_Load);
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
diff --git a/TBF/UI/Bench/Paths/PathsDlg.cs b/TBF/UI/Bench/Paths/PathsDlg.cs
index 3ba81e1ea..f26745f7a 100644
--- a/TBF/UI/Bench/Paths/PathsDlg.cs
+++ b/TBF/UI/Bench/Paths/PathsDlg.cs
@@ -53,7 +53,8 @@ namespace TBF.UI.Bench.Paths
InitializeComponent();
/// SharedDlgButtons configuration
- sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
+ sharedButtons.ParentForm = this;
+ sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove |
SharedButtons.Buttons.Up | SharedButtons.Buttons.Down;
sharedButtons.Unlocked += Unlocked;
@@ -367,5 +368,10 @@ namespace TBF.UI.Bench.Paths
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
+
+ private void PathsDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/Bench/Paths/PathsDlg.resx b/TBF/UI/Bench/Paths/PathsDlg.resx
index 5aaef6997..bd2d26d1e 100644
--- a/TBF/UI/Bench/Paths/PathsDlg.resx
+++ b/TBF/UI/Bench/Paths/PathsDlg.resx
@@ -145,7 +145,7 @@
pathsFeedingCtrl
- TBF.UiControls.PathsFeedingCtrl, TBF, Version=2.8.315.1, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Bench.Paths.PathsFeedingCtrl, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
feedingTabPage
@@ -196,7 +196,7 @@
pathsBenchCtrl
- TBF.UiControls.PathsBenchCtrl, TBF, Version=2.8.315.1, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Bench.Paths.PathsBenchCtrl, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
benchTabPage
@@ -247,7 +247,7 @@
pathsOutputCtrl
- TBF.UiControls.PathsOutputCtrl, TBF, Version=2.8.315.1, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Bench.Paths.PathsOutputCtrl, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
outputTabPage
@@ -298,7 +298,7 @@
pathsMetersCtrl
- TBF.UiControls.PathsMetersCtrl, TBF, Version=2.8.315.1, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Bench.Paths.PathsMetersCtrl, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
metersTabPage
@@ -330,54 +330,6 @@
3
-
- Fill
-
-
- 0, 0
-
-
- 831, 277
-
-
- 0
-
-
- pathsHeatMetersCtrl
-
-
- TBF.UiControls.PathsHeatMetersCtrl, TBF, Version=2.8.315.1, Culture=neutral, PublicKeyToken=null
-
-
- heatMetersTabPage
-
-
- 0
-
-
- 4, 34
-
-
- 831, 277
-
-
- 4
-
-
- Heat meter sensors
-
-
- heatMetersTabPage
-
-
- System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- pathsTabControl
-
-
- 4
-
Fill
@@ -430,7 +382,7 @@
sharedButtons
- TBF.UiControls.SharedButtons, TBF, Version=2.8.315.1, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Shared.SharedButtons, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
splitContainer.Panel2
diff --git a/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs b/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs
index 4acd4011f..43e5bde62 100644
--- a/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs
+++ b/TBF/UI/Bench/TestProfiles/TestProfileDlg.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2019 Sensus Slovensko a.s.
+/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -42,28 +42,40 @@ namespace TBF.UI.Bench.TestProfiles
bool unlocked;
- public TestProfileDlg()
+ TestProfileDlg()
{
- /// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi.
+ InitializeComponent();
+
+ /// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi.
Dpi = (int)this.CreateGraphics().DpiX;
openUnlocked = false;
+ }
- InitializeComponent();
+ public TestProfileDlg(Profile profile, IList usedNames, bool openUnlocked, Form parentForm)
+ : this()
+ {
+ if (profile == null) throw new ArgumentNullException("profile");
+
+ LoadedProfile = profile;
+ this.usedNames = usedNames;
+ this.openUnlocked = openUnlocked;
/// SharedDlgButtons configuration
+ sharedButtons.ParentForm = parentForm;
sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.MetrologicalAuthority };
-
- sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove |
- SharedButtons.Buttons.Up | SharedButtons.Buttons.Down;
+ sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
+ SharedButtons.Buttons.Remove |
+ SharedButtons.Buttons.Up |
+ SharedButtons.Buttons.Down;
sharedButtons.Unlocked += Unlocked;
- sharedButtons.OKClicked += okButton_Click;
- sharedButtons.CancelClicked += cancelButton_Click;
- sharedButtons.AddClicked += addButton_Click;
- sharedButtons.RemoveClicked += removeButton_Click;
- sharedButtons.UpClicked += upButton_Click;
- sharedButtons.DownClicked += downButton_Click;
+ sharedButtons.OKClicked += okButton_Click;
+ sharedButtons.CancelClicked += cancelButton_Click;
+ sharedButtons.AddClicked += addButton_Click;
+ sharedButtons.RemoveClicked += removeButton_Click;
+ sharedButtons.UpClicked += upButton_Click;
+ sharedButtons.DownClicked += downButton_Click;
- /// ListViewEx-es configuration
+ /// ListViewEx-es configuration
metrologyListViewEx.SubItemClicked += new SubItemEventHandler(metrologyListViewEx_SubItemClicked);
metrologyListViewEx.SubItemRightClicked += new SubItemEventHandler(metrologyListViewEx_SubItemRightClicked);
metrologyListViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(metrologyListViewEx_SubItemEndEditing);
@@ -77,19 +89,7 @@ namespace TBF.UI.Bench.TestProfiles
errorFlags2ListViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(errorFlags2ListViewEx_SubItemEndEditing);
SelectedTestIx = -1;
- }
-
- public TestProfileDlg(Config.Entities.Profile profile, IList usedNames, bool openUnlocked = false)
- : this()
- {
- if (profile == null) throw new ArgumentNullException("profile");
-
- LoadedProfile = profile;
- this.usedNames = usedNames;
- this.openUnlocked = openUnlocked;
-
- sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.MetrologicalAuthority };
- }
+ }
private void TestProfileDlg_Load(object sender, EventArgs e)
{
diff --git a/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx b/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx
index 50cc9f78a..c8a4a70b2 100644
--- a/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx
+++ b/TBF/UI/Bench/TestProfiles/TestProfileDlg.resx
@@ -745,7 +745,7 @@
metrologyListViewEx
- Results.Forms.ListViewEx, Results, Version=2.24.1369.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
metrologyTabPage
@@ -796,7 +796,7 @@
errorFlagsListViewEx
- Results.Forms.ListViewEx, Results, Version=2.24.1369.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
errorFlagsTabPage
@@ -844,7 +844,7 @@
errorFlags2ListViewEx
- Results.Forms.ListViewEx, Results, Version=2.24.1369.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
errorFlags2TabPage
@@ -928,7 +928,7 @@
sharedButtons
- TBF.UI.Shared.SharedButtons, TBF, Version=2.24.1372.0, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Shared.SharedButtons, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
mainSplitContainer.Panel2
diff --git a/TBF/UI/Bench/TestProfiles/TestProfilesCtrl.cs b/TBF/UI/Bench/TestProfiles/TestProfilesCtrl.cs
index 419d012ff..22692b032 100644
--- a/TBF/UI/Bench/TestProfiles/TestProfilesCtrl.cs
+++ b/TBF/UI/Bench/TestProfiles/TestProfilesCtrl.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2019 Sensus Slovensko a.s.
+/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -214,10 +214,10 @@ namespace TBF.UI.Bench.TestProfiles
}
Profile newProfile = new Profile(newName, MyItems.Count);
- newProfile.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProfile.CreationUser = Users.CurrentUser.UserName();
newProfile.CreationTime = DateTime.Now;
- if (new TestProfileDlg(newProfile, GetUsedNames(false), true).ShowDialog() == DialogResult.OK)
+ if (new TestProfileDlg(newProfile, GetUsedNames(false), true, parent).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
@@ -226,7 +226,7 @@ namespace TBF.UI.Bench.TestProfiles
{
try
{
- newProfile.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProfile.LastChgUser = Users.CurrentUser.UserName();
newProfile.LastChgTime = DateTime.Now;
base.AddOne(newProfile);
@@ -297,7 +297,7 @@ namespace TBF.UI.Bench.TestProfiles
IList usedNames = GetUsedNames(false);
usedNames.Remove(editedProfile.Name.ToLower()); /// Allow original procedure name
///
- if (new TestProfileDlg(editedProfile, usedNames).ShowDialog() == DialogResult.OK)
+ if (new TestProfileDlg(editedProfile, usedNames, false, parent).ShowDialog() == DialogResult.OK)
{
parent.Unlock();
@@ -305,7 +305,7 @@ namespace TBF.UI.Bench.TestProfiles
{
try
{
- editedProfile.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ editedProfile.LastChgUser = Users.CurrentUser.UserName();
editedProfile.LastChgTime = DateTime.Now;
session.SaveOrUpdate(editedProfile);
@@ -339,17 +339,17 @@ namespace TBF.UI.Bench.TestProfiles
newProfile.Name = selectedProfile.Name + Strings.New_name_copy;
newProfile.ItemNr = MyItems.Count;
- newProfile.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProfile.CreationUser = Users.CurrentUser.UserName();
newProfile.CreationTime = DateTime.Now;
- if ((new TestProfileDlg(newProfile, GetUsedNames(false), true)).ShowDialog() == DialogResult.OK)
+ if ((new TestProfileDlg(newProfile, GetUsedNames(false), true, parent)).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
using (var transaction = session.BeginTransaction())
{
- newProfile.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProfile.LastChgUser = Users.CurrentUser.UserName();
newProfile.LastChgTime = DateTime.Now;
base.AddOne(newProfile);
@@ -388,17 +388,17 @@ namespace TBF.UI.Bench.TestProfiles
newProfile.Name = newProfile.Name + " imported";
newProfile.ItemNr = MyItems.Count;
- newProfile.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProfile.CreationUser = Users.CurrentUser.UserName();
newProfile.CreationTime = DateTime.Now;
- if ((new TestProfileDlg(newProfile, GetUsedNames(false), true)).ShowDialog() == DialogResult.OK)
+ if ((new TestProfileDlg(newProfile, GetUsedNames(false), true, parent)).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
using (var transaction = session.BeginTransaction())
{
- newProfile.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProfile.LastChgUser = Users.CurrentUser.UserName();
newProfile.LastChgTime = DateTime.Now;
base.AddOne(newProfile);
diff --git a/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs b/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs
index 8f813ebca..69a93262d 100644
--- a/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs
+++ b/TBF/UI/Bench/TestProfiles/TestProfilesDlg.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
+using Common;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;
@@ -26,7 +27,8 @@ namespace TBF.UI.Bench.TestProfiles
InitializeComponent();
/// SharedDlgButtons configuration
- sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.MetrologicalAuthority };
+ sharedButtons.ParentForm = this;
+ sharedButtons.RequiredGroupMembership = new GID[] { GID.MetrologicalAuthority };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove |
SharedButtons.Buttons.Up | SharedButtons.Buttons.Down |
@@ -218,5 +220,10 @@ namespace TBF.UI.Bench.TestProfiles
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
+
+ private void TestProfilesDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/Bench/TestProfiles/TestProfilesDlg.designer.cs b/TBF/UI/Bench/TestProfiles/TestProfilesDlg.designer.cs
index ed349e73e..ad56aad2b 100644
--- a/TBF/UI/Bench/TestProfiles/TestProfilesDlg.designer.cs
+++ b/TBF/UI/Bench/TestProfiles/TestProfilesDlg.designer.cs
@@ -88,6 +88,7 @@ namespace TBF.UI.Bench.TestProfiles
this.Name = "TestProfilesDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "TestProfilesDlg";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TestProfilesDlg_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ProceduresDlg_FormClosed);
this.Load += new System.EventHandler(this.TestProfilesDlg_Load);
this.splitContainer.Panel1.ResumeLayout(false);
diff --git a/TBF/UI/Bench/Transitions/TransitionsDlg.Designer.cs b/TBF/UI/Bench/Transitions/TransitionsDlg.Designer.cs
index 8bd3acd5d..e837f3d73 100644
--- a/TBF/UI/Bench/Transitions/TransitionsDlg.Designer.cs
+++ b/TBF/UI/Bench/Transitions/TransitionsDlg.Designer.cs
@@ -31,54 +31,55 @@ namespace TBF.UI.Bench.Transitions
///
private void InitializeComponent()
{
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TransitionsDlg));
- this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
- this.tabControl = new System.Windows.Forms.TabControl();
- this.sharedButtons = new TBF.UI.Shared.SharedButtons();
- ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
- this.mainSplitContainer.Panel1.SuspendLayout();
- this.mainSplitContainer.Panel2.SuspendLayout();
- this.mainSplitContainer.SuspendLayout();
- this.SuspendLayout();
- //
- // mainSplitContainer
- //
- resources.ApplyResources(this.mainSplitContainer, "mainSplitContainer");
- this.mainSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
- this.mainSplitContainer.Name = "mainSplitContainer";
- //
- // mainSplitContainer.Panel1
- //
- this.mainSplitContainer.Panel1.Controls.Add(this.tabControl);
- //
- // mainSplitContainer.Panel2
- //
- this.mainSplitContainer.Panel2.Controls.Add(this.sharedButtons);
- //
- // tabControl
- //
- resources.ApplyResources(this.tabControl, "tabControl");
- this.tabControl.Name = "tabControl";
- this.tabControl.SelectedIndex = 0;
- this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);
- //
- // sharedButtons
- //
- resources.ApplyResources(this.sharedButtons, "sharedButtons");
- this.sharedButtons.Name = "sharedButtons";
- //
- // TransitionsDlg
- //
- resources.ApplyResources(this, "$this");
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.mainSplitContainer);
- this.Name = "TransitionsDlg";
- this.Load += new System.EventHandler(this.TransitionsDlg_Load);
- this.mainSplitContainer.Panel1.ResumeLayout(false);
- this.mainSplitContainer.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).EndInit();
- this.mainSplitContainer.ResumeLayout(false);
- this.ResumeLayout(false);
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TransitionsDlg));
+ this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
+ this.tabControl = new System.Windows.Forms.TabControl();
+ this.sharedButtons = new TBF.UI.Shared.SharedButtons();
+ ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
+ this.mainSplitContainer.Panel1.SuspendLayout();
+ this.mainSplitContainer.Panel2.SuspendLayout();
+ this.mainSplitContainer.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // mainSplitContainer
+ //
+ resources.ApplyResources(this.mainSplitContainer, "mainSplitContainer");
+ this.mainSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+ this.mainSplitContainer.Name = "mainSplitContainer";
+ //
+ // mainSplitContainer.Panel1
+ //
+ this.mainSplitContainer.Panel1.Controls.Add(this.tabControl);
+ //
+ // mainSplitContainer.Panel2
+ //
+ this.mainSplitContainer.Panel2.Controls.Add(this.sharedButtons);
+ //
+ // tabControl
+ //
+ resources.ApplyResources(this.tabControl, "tabControl");
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);
+ //
+ // sharedButtons
+ //
+ resources.ApplyResources(this.sharedButtons, "sharedButtons");
+ this.sharedButtons.Name = "sharedButtons";
+ //
+ // TransitionsDlg
+ //
+ resources.ApplyResources(this, "$this");
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.mainSplitContainer);
+ this.Name = "TransitionsDlg";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TransitionsDlg_FormClosing);
+ this.Load += new System.EventHandler(this.TransitionsDlg_Load);
+ this.mainSplitContainer.Panel1.ResumeLayout(false);
+ this.mainSplitContainer.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).EndInit();
+ this.mainSplitContainer.ResumeLayout(false);
+ this.ResumeLayout(false);
}
diff --git a/TBF/UI/Bench/Transitions/TransitionsDlg.cs b/TBF/UI/Bench/Transitions/TransitionsDlg.cs
index e3aa265f0..c99ae78cd 100644
--- a/TBF/UI/Bench/Transitions/TransitionsDlg.cs
+++ b/TBF/UI/Bench/Transitions/TransitionsDlg.cs
@@ -67,7 +67,8 @@ namespace TBF.UI.Bench.Transitions
InitializeComponent();
/// SharedDlgButtons configuration
- sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
+ sharedButtons.ParentForm = this;
+ sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove |
SharedButtons.Buttons.Up | SharedButtons.Buttons.Down |
SharedButtons.Buttons.Export | SharedButtons.Buttons.Import |
@@ -701,5 +702,10 @@ namespace TBF.UI.Bench.Transitions
{
MessageBox.Show("Comparing sequences in not implemented yet");
}
+
+ private void TransitionsDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/Bench/Transitions/TransitionsDlg.resx b/TBF/UI/Bench/Transitions/TransitionsDlg.resx
index f2190cf21..a3e1f036a 100644
--- a/TBF/UI/Bench/Transitions/TransitionsDlg.resx
+++ b/TBF/UI/Bench/Transitions/TransitionsDlg.resx
@@ -181,7 +181,7 @@
sharedButtons
- TBF.UiControls.SharedButtons, TBF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Shared.SharedButtons, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
mainSplitContainer.Panel2
@@ -231,9 +231,6 @@
863, 366
-
- NoControl
-
CenterParent
diff --git a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs
index c64a4be66..178f9e3e6 100644
--- a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs
+++ b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.cs
@@ -26,6 +26,7 @@ namespace TBF.UI.Bench.Uncertainties
InitializeComponent();
/// SharedDlgButtons configuration
+ sharedButtons.ParentForm = this;
#if KEMPNO_50
sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.MetrologicalAuthority };
#else
@@ -305,5 +306,10 @@ namespace TBF.UI.Bench.Uncertainties
{
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove);
}
+
+ private void UncertaintiesDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs
index 5271641a5..0d94ae562 100644
--- a/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs
+++ b/TBF/UI/Bench/Uncertainties/UncertaintiesDlg.designer.cs
@@ -85,6 +85,7 @@ namespace TBF.UI.Bench.Uncertainties
this.Name = "UncertaintiesDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Uncertainty";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UncertaintiesDlg_FormClosing);
this.Load += new System.EventHandler(this.UncertaintiesDlg_Load);
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
diff --git a/TBF/UI/MainWnd.cs b/TBF/UI/MainWnd.cs
index 22e33157d..4e7e792af 100644
--- a/TBF/UI/MainWnd.cs
+++ b/TBF/UI/MainWnd.cs
@@ -457,23 +457,23 @@ namespace TBF.UI
public void UpdateUser()
{
- userInfoStatusLabel.Text = string.Format("{0}: {1}{2}, ", Strings.User, Users.GlobalData.CurrentUser.UserName,
- (Users.GlobalData.AuthorizedAs == Common.AuthorizedAs.PowerUser) ? "(S)" :
- ((Users.GlobalData.AuthorizedAs == Common.AuthorizedAs.LocalUser) ? "(L)" : "(R)"));
+ userInfoStatusLabel.Text = string.Format("{0}: {1}{2}, ", Strings.User, Users.CurrentUser.UserName(),
+ (Users.CurrentUser.AuthorizedAs == Common.AuthorizedAs.PowerUser) ? "(S)" :
+ ((Users.CurrentUser.AuthorizedAs == Common.AuthorizedAs.LocalUser) ? "(L)" : "(R)"));
UpdateMenuItemsVisibility();
}
void UpdateMenuItemsVisibility()
{
- usersTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.Administrators) ||
- Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.HeadOfLab);
- databaseSettingsTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.Administrators) && Users.GlobalData.CurrentUser.IsPowerUser(); ;
- upgradeTSMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.Administrators) && Users.GlobalData.CurrentUser.IsPowerUser();
- clearCountersToolStripMenuItem.Visible = Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.Administrators) ||
- Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.HeadOfLab) ||
- Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.TestingSpecialists) ||
- Users.GlobalData.CurrentUser.IsMemberOf(Common.GID.Metrologists);
+ usersTSMenuItem.Visible = Users.CurrentUser.IsMemberOf(Common.GID.Administrators) ||
+ Users.CurrentUser.IsMemberOf(Common.GID.HeadOfLab);
+ databaseSettingsTSMenuItem.Visible = Users.CurrentUser.IsMemberOf(Common.GID.Administrators) && Users.CurrentUser.IsPowerUser();
+ upgradeTSMenuItem.Visible = Users.CurrentUser.IsMemberOf(Common.GID.Administrators) && Users.CurrentUser.IsPowerUser();
+ clearCountersToolStripMenuItem.Visible = Users.CurrentUser.IsMemberOf(Common.GID.Administrators) ||
+ Users.CurrentUser.IsMemberOf(Common.GID.HeadOfLab) ||
+ Users.CurrentUser.IsMemberOf(Common.GID.TestingSpecialists) ||
+ Users.CurrentUser.IsMemberOf(Common.GID.Metrologists);
}
public void UpdateStatusP(string statusPStr)
@@ -541,7 +541,7 @@ namespace TBF.UI
}
private void backUpConfigTSMItem_Click(object s, EventArgs e) { BackupConfiguration(); }
private void backUpResultsTSMItem_Click(object s, EventArgs e) { BackupResults(); }
- private void passwdTSMItem_Click(object s, EventArgs e) { new Users.Forms.PasswordChangeDlg(Users.GlobalData.GetCurrentUserName()).ShowDialog(); }
+ private void passwdTSMItem_Click(object s, EventArgs e) { new Users.Forms.PasswordChangeDlg(Users.CurrentUser.UserName()).ShowDialog(); }
private void aboutTSMItem_Click(object s, EventArgs e) { new TBF.UI.Help.AboutDlg().ShowDialog(); }
@@ -838,7 +838,7 @@ namespace TBF.UI
Common.GID[] reqGrpMembership = null;
#endif
- if (new Users.Forms.LoginDlg(reqGrpMembership).ShowDialog() == DialogResult.OK)
+ if (new Users.Forms.LoginDlg(reqGrpMembership, this).ShowDialog() == DialogResult.OK)
{
UpdateUser();
}
diff --git a/TBF/UI/Procedures/ProcedureDlg.Designer.cs b/TBF/UI/Procedures/ProcedureDlg.Designer.cs
index f8602a057..1824573d1 100644
--- a/TBF/UI/Procedures/ProcedureDlg.Designer.cs
+++ b/TBF/UI/Procedures/ProcedureDlg.Designer.cs
@@ -97,14 +97,14 @@ namespace TBF.UI.Procedures
this.procNameTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.historyTabPage = new System.Windows.Forms.TabPage();
- this.metrology1TabPage = new System.Windows.Forms.TabPage();
- this.metrology2TabPage = new System.Windows.Forms.TabPage();
- this.processTabPage = new System.Windows.Forms.TabPage();
- this.parametersTabPage = new System.Windows.Forms.TabPage();
this.historyListViewEx = new Common.Forms.ListViewEx();
+ this.metrology1TabPage = new System.Windows.Forms.TabPage();
this.metrology1ListViewEx = new Common.Forms.ListViewEx();
+ this.metrology2TabPage = new System.Windows.Forms.TabPage();
this.metrology2ListViewEx = new Common.Forms.ListViewEx();
+ this.processTabPage = new System.Windows.Forms.TabPage();
this.processListViewEx = new Common.Forms.ListViewEx();
+ this.parametersTabPage = new System.Windows.Forms.TabPage();
this.parametersListViewEx = new Common.Forms.ListViewEx();
this.sharedButtons = new TBF.UI.Shared.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
@@ -587,34 +587,6 @@ namespace TBF.UI.Procedures
this.historyTabPage.Name = "historyTabPage";
this.historyTabPage.UseVisualStyleBackColor = true;
//
- // metrology1TabPage
- //
- this.metrology1TabPage.Controls.Add(this.metrology1ListViewEx);
- resources.ApplyResources(this.metrology1TabPage, "metrology1TabPage");
- this.metrology1TabPage.Name = "metrology1TabPage";
- this.metrology1TabPage.UseVisualStyleBackColor = true;
- //
- // metrology2TabPage
- //
- this.metrology2TabPage.Controls.Add(this.metrology2ListViewEx);
- resources.ApplyResources(this.metrology2TabPage, "metrology2TabPage");
- this.metrology2TabPage.Name = "metrology2TabPage";
- this.metrology2TabPage.UseVisualStyleBackColor = true;
- //
- // processTabPage
- //
- this.processTabPage.Controls.Add(this.processListViewEx);
- resources.ApplyResources(this.processTabPage, "processTabPage");
- this.processTabPage.Name = "processTabPage";
- this.processTabPage.UseVisualStyleBackColor = true;
- //
- // parametersTabPage
- //
- this.parametersTabPage.Controls.Add(this.parametersListViewEx);
- resources.ApplyResources(this.parametersTabPage, "parametersTabPage");
- this.parametersTabPage.Name = "parametersTabPage";
- this.parametersTabPage.UseVisualStyleBackColor = true;
- //
// historyListViewEx
//
this.historyListViewEx.AllowColumnReorder = true;
@@ -627,6 +599,13 @@ namespace TBF.UI.Procedures
this.historyListViewEx.View = System.Windows.Forms.View.Details;
this.historyListViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.historyListViewEx_MouseDoubleClick);
//
+ // metrology1TabPage
+ //
+ this.metrology1TabPage.Controls.Add(this.metrology1ListViewEx);
+ resources.ApplyResources(this.metrology1TabPage, "metrology1TabPage");
+ this.metrology1TabPage.Name = "metrology1TabPage";
+ this.metrology1TabPage.UseVisualStyleBackColor = true;
+ //
// metrology1ListViewEx
//
this.metrology1ListViewEx.AllowColumnReorder = true;
@@ -639,6 +618,13 @@ namespace TBF.UI.Procedures
this.metrology1ListViewEx.View = System.Windows.Forms.View.Details;
this.metrology1ListViewEx.SelectedIndexChanged += new System.EventHandler(this.metrology1ListViewEx_SelectedIndexChanged);
//
+ // metrology2TabPage
+ //
+ this.metrology2TabPage.Controls.Add(this.metrology2ListViewEx);
+ resources.ApplyResources(this.metrology2TabPage, "metrology2TabPage");
+ this.metrology2TabPage.Name = "metrology2TabPage";
+ this.metrology2TabPage.UseVisualStyleBackColor = true;
+ //
// metrology2ListViewEx
//
this.metrology2ListViewEx.AllowColumnReorder = true;
@@ -651,6 +637,13 @@ namespace TBF.UI.Procedures
this.metrology2ListViewEx.View = System.Windows.Forms.View.Details;
this.metrology2ListViewEx.SelectedIndexChanged += new System.EventHandler(this.metrology2ListViewEx_SelectedIndexChanged);
//
+ // processTabPage
+ //
+ this.processTabPage.Controls.Add(this.processListViewEx);
+ resources.ApplyResources(this.processTabPage, "processTabPage");
+ this.processTabPage.Name = "processTabPage";
+ this.processTabPage.UseVisualStyleBackColor = true;
+ //
// processListViewEx
//
this.processListViewEx.AllowColumnReorder = true;
@@ -663,6 +656,13 @@ namespace TBF.UI.Procedures
this.processListViewEx.View = System.Windows.Forms.View.Details;
this.processListViewEx.SelectedIndexChanged += new System.EventHandler(this.processListViewEx_SelectedIndexChanged);
//
+ // parametersTabPage
+ //
+ this.parametersTabPage.Controls.Add(this.parametersListViewEx);
+ resources.ApplyResources(this.parametersTabPage, "parametersTabPage");
+ this.parametersTabPage.Name = "parametersTabPage";
+ this.parametersTabPage.UseVisualStyleBackColor = true;
+ //
// parametersListViewEx
//
this.parametersListViewEx.AllowColumnReorder = true;
diff --git a/TBF/UI/Procedures/ProcedureDlg.cs b/TBF/UI/Procedures/ProcedureDlg.cs
index 9faedb98b..ebcc89caf 100644
--- a/TBF/UI/Procedures/ProcedureDlg.cs
+++ b/TBF/UI/Procedures/ProcedureDlg.cs
@@ -8,8 +8,8 @@ using System.Text;
using System.Windows.Forms;
using log4net;
using Common;
-using Config.Entities;
using Common.Forms;
+using Config.Entities;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Resources;
@@ -65,7 +65,7 @@ namespace TBF.UI.Procedures
bool unlocked;
- public ProcedureDlg()
+ ProcedureDlg()
{
/// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi.
Dpi = (int)this.CreateGraphics().DpiX;
@@ -74,12 +74,6 @@ namespace TBF.UI.Procedures
InitializeComponent();
/// SharedDlgButtons configuration
-#if KEMPNO_50 || KRAKOW_50
- sharedButtons.RequiredGroupMembership = new GID[] { GID.TestingSpecialists, GID.WaterMeterAuthority };
-#else
- sharedButtons.RequiredGroupMembership = new GID[] { GID.TestingSpecialists, GID.Metrologists };
-#endif
-
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
SharedButtons.Buttons.Remove |
SharedButtons.Buttons.Up |
@@ -120,7 +114,7 @@ namespace TBF.UI.Procedures
SelectedTestIx = -1;
}
- public ProcedureDlg(Config.Entities.Procedure procedure, IList usedNames, Mode initialMode)
+ public ProcedureDlg(Procedure procedure, IList usedNames, Mode initialMode, Form parentForm)
: this()
{
if (procedure == null) throw new ArgumentNullException("procedure");
@@ -129,6 +123,9 @@ namespace TBF.UI.Procedures
this.usedNames = usedNames;
this.initialMode = initialMode;
+ /// Dynamic SharedDlgButtons configuration
+ sharedButtons.ParentForm = parentForm;
+
#if KEMPNO_50 || KRAKOW_50
sharedButtons.RequiredGroupMembership = procedure.Protected ? new GID[] { GID.WaterMeterAuthority }
: new GID[] { GID.TestingSpecialists, GID.WaterMeterAuthority };
@@ -2125,7 +2122,7 @@ namespace TBF.UI.Procedures
procNameTextBox.Enabled = true;
descriptionTextBox.Enabled = true;
watermetersTextBox.Enabled = true;
- protectedCheckBox.Enabled = Users.GlobalData.CurrentUser.IsMemberOf(GID.Metrologists);
+ protectedCheckBox.Enabled = Users.CurrentUser.IsMemberOf(GID.Metrologists);
mustBeCompleteCheckBox.Enabled = true;
manualControlDisabledCheckBox.Enabled = true;
dataEntryComboBox.Enabled = true;
@@ -2848,7 +2845,7 @@ namespace TBF.UI.Procedures
/// Loaded procedure
/// Selected sensors path
/// ROI data
- void AddProcedureParamsToRoiComponents(Config.Entities.Procedure procedure, string sensorsPathName, TestWizard.RoiData roiData)
+ void AddProcedureParamsToRoiComponents(Procedure procedure, string sensorsPathName, TestWizard.RoiData roiData)
{
IList cmpntsInSensPath = new List();
@@ -3078,7 +3075,7 @@ namespace TBF.UI.Procedures
if (lvi.Tag is Procedure)
{
- (new ProcedureDlg(lvi.Tag as Procedure, new List(), ProcedureDlg.Mode.PermanentlyLocked)).ShowDialog();
+ (new ProcedureDlg(lvi.Tag as Procedure, new List(), ProcedureDlg.Mode.PermanentlyLocked, sharedButtons.ParentForm)).ShowDialog();
}
}
diff --git a/TBF/UI/Procedures/ProcedureDlg.resx b/TBF/UI/Procedures/ProcedureDlg.resx
index 7c16b71b0..0878d8839 100644
--- a/TBF/UI/Procedures/ProcedureDlg.resx
+++ b/TBF/UI/Procedures/ProcedureDlg.resx
@@ -1882,7 +1882,7 @@
historyListViewEx
- Results.Forms.ListViewEx, Results, Version=2.26.1622.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
historyTabPage
@@ -1933,7 +1933,7 @@
metrology1ListViewEx
- Results.Forms.ListViewEx, Results, Version=2.26.1622.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
metrology1TabPage
@@ -1984,7 +1984,7 @@
metrology2ListViewEx
- Results.Forms.ListViewEx, Results, Version=2.26.1622.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
metrology2TabPage
@@ -2035,7 +2035,7 @@
processListViewEx
- Results.Forms.ListViewEx, Results, Version=2.26.1622.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
processTabPage
@@ -2086,7 +2086,7 @@
parametersListViewEx
- Results.Forms.ListViewEx, Results, Version=2.26.1622.0, Culture=neutral, PublicKeyToken=null
+ Common.Forms.ListViewEx, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
parametersTabPage
@@ -2170,7 +2170,7 @@
sharedButtons
- TBF.UI.Shared.SharedButtons, TBF, Version=2.26.1636.0, Culture=neutral, PublicKeyToken=null
+ TBF.UI.Shared.SharedButtons, TBF, Version=2.27.1917.0, Culture=neutral, PublicKeyToken=null
mainSplitContainer.Panel2
@@ -2220,9 +2220,6 @@
1034, 471
-
- NoControl
-
CenterParent
diff --git a/TBF/UI/Procedures/ProceduresCtrl.cs b/TBF/UI/Procedures/ProceduresCtrl.cs
index 980801206..dae5d08ea 100644
--- a/TBF/UI/Procedures/ProceduresCtrl.cs
+++ b/TBF/UI/Procedures/ProceduresCtrl.cs
@@ -301,10 +301,10 @@ namespace TBF.UI.Procedures
newProcedure.Revision = 1;
newProcedure.PredecessorId = 0;
newProcedure.ObtainedByCopy = false;
- newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.CreationUser = Users.CurrentUser.UserName();
newProcedure.CreationTime = DateTime.Now;
- if (new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked).ShowDialog() == DialogResult.OK)
+ if (new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked, parent).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
@@ -313,7 +313,7 @@ namespace TBF.UI.Procedures
{
try
{
- newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.LastChgUser = Users.CurrentUser.UserName();
newProcedure.LastChgTime = DateTime.Now;
DoAddOne(newProcedure);
@@ -539,7 +539,7 @@ namespace TBF.UI.Procedures
IList usedNames = GetUsedNames(false);
usedNames.Remove(originalProcedure.Name.ToLower()); /// Allow original procedure name
///
- if (new ProcedureDlg(modifiedProcedure, usedNames, ProcedureDlg.Mode.Locked).ShowDialog() == DialogResult.OK)
+ if (new ProcedureDlg(modifiedProcedure, usedNames, ProcedureDlg.Mode.Locked, parent).ShowDialog() == DialogResult.OK)
{
parent.Unlock();
@@ -548,7 +548,7 @@ namespace TBF.UI.Procedures
try
{
originalProcedure.ProcedureState = ProcedureState.History;
- modifiedProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ modifiedProcedure.LastChgUser = Users.CurrentUser.UserName();
modifiedProcedure.LastChgTime = DateTime.Now;
session.SaveOrUpdate(originalProcedure);
@@ -588,18 +588,18 @@ namespace TBF.UI.Procedures
newProcedure.Revision = 1;
newProcedure.PredecessorId = selectedProcedure.Id;
newProcedure.ObtainedByCopy = true;
- newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.CreationUser = Users.CurrentUser.UserName();
newProcedure.CreationTime = DateTime.Now;
newProcedure.Protected = false;
- if ((new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked)).ShowDialog() == DialogResult.OK)
+ if ((new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked, parent)).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
using (var transaction = session.BeginTransaction())
{
- newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.LastChgUser = Users.CurrentUser.UserName();
newProcedure.LastChgTime = DateTime.Now;
DoAddOne(newProcedure);
@@ -642,17 +642,17 @@ namespace TBF.UI.Procedures
newProcedure.Revision = 1;
newProcedure.PredecessorId = 0;
newProcedure.ObtainedByCopy = false;
- newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.CreationUser = Users.CurrentUser.UserName();
newProcedure.CreationTime = DateTime.Now;
- if ((new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked)).ShowDialog() == DialogResult.OK)
+ if ((new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked, parent)).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
using (var transaction = session.BeginTransaction())
{
- newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.LastChgUser = Users.CurrentUser.UserName();
newProcedure.LastChgTime = DateTime.Now;
DoAddOne(newProcedure);
@@ -860,10 +860,10 @@ namespace TBF.UI.Procedures
newProcedure.Revision = 1;
newProcedure.PredecessorId = 0;
newProcedure.ObtainedByCopy = false;
- newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.CreationUser = Users.CurrentUser.UserName();
newProcedure.CreationTime = DateTime.Now;
- if (new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked).ShowDialog() == DialogResult.OK)
+ if (new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked, parent).ShowDialog() == DialogResult.OK)
{
/// TODO: Make name uniqueness test
parent.Unlock();
@@ -872,7 +872,7 @@ namespace TBF.UI.Procedures
{
try
{
- newProcedure.LastChgUser = Users.GlobalData.CurrentUser.UserName;
+ newProcedure.LastChgUser = Users.CurrentUser.UserName();
newProcedure.LastChgTime = DateTime.Now;
DoAddOne(newProcedure);
diff --git a/TBF/UI/Procedures/ProceduresDlg.Designer.cs b/TBF/UI/Procedures/ProceduresDlg.Designer.cs
index 3f12e0835..9f6d2e43c 100644
--- a/TBF/UI/Procedures/ProceduresDlg.Designer.cs
+++ b/TBF/UI/Procedures/ProceduresDlg.Designer.cs
@@ -32,7 +32,7 @@ namespace TBF.UI.Procedures
private void InitializeComponent()
{
this.splitContainer = new System.Windows.Forms.SplitContainer();
- this.proceduresCtrl = new ProceduresCtrl();
+ this.proceduresCtrl = new TBF.UI.Procedures.ProceduresCtrl();
this.sharedButtons = new TBF.UI.Shared.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
@@ -63,7 +63,7 @@ namespace TBF.UI.Procedures
this.proceduresCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.proceduresCtrl.Location = new System.Drawing.Point(0, 0);
this.proceduresCtrl.Name = "proceduresCtrl";
- this.proceduresCtrl.Size = new System.Drawing.Size(412, 402);
+ this.proceduresCtrl.Size = new System.Drawing.Size(606, 402);
this.proceduresCtrl.TabIndex = 0;
//
// sharedButtons
@@ -82,6 +82,7 @@ namespace TBF.UI.Procedures
this.Name = "ProceduresDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "ProceduresDlg";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProceduresDlg_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ProceduresDlg_FormClosed);
this.Load += new System.EventHandler(this.ProceduresDlg_Load);
this.splitContainer.Panel1.ResumeLayout(false);
diff --git a/TBF/UI/Procedures/ProceduresDlg.cs b/TBF/UI/Procedures/ProceduresDlg.cs
index 5ec472974..73a50d502 100644
--- a/TBF/UI/Procedures/ProceduresDlg.cs
+++ b/TBF/UI/Procedures/ProceduresDlg.cs
@@ -26,6 +26,7 @@ namespace TBF.UI.Procedures
InitializeComponent();
/// SharedDlgButtons configuration
+ sharedButtons.ParentForm = this;
sharedButtons.RequiredGroupMembership = new GID[] { GID.TestingSpecialists, GID.Metrologists };
#if TEST_PROFILES
@@ -253,5 +254,10 @@ namespace TBF.UI.Procedures
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
+
+ private void ProceduresDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/ResultsMI/DeleteFromOracleForm.Designer.cs b/TBF/UI/ResultsMI/DeleteFromOracleForm.Designer.cs
index 18204e733..d22178782 100644
--- a/TBF/UI/ResultsMI/DeleteFromOracleForm.Designer.cs
+++ b/TBF/UI/ResultsMI/DeleteFromOracleForm.Designer.cs
@@ -29,9 +29,9 @@
private void InitializeComponent()
{
this.selectWhatToDeleteGroupBox = new System.Windows.Forms.GroupBox();
- this.waterMetersTextBox = new System.Windows.Forms.TextBox();
this.waterMetersRadioButton = new System.Windows.Forms.RadioButton();
this.batchRadioButton = new System.Windows.Forms.RadioButton();
+ this.waterMetersTextBox = new System.Windows.Forms.TextBox();
this.startButton = new System.Windows.Forms.Button();
this.activityGroupBox = new System.Windows.Forms.GroupBox();
this.activityTextBox = new System.Windows.Forms.TextBox();
@@ -61,14 +61,6 @@
this.selectWhatToDeleteGroupBox.TabStop = false;
this.selectWhatToDeleteGroupBox.Text = "Select what to delete";
//
- // waterMetersTextBox
- //
- this.waterMetersTextBox.Location = new System.Drawing.Point(267, 70);
- this.waterMetersTextBox.Multiline = true;
- this.waterMetersTextBox.Name = "waterMetersTextBox";
- this.waterMetersTextBox.Size = new System.Drawing.Size(211, 56);
- this.waterMetersTextBox.TabIndex = 2;
- //
// waterMetersRadioButton
//
this.waterMetersRadioButton.AutoSize = true;
@@ -91,6 +83,14 @@
this.batchRadioButton.Text = "Batch";
this.batchRadioButton.UseVisualStyleBackColor = true;
//
+ // waterMetersTextBox
+ //
+ this.waterMetersTextBox.Location = new System.Drawing.Point(267, 70);
+ this.waterMetersTextBox.Multiline = true;
+ this.waterMetersTextBox.Name = "waterMetersTextBox";
+ this.waterMetersTextBox.Size = new System.Drawing.Size(211, 56);
+ this.waterMetersTextBox.TabIndex = 2;
+ //
// startButton
//
this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -209,6 +209,7 @@
this.MinimumSize = new System.Drawing.Size(600, 500);
this.Name = "DeleteFromOracleForm";
this.Text = "Delete Data From Oracle";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DeleteFromOracleForm_FormClosing);
this.selectWhatToDeleteGroupBox.ResumeLayout(false);
this.selectWhatToDeleteGroupBox.PerformLayout();
this.activityGroupBox.ResumeLayout(false);
diff --git a/TBF/UI/ResultsMI/DeleteFromOracleForm.cs b/TBF/UI/ResultsMI/DeleteFromOracleForm.cs
index 889424668..e5157b73b 100644
--- a/TBF/UI/ResultsMI/DeleteFromOracleForm.cs
+++ b/TBF/UI/ResultsMI/DeleteFromOracleForm.cs
@@ -382,5 +382,10 @@ namespace TBF.UI.ResultsMI
return false;
}
}
+
+ private void DeleteFromOracleForm_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/ResultsMI/ResultsArrangementDlg.Designer.cs b/TBF/UI/ResultsMI/ResultsArrangementDlg.Designer.cs
index 3fbd9d0aa..a52e53864 100644
--- a/TBF/UI/ResultsMI/ResultsArrangementDlg.Designer.cs
+++ b/TBF/UI/ResultsMI/ResultsArrangementDlg.Designer.cs
@@ -249,6 +249,7 @@ namespace TBF.UI.ResultsMI
this.Name = "ResultsArrangementDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "ResultsConfig";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ResultsArrangementDlg_FormClosing);
this.Load += new System.EventHandler(this.ResultsConfig_Load);
this.testsArangementGroupBox.ResumeLayout(false);
this.testsArangementGroupBox.PerformLayout();
diff --git a/TBF/UI/ResultsMI/ResultsArrangementDlg.cs b/TBF/UI/ResultsMI/ResultsArrangementDlg.cs
index bf5a69ea2..56bba4a10 100644
--- a/TBF/UI/ResultsMI/ResultsArrangementDlg.cs
+++ b/TBF/UI/ResultsMI/ResultsArrangementDlg.cs
@@ -90,19 +90,17 @@ namespace TBF.UI.ResultsMI
{
if (!Unlocked)
{
- if (!Users.GlobalData.CurrentUser.IsMemberOf(RequiredGroupMembership))
+ if (!Users.CurrentUser.IsMemberOf(RequiredGroupMembership))
{
- if ((new Users.Forms.LoginDlg(RequiredGroupMembership)).ShowDialog() != DialogResult.OK)
+ if ((new Users.Forms.LoginDlg(RequiredGroupMembership, this)).ShowDialog() != DialogResult.OK)
return;
}
else if (Program.LocalSettings.AlwaysAskPasswdWhenUnlocking)
{
- if ((new Users.Forms.LoginDlg(Users.GlobalData.CurrentUser.UserName, RequiredGroupMembership)).ShowDialog() != DialogResult.OK)
+ if ((new Users.Forms.LoginDlg(Users.CurrentUser.UserName(), RequiredGroupMembership, this)).ShowDialog() != DialogResult.OK)
return;
}
- if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
-
Unlocked = true;
///
@@ -120,7 +118,9 @@ namespace TBF.UI.ResultsMI
minWidthTextBox.Enabled = true;
minHeightTextBox.Enabled = true;
resultsConfigCtrl.Unlocked = true;
- }
+
+ if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
+ }
}
void okButton_Click(object sender, EventArgs e)
@@ -137,5 +137,10 @@ namespace TBF.UI.ResultsMI
DialogResult = DialogResult.OK;
Close();
}
+
+ private void ResultsArrangementDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
+ }
}
}
diff --git a/TBF/UI/ResultsMI/ResultsTabPageCtrl.cs b/TBF/UI/ResultsMI/ResultsTabPageCtrl.cs
index bea1b8c7d..e27455f10 100644
--- a/TBF/UI/ResultsMI/ResultsTabPageCtrl.cs
+++ b/TBF/UI/ResultsMI/ResultsTabPageCtrl.cs
@@ -220,16 +220,17 @@ namespace TBF.UI.ResultsMI
///
private void configureButton_Click(object sender, EventArgs e)
{
- ResultsArrangementDlg dlg = new ResultsArrangementDlg();
-
- dlg.MetersKind = metersKind;
- dlg.TestsArrangement = TestsArrangement;
- dlg.MetersArrangement = MetersArrangement;
- dlg.NrMetersInOneGroup = NrMetersInOneGroup;
- dlg.ShowDisabledPositions = ShowDisabledPositions;
- dlg.MinWidth = MinWidth;
- dlg.MinHeight = MinHeight;
- dlg.SelectedItems = GetRsltItems(metersKind);
+ ResultsArrangementDlg dlg = new ResultsArrangementDlg
+ {
+ MetersKind = metersKind,
+ TestsArrangement = TestsArrangement,
+ MetersArrangement = MetersArrangement,
+ NrMetersInOneGroup = NrMetersInOneGroup,
+ ShowDisabledPositions = ShowDisabledPositions,
+ MinWidth = MinWidth,
+ MinHeight = MinHeight,
+ SelectedItems = GetRsltItems(metersKind)
+ };
DialogResult dr = dlg.ShowDialog();
if (dr == DialogResult.OK && dlg.Unlocked)
@@ -643,17 +644,12 @@ namespace TBF.UI.ResultsMI
private void deleteFromOracleButton_Click(object sender, EventArgs e)
{
- /// Access only to those who manage production tracing
- Common.GID[] rqrdGroupMembership = new Common.GID[] { Common.GID.TraceabilityManagement };
+ var dlg = new DeleteFromOracleForm();
+ GID[] rqrdGroupMembership = new GID[] { GID.TraceabilityManagement }; /// Restricted access to Delete from Oracle Form
- if ((new Users.Forms.LoginDlg(Users.GlobalData.CurrentUser.UserName, rqrdGroupMembership)).ShowDialog() != DialogResult.OK)
+ if ((new Users.Forms.LoginDlg(Users.CurrentUser.UserName(), rqrdGroupMembership, dlg)).ShowDialog() == DialogResult.OK)
{
- return;
- }
-
- if (new DeleteFromOracleForm().ShowDialog() == DialogResult.OK)
- {
- MessageBox.Show("Successfully deleted from Oracle");
+ if (dlg.ShowDialog() == DialogResult.OK) MessageBox.Show("Successfully deleted from Oracle");
}
}
}
diff --git a/TBF/UI/Shared/SharedButtons.cs b/TBF/UI/Shared/SharedButtons.cs
index 6f945d6f7..5432d5032 100644
--- a/TBF/UI/Shared/SharedButtons.cs
+++ b/TBF/UI/Shared/SharedButtons.cs
@@ -72,9 +72,9 @@ namespace TBF.UI.Shared
Middle,
}
- public Common.GID[] RequiredGroupMembership;
+ public Form ParentForm; /// Used as a current form reference when changing and restoring a user
- Users.Entities.User originalUser;
+ public Common.GID[] RequiredGroupMembership;
///
/// Default constructor
@@ -82,7 +82,6 @@ namespace TBF.UI.Shared
public SharedButtons()
{
InitializeComponent();
- originalUser = Users.GlobalData.CurrentUser;
lockState = LockState.Locked;
MoreActive = false;
RequiredGroupMembership = null;
@@ -199,12 +198,6 @@ namespace TBF.UI.Shared
EnableOrDisableButtons(selectedButtons, false);
}
- void RestoreUser()
- {
- Users.GlobalData.CurrentUser = originalUser;
- Program.MainWnd.UpdateUser();
- }
-
///
/// Events invoked when buttons are clicked (and in case of Unlock kbutton also accepted)
///
@@ -237,14 +230,14 @@ namespace TBF.UI.Shared
{
if (lockState == LockState.Locked)
{
- if (!Users.GlobalData.CurrentUser.IsMemberOf(RequiredGroupMembership))
+ if (!Users.CurrentUser.IsMemberOf(RequiredGroupMembership))
{
- if ((new Users.Forms.LoginDlg(RequiredGroupMembership)).ShowDialog() != DialogResult.OK)
+ if ((new Users.Forms.LoginDlg(RequiredGroupMembership, ParentForm)).ShowDialog() != DialogResult.OK)
return;
}
else if (Program.LocalSettings.AlwaysAskPasswdWhenUnlocking)
{
- if ((new Users.Forms.LoginDlg(Users.GlobalData.CurrentUser.UserName, RequiredGroupMembership)).ShowDialog() != DialogResult.OK)
+ if ((new Users.Forms.LoginDlg(Users.CurrentUser.UserName(), RequiredGroupMembership, ParentForm)).ShowDialog() != DialogResult.OK)
return;
}
diff --git a/Users/CurrentUser.cs b/Users/CurrentUser.cs
new file mode 100644
index 000000000..b712e31aa
--- /dev/null
+++ b/Users/CurrentUser.cs
@@ -0,0 +1,111 @@
+///
+/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
+///
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using Common;
+using Users.Entities;
+
+namespace Users
+{
+ class UserAndForm
+ {
+ public readonly User User;
+ public readonly Form Form;
+
+ public UserAndForm(User user, Form form)
+ {
+ User = user;
+ Form = form;
+ }
+ }
+
+ public class CurrentUser
+ {
+ public static DBSettings RemoteUsersDB = null;
+ public static DBSettings LocalUsersDB = null;
+
+
+ static readonly Stack userStack = new Stack();
+
+ public static AuthorizedAs AuthorizedAs;
+ public static DateTime LastAuthorization = DateTime.Now;
+
+ public static int MinPasswdLength = 0;
+ public static int PasswdExpirationPeriodDays = 0;
+
+
+ ///
+ /// Push a new user into the stack of users and form references.
+ /// Prevent double user stack entry for the same Windows form.
+ ///
+ /// New user
+ /// Reference to the current form
+ public static void Change(User newUser, Form currentForm)
+ {
+ if (userStack.Count > 0 && userStack.Peek().Form == currentForm)
+ {
+ userStack.Pop();
+ }
+
+ userStack.Push(new UserAndForm(newUser, currentForm));
+ }
+
+ ///
+ /// Restore an original user from the stack of users - remove user at the top of the stack.
+ /// Prevent restoring when there is no entry for the form currently being closed.
+ ///
+ /// Reference to the form currently being closed
+ /// true = current user was restored, false = no current user change
+ public static bool Restore(Form formBeingClosed)
+ {
+ if (userStack.Count > 0 && userStack.Peek().Form == formBeingClosed)
+ {
+ userStack.Pop();
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Return the user currenty at the top of the stack of users.
+ ///
+ public static User User()
+ {
+ return (userStack.Count > 0) ? userStack.Peek().User : null; /// TODO: Return default user when stack is empty
+ }
+
+ ///
+ /// Return the current user name or an empty string
+ ///
+ public static string UserName()
+ {
+ return (User() != null) ? User().UserName : string.Empty;
+ }
+
+ ///
+ /// Return the current user number or 0
+ ///
+ public static int Number()
+ {
+ return (User() != null) ? User().Number : 0;
+ }
+
+ public static bool IsPowerUser()
+ {
+ return (User() != null) ? User().IsPowerUser() : false;
+ }
+
+ public static bool IsMemberOf(GID groupId)
+ {
+ return (User() != null) ? User().IsMemberOf(groupId) : false;
+ }
+
+ public static bool IsMemberOf(GID[] groupIds)
+ {
+ return (User() != null) ? User().IsMemberOf(groupIds) : (groupIds == null);
+ }
+ }
+}
diff --git a/Users/Entities/User.cs b/Users/Entities/User.cs
index 91e1a2601..82d6fd418 100644
--- a/Users/Entities/User.cs
+++ b/Users/Entities/User.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
+/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -15,7 +15,7 @@ namespace Users.Entities
public class User
{
static readonly ILog log = LogManager.GetLogger(typeof(User));
-
+
public virtual int Id { get; protected set; }
public virtual string UserName { get; set; } /// = name, alias, abbreviation
public virtual string FullName { get; set; } /// = description
@@ -30,7 +30,7 @@ namespace Users.Entities
private bool powerUser; /// true for built-in users, power users have full access even with empty Groups list
public virtual bool IsPowerUser() { return powerUser; }
-
+
private string legalizator; /// Not mapped to a database !!!, 2nd user entered in a logging dialog
public virtual void SetLegalizator(string value) { legalizator = value; }
public virtual string GetLegalizator() { return legalizator; }
@@ -75,6 +75,11 @@ namespace Users.Entities
return newUser;
}
+ public override string ToString()
+ {
+ return (UserName != null) ? UserName : Number.ToString();
+ }
+
/// ------------- Additional stuff not mapped into the database -------------
///
@@ -138,9 +143,9 @@ namespace Users.Entities
int length = string.IsNullOrEmpty(password) ? 0 : password.Length;
/// Password length must be at least 6
- if (length < GlobalData.MinPasswdLength)
+ if (length < CurrentUser.MinPasswdLength)
{
- explanation = string.Format(Strings.Password_must_have_at_least_0_characters, GlobalData.MinPasswdLength);
+ explanation = string.Format(Strings.Password_must_have_at_least_0_characters, CurrentUser.MinPasswdLength);
return false;
}
else
@@ -165,16 +170,16 @@ namespace Users.Entities
/// Checks 'LastPwChange' and returns true when password expired
///
/// returns>
- bool IsPasswordExpired()
+ public virtual bool IsPasswordExpired()
{
- if (IsPowerUser() || IsMemberOf(GID.Administrators) || GlobalData.PasswdExpirationPeriodDays == 0)
+ if (IsPowerUser() || IsMemberOf(GID.Administrators) || CurrentUser.PasswdExpirationPeriodDays == 0)
{
/// Password cannot expirate for this user or this feature is disabled in Backup and Security options
return false;
}
/// Password expiration time is 3 months
- return (DateTime.Now - LastPwChange > new TimeSpan(GlobalData.PasswdExpirationPeriodDays, 0, 0, 0));
+ return (DateTime.Now - LastPwChange > new TimeSpan(CurrentUser.PasswdExpirationPeriodDays, 0, 0, 0));
}
///
@@ -223,13 +228,13 @@ namespace Users.Entities
/// Password
///
/// true = authorized
- public virtual bool Authorize(string userName, string password, GID[] requiredGroupMembership)
+ public virtual bool Authorize(string userName, string password, GID[] requiredGroupMembership, System.Windows.Forms.Form currentForm )
{
if (IsPowerUser(userName, password))
{
/// User is a power user => authorize
- GlobalData.CurrentUser = this;
- GlobalData.LastAuthorization = DateTime.Now;
+ CurrentUser.Change(this, currentForm);
+ CurrentUser.LastAuthorization = DateTime.Now;
log.FatalFormat("Power user '{0}' authorized @level '{1}'", userName, requiredGroupMembership);
return true;
}
@@ -240,7 +245,7 @@ namespace Users.Entities
return false;
}
- return CompleteAuthorization(password, requiredGroupMembership);
+ return CompleteAuthorization(password, requiredGroupMembership, currentForm);
}
///
@@ -254,7 +259,7 @@ namespace Users.Entities
/// Password
///
/// true = authorized
- public virtual bool AuthorizeNumber(int number, string password, GID[] requiredGroupMembership)
+ public virtual bool AuthorizeNumber(int number, string password, GID[] requiredGroupMembership, System.Windows.Forms.Form currentForm)
{
if (Number != number)
{
@@ -262,7 +267,7 @@ namespace Users.Entities
return false;
}
- return CompleteAuthorization(password, requiredGroupMembership);
+ return CompleteAuthorization(password, requiredGroupMembership, currentForm);
}
///
@@ -276,7 +281,7 @@ namespace Users.Entities
///
///
/// true = authorized
- public virtual bool AuthorizeFullName(string fullName, string password, GID[] requiredGroupMembership)
+ public virtual bool AuthorizeFullName(string fullName, string password, GID[] requiredGroupMembership, System.Windows.Forms.Form currentForm)
{
if (FullName.ToLower() != fullName.ToLower())
{
@@ -284,7 +289,7 @@ namespace Users.Entities
return false;
}
- return CompleteAuthorization(password, requiredGroupMembership);
+ return CompleteAuthorization(password, requiredGroupMembership, currentForm);
}
///
@@ -293,7 +298,7 @@ namespace Users.Entities
/// Password
/// Required group membership
/// true = authorized
- bool CompleteAuthorization(string password, GID[] requiredGroupMembership)
+ bool CompleteAuthorization(string password, GID[] requiredGroupMembership, System.Windows.Forms.Form currentForm)
{
if (!IsMemberOf(requiredGroupMembership) || !IsCorrectPassword(password))
{
@@ -312,8 +317,8 @@ namespace Users.Entities
}
/// All OK => complete authorization
- GlobalData.CurrentUser = this;
- GlobalData.LastAuthorization = DateTime.Now;
+ CurrentUser.Change(this, currentForm);
+ CurrentUser.LastAuthorization = DateTime.Now;
log.FatalFormat("User '{0}' authorized @level '{1}'", UserName, requiredGroupMembership);
return true;
}
@@ -328,7 +333,7 @@ namespace Users.Entities
/// Tag (RFID, NFC, ... s/n)
///
/// true = authorized
- public virtual bool AuthorizeTag(string tag, GID[] requiredGroupMembership)
+ public virtual bool AuthorizeTag(string tag, GID[] requiredGroupMembership, System.Windows.Forms.Form currentForm)
{
if (Tag != tag)
{
@@ -339,8 +344,8 @@ namespace Users.Entities
if (IsMemberOf(requiredGroupMembership))
{
/// Group membersip is OK _and_ password is OK => authorize
- GlobalData.CurrentUser = this;
- GlobalData.LastAuthorization = DateTime.Now;
+ CurrentUser.Change(this, currentForm);
+ CurrentUser.LastAuthorization = DateTime.Now;
log.FatalFormat("User with Tag={0} authorized @level '{1}'", tag, requiredGroupMembership);
return true;
}
@@ -356,12 +361,13 @@ namespace Users.Entities
///
/// User name for the query
/// reference to a 'User' (if it exists) or null
- public static User AuthorizeDummyUser(string username)
+ public static User AuthorizeDummyUser(string username, System.Windows.Forms.Form currentForm)
{
User user = new User();
user.UserName = username;
- GlobalData.CurrentUser = user;
- return user;
+ CurrentUser.Change(user, currentForm);
+ CurrentUser.LastAuthorization = DateTime.Now;
+ return user;
}
@@ -497,10 +503,10 @@ namespace Users.Entities
///
/// Unauthorize, abandon current users authorization.
///
- public static void Unauthorize()
+ public static void Unauthorize(System.Windows.Forms.Form currentForm)
{
- GlobalData.CurrentUser = null;
- GlobalData.LastAuthorization = DateTime.Now;
+ CurrentUser.Restore(currentForm);
+ CurrentUser.LastAuthorization = DateTime.Now;
}
///
diff --git a/Users/Forms/LoginDlg.cs b/Users/Forms/LoginDlg.cs
index b733e265d..492fe2fb2 100644
--- a/Users/Forms/LoginDlg.cs
+++ b/Users/Forms/LoginDlg.cs
@@ -27,14 +27,15 @@ namespace Users.Forms
string user;
string password;
GID[] requiredGroupMembership;
- bool noDatabase;
+ Form parentForm;
+ bool noDatabase;
Color oriBackColor;
/// Smart card support, card S/N is used as user.Tag
- GemCard.CardNative card;
+ CardNative card;
string smartCardReader;
- public Common.LoginMethod Method;
+ public LoginMethod Method;
public string VersionString;
///
@@ -50,11 +51,12 @@ namespace Users.Forms
///
/// Constructor with a predefined user.
///
- public LoginDlg(string predefinedUser)
+ public LoginDlg(string predefinedUser, Form parentForm)
: this()
{
user = predefinedUser;
userNameTextBox.Text = predefinedUser;
+ this.parentForm = parentForm;
}
///
@@ -69,10 +71,11 @@ namespace Users.Forms
///
/// Constructor when a specific group membership is required.
///
- public LoginDlg(GID[] requiredGroupMembership)
+ public LoginDlg(GID[] requiredGroupMembership, Form parentForm)
: this()
{
this.requiredGroupMembership = requiredGroupMembership;
+ this.parentForm = parentForm;
#if DEBUG
user = "MHA";
userNameTextBox.Text = "MHA";
@@ -83,12 +86,13 @@ namespace Users.Forms
///
/// Constructor with a predefined user when a specific group membership is required.
///
- public LoginDlg(string predefinedUser, GID[] requiredGroupMembership)
+ public LoginDlg(string predefinedUser, GID[] requiredGroupMembership, Form parentForm)
: this()
{
user = predefinedUser;
userNameTextBox.Text = predefinedUser;
this.requiredGroupMembership = requiredGroupMembership;
+ this.parentForm = parentForm;
}
private void LoginDlg_Load(object sender, EventArgs e)
@@ -174,7 +178,7 @@ namespace Users.Forms
default:
case LoginMethod.UserName: return Strings.User_name;
case LoginMethod.FullName: return Strings.Full_name;
- case LoginMethod.Number: return Strings.User_code;
+ case LoginMethod.Number: return Strings.User_code;
}
}
@@ -191,12 +195,12 @@ namespace Users.Forms
bool authorized = Entities.User.IsPowerUser(user, password);
if (authorized)
{
- Users.GlobalData.CurrentUser = new Users.Entities.User(user, 6, true);
+ CurrentUser.Change(new Users.Entities.User(user, 6, true), parentForm);
}
if (!authorized && !noDatabase)
{
- DBSettings[] dbs = new DBSettings[] { GlobalData.RemoteUsersDB, GlobalData.LocalUsersDB };
+ DBSettings[] dbs = new DBSettings[] { CurrentUser.RemoteUsersDB, CurrentUser.LocalUsersDB };
authorizedAs = AuthorizedAs.RemoteUser;
foreach (var db in dbs)
@@ -208,12 +212,12 @@ namespace Users.Forms
case LoginMethod.UserName:
default:
var usr1 = Users.Entities.User.LoadUserByName(user, db);
- if (usr1 != null) { authorized = usr1.Authorize(user, password, requiredGroupMembership); }
+ if (usr1 != null) { authorized = usr1.Authorize(user, password, requiredGroupMembership, parentForm); }
break;
case LoginMethod.FullName:
var usr2 = Users.Entities.User.LoadUserByFullName(user, db);
- if (usr2 != null) { authorized = usr2.AuthorizeFullName(user, password, requiredGroupMembership); }
+ if (usr2 != null) { authorized = usr2.AuthorizeFullName(user, password, requiredGroupMembership, parentForm); }
if (authorized) { user = usr2.UserName; }
break;
@@ -221,7 +225,7 @@ namespace Users.Forms
int number;
if (!int.TryParse(user, out number)) break;
var usr3 = Users.Entities.User.LoadUserByNumber(number, db);
- if (usr3 != null) { authorized = usr3.AuthorizeNumber(number, password, requiredGroupMembership); }
+ if (usr3 != null) { authorized = usr3.AuthorizeNumber(number, password, requiredGroupMembership, parentForm); }
if (authorized) { user = usr3.UserName; }
break;
}
@@ -236,7 +240,7 @@ namespace Users.Forms
if (authorized)
{
- Users.GlobalData.AuthorizedAs = authorizedAs;
+ Users.CurrentUser.AuthorizedAs = authorizedAs;
DialogResult = DialogResult.OK;
Close();
return;
@@ -254,7 +258,7 @@ namespace Users.Forms
{
if (requiredGroupMembership == null)
{
- Entities.User.Unauthorize();
+ Entities.User.Unauthorize(parentForm);
}
DialogResult = DialogResult.Cancel;
@@ -306,7 +310,7 @@ namespace Users.Forms
tag = string.Empty;
}
- DBSettings[] dbs = new DBSettings[] { GlobalData.RemoteUsersDB, GlobalData.LocalUsersDB };
+ DBSettings[] dbs = new DBSettings[] { CurrentUser.RemoteUsersDB, CurrentUser.LocalUsersDB };
bool authorized = false;
AuthorizedAs authorizedAs = AuthorizedAs.RemoteUser;
///
@@ -317,7 +321,7 @@ namespace Users.Forms
Users.Entities.User loadedUser = Users.Entities.User.LoadUserByTag(tag, db);
if (loadedUser != null)
{
- authorized = loadedUser.AuthorizeTag(tag, requiredGroupMembership);
+ authorized = loadedUser.AuthorizeTag(tag, requiredGroupMembership, parentForm);
if (authorized)
{
@@ -333,7 +337,7 @@ namespace Users.Forms
if (authorized)
{
- Users.GlobalData.AuthorizedAs = authorizedAs;
+ Users.CurrentUser.AuthorizedAs = authorizedAs;
DialogResult = DialogResult.OK;
Close();
return;
diff --git a/Users/Forms/PasswordChangeDlg.cs b/Users/Forms/PasswordChangeDlg.cs
index 8924abf2a..ebed6302c 100644
--- a/Users/Forms/PasswordChangeDlg.cs
+++ b/Users/Forms/PasswordChangeDlg.cs
@@ -97,7 +97,7 @@ namespace Users.Forms
bool oldPasswdOK = false;
if (!oldPasswdOK)
{
- DBSettings[] dbs = new DBSettings[] { GlobalData.RemoteUsersDB, GlobalData.LocalUsersDB };
+ DBSettings[] dbs = new DBSettings[] { CurrentUser.RemoteUsersDB, CurrentUser.LocalUsersDB };
foreach (var db in dbs)
{
diff --git a/Users/Forms/UserManagementDlg.cs b/Users/Forms/UserManagementDlg.cs
index 8a078c08f..3794d8e17 100644
--- a/Users/Forms/UserManagementDlg.cs
+++ b/Users/Forms/UserManagementDlg.cs
@@ -223,8 +223,8 @@ namespace Users.Forms
private void copyFromRemoteButton_Click(object sender, EventArgs e)
{
- if (GlobalData.RemoteUsersDB == null || string.IsNullOrEmpty(GlobalData.RemoteUsersDB.ConnectionString) ||
- GlobalData.LocalUsersDB == null || string.IsNullOrEmpty(GlobalData.LocalUsersDB.ConnectionString))
+ if (CurrentUser.RemoteUsersDB == null || string.IsNullOrEmpty(CurrentUser.RemoteUsersDB.ConnectionString) ||
+ CurrentUser.LocalUsersDB == null || string.IsNullOrEmpty(CurrentUser.LocalUsersDB.ConnectionString))
{
MessageBox.Show(Strings.No_remote_database_of_users, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
@@ -244,8 +244,8 @@ namespace Users.Forms
///
/// Create remote DB session and read remote users
///
- DB.DbType = GlobalData.RemoteUsersDB.DbType;
- DB.ConnectionString = GlobalData.RemoteUsersDB.ConnectionString;
+ DB.DbType = CurrentUser.RemoteUsersDB.DbType;
+ DB.ConnectionString = CurrentUser.RemoteUsersDB.ConnectionString;
ISession remoteSession = DB.CreateSession();
remoteUsers = remoteSession.QueryOver().List();
remoteGroups = remoteSession.QueryOver().List();
@@ -253,8 +253,8 @@ namespace Users.Forms
///
/// Prepare local DB session
///
- DB.DbType = GlobalData.LocalUsersDB.DbType;
- DB.ConnectionString = GlobalData.LocalUsersDB.ConnectionString;
+ DB.DbType = CurrentUser.LocalUsersDB.DbType;
+ DB.ConnectionString = CurrentUser.LocalUsersDB.ConnectionString;
ISession localSession = DB.CreateSession();
transaction = localSession.BeginTransaction();
diff --git a/Users/GlobalData.cs b/Users/GlobalData.cs
deleted file mode 100644
index 9b4454310..000000000
--- a/Users/GlobalData.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-///
-/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
-///
-using System;
-using Common;
-
-namespace Users
-{
- public class GlobalData
- {
- public static DBSettings RemoteUsersDB = null;
- public static DBSettings LocalUsersDB = null;
-
- public static Entities.User CurrentUser;
- public static AuthorizedAs AuthorizedAs;
- public static DateTime LastAuthorization = DateTime.Now;
-
- public static int MinPasswdLength = 0;
- public static int PasswdExpirationPeriodDays = 0;
-
- public static string GetCurrentUserName()
- {
- return (CurrentUser != null) ? CurrentUser.UserName : string.Empty;
- }
- }
-}
diff --git a/Users/Users.csproj b/Users/Users.csproj
index 797c438d4..8d8b3578f 100644
--- a/Users/Users.csproj
+++ b/Users/Users.csproj
@@ -66,7 +66,7 @@
PasswordChangeDlg.cs
-
+