From 18dac8fb72c959114e7bbd3fbc3f27b49ec58331 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 26 Sep 2017 07:52:48 +0200 Subject: [PATCH] Legalizator (= 2nd user) support, ver. 2.16.667 --- Results/ItemID.cs | 9 +- Results/Properties/AssemblyInfo.cs | 4 +- Results/Resources/Strings.Designer.cs | 18 ++ Results/Resources/Strings.resx | 6 + Results/WMeterRsltItemSpec.cs | 12 +- .../BenchControl/Sequences/MainSeq.cs | 2 +- .../Forms/LoginDlgWithBenchSelection.cs | 44 ++++- .../LoginDlgWithBenchSelection.designer.cs | 186 ++++++++++-------- .../Forms/LoginDlgWithBenchSelection.resx | 86 ++++++-- TestBenchFramework/LocalSettings.cs | 5 + TestBenchFramework/Program.cs | 5 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- .../Resources/Strings.Designer.cs | 9 + TestBenchFramework/Resources/Strings.pl.resx | 3 + TestBenchFramework/Resources/Strings.resx | 3 + .../UiControls/SharedButtons.cs | 2 +- Users/Entities/User.cs | 46 ++++- Users/GlobalData.cs | 2 +- Users/IUser.cs | 29 --- Users/Properties/AssemblyInfo.cs | 4 +- Users/Users.csproj | 1 - 21 files changed, 320 insertions(+), 160 deletions(-) delete mode 100644 Users/IUser.cs diff --git a/Results/ItemID.cs b/Results/ItemID.cs index 95c2df652..bbc456ae9 100644 --- a/Results/ItemID.cs +++ b/Results/ItemID.cs @@ -167,9 +167,12 @@ namespace Results E15, /// 149 E16, /// 150 - TableRowNr, /// 151 - TableColumnNr, /// 152 - WMRemark, + Table_row_nr, /// 151 + Table_column_nr, /// 152 + WMRemark, /// 153 + + User_description, /// 154 + Legalizator, Count, } diff --git a/Results/Properties/AssemblyInfo.cs b/Results/Properties/AssemblyInfo.cs index 64e0fb828..3119a298e 100644 --- a/Results/Properties/AssemblyInfo.cs +++ b/Results/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.16.645.0")] -[assembly: AssemblyFileVersion("2.16.645.0")] +[assembly: AssemblyVersion("2.16.667.0")] +[assembly: AssemblyFileVersion("2.16.667.0")] diff --git a/Results/Resources/Strings.Designer.cs b/Results/Resources/Strings.Designer.cs index e4de6e3eb..09380a68d 100644 --- a/Results/Resources/Strings.Designer.cs +++ b/Results/Resources/Strings.Designer.cs @@ -411,6 +411,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to Legalizator. + /// + internal static string Legalizator { + get { + return ResourceManager.GetString("Legalizator", resourceCulture); + } + } + /// /// Looks up a localized string similar to main. /// @@ -1410,6 +1419,15 @@ namespace Results.Resources { } } + /// + /// Looks up a localized string similar to User description. + /// + internal static string User_description { + get { + return ResourceManager.GetString("User_description", resourceCulture); + } + } + /// /// Looks up a localized string similar to User nr.. /// diff --git a/Results/Resources/Strings.resx b/Results/Resources/Strings.resx index 22c92cb60..cb9fb89f6 100644 --- a/Results/Resources/Strings.resx +++ b/Results/Resources/Strings.resx @@ -630,4 +630,10 @@ Error flags + + Legalizator + + + User description + \ No newline at end of file diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index 19693e16e..ac1845eae 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -316,9 +316,11 @@ namespace Results /// Batch info AllItems.Add(new WMeterRsltItemSpec(ItemID.Test_bench_ID, Strings.Bench, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => w.Batch.TestBenchId.ToString())); AllItems.Add(new WMeterRsltItemSpec(ItemID.Program_version, Strings.Ver, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => w.Batch.ProgramVersion)); - AllItems.Add(new WMeterRsltItemSpec(ItemID.User_name, Strings.User, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => w.Batch.UserName)); - AllItems.Add(new WMeterRsltItemSpec(ItemID.User_nr, Strings.User_nr, Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => w.Batch.UserNumber.ToString())); - AllItems.Add(new WMeterRsltItemSpec(ItemID.Watermeters, Strings.WMs, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => w.Batch.WatermetersStr)); + AllItems.Add(new WMeterRsltItemSpec(ItemID.User_nr, Strings.User_nr, Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => w.Batch.UserNumber.ToString())); + AllItems.Add(new WMeterRsltItemSpec(ItemID.User_name, Strings.User, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => Users.Entities.User.EncodedStrToUserName(w.Batch.UserName))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.User_description, Strings.User_description, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => Users.Entities.User.EncodedStrToFullName(w.Batch.UserName))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Legalizator, Strings.Legalizator, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => Users.Entities.User.EncodedStrToLegalizator(w.Batch.UserName))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Watermeters, Strings.WMs, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => w.Batch.WatermetersStr)); AllItems.Add(new WMeterRsltItemSpec(ItemID.Protocol_title, Strings.Protocol, Quantity.String, ItemCategory.Other, (w, t, u, f, p) => w.Batch.ProtocolTitle)); AllItems.Add(new WMeterRsltItemSpec(ItemID.Batch_start_time, Strings.Start, Quantity.DateTime, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? w.Batch.StartTime.ToString() : string.Format(f, w.Batch.StartTime))); AllItems.Add(new WMeterRsltItemSpec(ItemID.Batch_end_time, Strings.End, Quantity.DateTime, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? w.Batch.EndTime.ToString() : string.Format(f, w.Batch.EndTime))); @@ -364,8 +366,8 @@ namespace Results AllItems.Add(new WMeterRsltItemSpec(ItemID.E15, "E15 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x4000) != 0) ? Strings.Yes : Strings.No)); AllItems.Add(new WMeterRsltItemSpec(ItemID.E16, "E16 ()", Quantity.Boolean, ItemCategory.TestResult, (w, t, u, f, p) => (w.GetTestRslt(t) != null && (w.GetTestRslt(t).ErrorFlags & 0x8000) != 0) ? Strings.Yes : Strings.No)); - AllItems.Add(new WMeterRsltItemSpec(ItemID.TableRowNr, "Table row #", Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? TableRowNr.ToString() : string.Format(f, TableRowNr))); - AllItems.Add(new WMeterRsltItemSpec(ItemID.TableColumnNr, "Table column #", Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? TableColumnNr.ToString() : string.Format(f, TableColumnNr))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Table_row_nr, "Table row #", Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? TableRowNr.ToString() : string.Format(f, TableRowNr))); + AllItems.Add(new WMeterRsltItemSpec(ItemID.Table_column_nr, "Table column #", Quantity.Number, ItemCategory.Other, (w, t, u, f, p) => string.IsNullOrEmpty(f) ? TableColumnNr.ToString() : string.Format(f, TableColumnNr))); AllItems.Add(new WMeterRsltItemSpec(ItemID.WMRemark, string.Format("{0} {1}", Strings.Water_Meter, Strings.Remark), Quantity.String, ItemCategory.MeterResult, (w, t, u, f, p) => w.Remark)); } diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 067be32d8..e0ab72bf1 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -1349,7 +1349,7 @@ namespace TBF.BenchControl.Sequences /// Prepare empty results return Results.BatchResults.NewFromProcedure(newBatchNr, (BenchInfo != null) ? BenchInfo.TestBenchId : 1, - Users.GlobalData.CurrentUser.UserName, + Users.GlobalData.CurrentUser.ToEncodedStr(), Users.GlobalData.CurrentUser.Number, Program.Version, StateMachine.Procedure, diff --git a/TestBenchFramework/Forms/LoginDlgWithBenchSelection.cs b/TestBenchFramework/Forms/LoginDlgWithBenchSelection.cs index 595262214..46517b85c 100644 --- a/TestBenchFramework/Forms/LoginDlgWithBenchSelection.cs +++ b/TestBenchFramework/Forms/LoginDlgWithBenchSelection.cs @@ -15,16 +15,18 @@ namespace TBF.Forms /// public partial class LoginDlgWithBenchSelection : Form { - // Private fields + /// Private fields string alias; string password; string benchName = null; + string legalizator; - // Readonly public properties to do the authorization. + /// Readonly public properties to do the authorization. public string Alias { get { return alias; } } public string Password { get { return password; } } public string BenchName { get { return benchName; } } public Users.Entities.LoginMethod Method; + public string Legalizator { get { return legalizator; } } /// /// Constructor. @@ -41,10 +43,37 @@ namespace TBF.Forms : this() { benchName = predefinedBench; + +#if LANG_PL + Height = 156; + EnableAndPrepareLegalizatorCombo(legalizatorComboBox); +#else + legalizator = string.Empty; +#endif } - private void LoginDlgWithBenchSelection_Load(object sender, EventArgs e) - { + /// + /// Load Legalizator order combo box items from the LocalSettings LastLegalizators array + /// + /// Legalizator ComboBox + void EnableAndPrepareLegalizatorCombo(ComboBox comboBox) + { + legalizatorLabel.Visible = true; + legalizatorComboBox.Visible = true; + legalizatorComboBox.Enabled = true; + + for (int i = 0; i < Program.LocalSettings.LastLegalizatorsCount; i++) + { + comboBox.Items.Add(Program.LocalSettings.LastLegalizators[i]); + } + + legalizator = (comboBox.Items.Count > 0) ? Program.LocalSettings.LastLegalizators[0] : string.Empty; + comboBox.Text = legalizator; + } + + + private void LoginDlgWithBenchSelection_Load(object sender, EventArgs e) + { Localize(); #if DEBUG userNameTextBox.Text = "milan"; @@ -68,6 +97,7 @@ namespace TBF.Forms testBenchLabel.Text = Strings.Test_bench; okButton.Text = Strings.OkBtnText; cancelButton.Text = Strings.CancelBtnText; + legalizatorLabel.Text = Strings.Legalizator; } string GetAliasLabel() @@ -84,6 +114,7 @@ namespace TBF.Forms /// /// OK clicked (authorization is done outside this dialog). /// + private void okButton_Click(object sender, EventArgs e) { if (testBenchComboBox.SelectedItem != null) @@ -91,6 +122,11 @@ namespace TBF.Forms alias = userNameTextBox.Text; password = passwordTextBox.Text; benchName = testBenchComboBox.SelectedItem.ToString(); + if (legalizatorComboBox.Enabled) + { + legalizator = legalizatorComboBox.Text; + Program.LocalSettings.UpdateHistory(legalizator, ref Program.LocalSettings.LastLegalizators); + } DialogResult = DialogResult.OK; Close(); diff --git a/TestBenchFramework/Forms/LoginDlgWithBenchSelection.designer.cs b/TestBenchFramework/Forms/LoginDlgWithBenchSelection.designer.cs index 3543b89d3..5f608b31b 100644 --- a/TestBenchFramework/Forms/LoginDlgWithBenchSelection.designer.cs +++ b/TestBenchFramework/Forms/LoginDlgWithBenchSelection.designer.cs @@ -31,92 +31,104 @@ namespace TBF.Forms /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlgWithBenchSelection)); - this.aliasLabel = new System.Windows.Forms.Label(); - this.passwordLabel = new System.Windows.Forms.Label(); - this.testBenchLabel = new System.Windows.Forms.Label(); - this.testBenchComboBox = new System.Windows.Forms.ComboBox(); - this.passwordTextBox = new System.Windows.Forms.TextBox(); - this.cancelButton = new System.Windows.Forms.Button(); - this.okButton = new System.Windows.Forms.Button(); - this.userNameTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // aliasLabel - // - resources.ApplyResources(this.aliasLabel, "aliasLabel"); - this.aliasLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; - this.aliasLabel.Name = "aliasLabel"; - this.aliasLabel.Click += new System.EventHandler(this.aliasLabel_Click); - // - // passwordLabel - // - resources.ApplyResources(this.passwordLabel, "passwordLabel"); - this.passwordLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; - this.passwordLabel.Name = "passwordLabel"; - // - // testBenchLabel - // - resources.ApplyResources(this.testBenchLabel, "testBenchLabel"); - this.testBenchLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; - this.testBenchLabel.Name = "testBenchLabel"; - // - // testBenchComboBox - // - resources.ApplyResources(this.testBenchComboBox, "testBenchComboBox"); - this.testBenchComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.testBenchComboBox.FormattingEnabled = true; - this.testBenchComboBox.Name = "testBenchComboBox"; - // - // passwordTextBox - // - resources.ApplyResources(this.passwordTextBox, "passwordTextBox"); - this.passwordTextBox.Name = "passwordTextBox"; - this.passwordTextBox.UseSystemPasswordChar = true; - this.passwordTextBox.TextChanged += new System.EventHandler(this.passwordTextBox_TextChanged); - // - // cancelButton - // - resources.ApplyResources(this.cancelButton, "cancelButton"); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; - this.cancelButton.Name = "cancelButton"; - this.cancelButton.UseVisualStyleBackColor = true; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); - // - // okButton - // - resources.ApplyResources(this.okButton, "okButton"); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; - this.okButton.Name = "okButton"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // userNameTextBox - // - resources.ApplyResources(this.userNameTextBox, "userNameTextBox"); - this.userNameTextBox.Name = "userNameTextBox"; - this.userNameTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.userNameTextBox_KeyPress); - // - // LoginDlgWithBenchSelection - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.userNameTextBox); - this.Controls.Add(this.okButton); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.passwordTextBox); - this.Controls.Add(this.testBenchComboBox); - this.Controls.Add(this.testBenchLabel); - this.Controls.Add(this.passwordLabel); - this.Controls.Add(this.aliasLabel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Name = "LoginDlgWithBenchSelection"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Load += new System.EventHandler(this.LoginDlgWithBenchSelection_Load); - this.ResumeLayout(false); - this.PerformLayout(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlgWithBenchSelection)); + this.aliasLabel = new System.Windows.Forms.Label(); + this.passwordLabel = new System.Windows.Forms.Label(); + this.testBenchLabel = new System.Windows.Forms.Label(); + this.testBenchComboBox = new System.Windows.Forms.ComboBox(); + this.passwordTextBox = new System.Windows.Forms.TextBox(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.userNameTextBox = new System.Windows.Forms.TextBox(); + this.legalizatorComboBox = new System.Windows.Forms.ComboBox(); + this.legalizatorLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // aliasLabel + // + resources.ApplyResources(this.aliasLabel, "aliasLabel"); + this.aliasLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; + this.aliasLabel.Name = "aliasLabel"; + // + // passwordLabel + // + resources.ApplyResources(this.passwordLabel, "passwordLabel"); + this.passwordLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; + this.passwordLabel.Name = "passwordLabel"; + // + // testBenchLabel + // + resources.ApplyResources(this.testBenchLabel, "testBenchLabel"); + this.testBenchLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; + this.testBenchLabel.Name = "testBenchLabel"; + // + // testBenchComboBox + // + resources.ApplyResources(this.testBenchComboBox, "testBenchComboBox"); + this.testBenchComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.testBenchComboBox.FormattingEnabled = true; + this.testBenchComboBox.Name = "testBenchComboBox"; + // + // passwordTextBox + // + resources.ApplyResources(this.passwordTextBox, "passwordTextBox"); + this.passwordTextBox.Name = "passwordTextBox"; + this.passwordTextBox.UseSystemPasswordChar = true; + // + // cancelButton + // + resources.ApplyResources(this.cancelButton, "cancelButton"); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; + this.cancelButton.Name = "cancelButton"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // okButton + // + resources.ApplyResources(this.okButton, "okButton"); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; + this.okButton.Name = "okButton"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // userNameTextBox + // + resources.ApplyResources(this.userNameTextBox, "userNameTextBox"); + this.userNameTextBox.Name = "userNameTextBox"; + // + // legalizatorComboBox + // + resources.ApplyResources(this.legalizatorComboBox, "legalizatorComboBox"); + this.legalizatorComboBox.FormattingEnabled = true; + this.legalizatorComboBox.Name = "legalizatorComboBox"; + // + // legalizatorLabel + // + resources.ApplyResources(this.legalizatorLabel, "legalizatorLabel"); + this.legalizatorLabel.ImageKey = global::TBF.Resources.Strings.Closing_the_tank; + this.legalizatorLabel.Name = "legalizatorLabel"; + // + // LoginDlgWithBenchSelection + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.legalizatorComboBox); + this.Controls.Add(this.legalizatorLabel); + this.Controls.Add(this.userNameTextBox); + this.Controls.Add(this.okButton); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.passwordTextBox); + this.Controls.Add(this.testBenchComboBox); + this.Controls.Add(this.testBenchLabel); + this.Controls.Add(this.passwordLabel); + this.Controls.Add(this.aliasLabel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "LoginDlgWithBenchSelection"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Load += new System.EventHandler(this.LoginDlgWithBenchSelection_Load); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -130,5 +142,7 @@ namespace TBF.Forms private System.Windows.Forms.ComboBox testBenchComboBox; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button okButton; + private System.Windows.Forms.ComboBox legalizatorComboBox; + private System.Windows.Forms.Label legalizatorLabel; } } \ No newline at end of file diff --git a/TestBenchFramework/Forms/LoginDlgWithBenchSelection.resx b/TestBenchFramework/Forms/LoginDlgWithBenchSelection.resx index b0b961b09..9ecdee9bd 100644 --- a/TestBenchFramework/Forms/LoginDlgWithBenchSelection.resx +++ b/TestBenchFramework/Forms/LoginDlgWithBenchSelection.resx @@ -144,7 +144,7 @@ $this - 7 + 9 True @@ -171,7 +171,7 @@ $this - 6 + 8 True @@ -198,14 +198,14 @@ $this - 5 + 7 Top, Right - 150, 67 + 148, 67 168, 21 @@ -223,13 +223,13 @@ $this - 4 + 6 Top, Right - 150, 41 + 148, 41 168, 20 @@ -247,13 +247,13 @@ $this - 3 + 5 Top, Right - 336, 48 + 334, 48 105, 28 @@ -274,13 +274,13 @@ $this - 2 + 4 Top, Right - 336, 14 + 334, 14 105, 28 @@ -301,13 +301,13 @@ $this - 1 + 3 Top, Right - 150, 15 + 148, 15 168, 20 @@ -325,8 +325,68 @@ $this + 2 + + + Top, Right + + + 148, 95 + + + 168, 21 + + + 9 + + + False + + + legalizatorComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 + + True + + + NoControl + + + 11, 98 + + + 58, 13 + + + 8 + + + Legalizator + + + False + + + legalizatorLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + True @@ -334,7 +394,7 @@ 6, 13 - 456, 102 + 454, 102 CenterScreen diff --git a/TestBenchFramework/LocalSettings.cs b/TestBenchFramework/LocalSettings.cs index 6d1280f84..41aa0aa50 100644 --- a/TestBenchFramework/LocalSettings.cs +++ b/TestBenchFramework/LocalSettings.cs @@ -198,6 +198,11 @@ namespace TBF public bool PrintOrderOnlyGoodResult; public bool PrintOrderOnlyLastResult; + /// Legalizator history + public string[] LastLegalizators; + [XmlIgnore] + public int LastLegalizatorsCount { get { return (LastLegalizators != null) ? LastLegalizators.Length : 0; } } + /// Configuration of results public Config.Entities.MetersArrangement ResultsConfigMeters; public Config.Entities.TestsArrangement ResultsConfigTests; diff --git a/TestBenchFramework/Program.cs b/TestBenchFramework/Program.cs index d8702cd19..fac8ca871 100644 --- a/TestBenchFramework/Program.cs +++ b/TestBenchFramework/Program.cs @@ -215,7 +215,7 @@ namespace TBF GlobalData.RemoteUsersDB = LocalSettings.TestBenches[i].UsersDBSettings; GlobalData.LocalUsersDB = LocalSettings.TestBenches[i].ProceduresDBSettings; - Users.IUser loadedUser = null; + Users.Entities.User loadedUser = null; try { bool authorized = false; @@ -275,7 +275,8 @@ namespace TBF if (authorized) { - Users.GlobalData.AuthorizedAs = authorizedAs; + loadedUser.SetLegalizator(loginDlgBench.Legalizator); + Users.GlobalData.AuthorizedAs = authorizedAs; LocalSettings.LoginMethod = loginDlgBench.Method; /// Save the login method actually used diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 3819db0f3..80b5c3204 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.16.661.1")] -[assembly: AssemblyFileVersion("2.16.661.1")] +[assembly: AssemblyVersion("2.16.667.1")] +[assembly: AssemblyFileVersion("2.16.667.1")] diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 8fb4fff88..8434a0b33 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1968,6 +1968,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Legalizator. + /// + internal static string Legalizator { + get { + return ResourceManager.GetString("Legalizator", resourceCulture); + } + } + /// /// Looks up a localized string similar to Less. /// diff --git a/TestBenchFramework/Resources/Strings.pl.resx b/TestBenchFramework/Resources/Strings.pl.resx index 4e0470801..76e432e5a 100644 --- a/TestBenchFramework/Resources/Strings.pl.resx +++ b/TestBenchFramework/Resources/Strings.pl.resx @@ -1626,4 +1626,7 @@ Krótki opis + + Legalizator + \ No newline at end of file diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index f713c9f9f..a42e1554d 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1792,4 +1792,7 @@ At temperature + + Legalizator + \ No newline at end of file diff --git a/TestBenchFramework/UiControls/SharedButtons.cs b/TestBenchFramework/UiControls/SharedButtons.cs index 15f3c0e36..6cafd4d30 100644 --- a/TestBenchFramework/UiControls/SharedButtons.cs +++ b/TestBenchFramework/UiControls/SharedButtons.cs @@ -65,7 +65,7 @@ namespace TBF.UiControls public Users.Grp.GID RequiredGroupMembership; - Users.IUser originalUser; + Users.Entities.User originalUser; /// /// Default constructor diff --git a/Users/Entities/User.cs b/Users/Entities/User.cs index 8cdebbc4d..50aa207ad 100644 --- a/Users/Entities/User.cs +++ b/Users/Entities/User.cs @@ -9,19 +9,23 @@ using log4net; namespace Users.Entities { - public class User : IUser + 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 + public virtual string UserName { get; set; } /// = name, alias, abbreviation + public virtual string FullName { get; set; } /// = description public virtual int Number { get; set; } - public virtual string Password { get; set; } + public virtual string Password { get; set; } public virtual DateTime LastPwChange { get; set; } - public virtual IList Groups { get; set; } //User can be a member of a list of groups + public virtual IList Groups { get; set; } //User can be a member of a list of groups - private bool powerUser; /// true for built-in users, power users have full access even with empty Groups list + private bool powerUser; /// true for built-in users, power users have full access even with empty Groups list + + 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; } public User() { @@ -36,7 +40,7 @@ namespace Users.Entities Number = number; this.powerUser = powerUser; Groups = new List(); - FullName = powerUser ? "Power user" : string.Empty; + FullName = powerUser ? "Power User" : string.Empty; } public virtual void AddGroup(Group group) @@ -55,9 +59,10 @@ namespace Users.Entities { User newUser = new User(UserName, Number, false); newUser.FullName = FullName; + newUser.Number = Number; newUser.Password = Password; newUser.LastPwChange = LastPwChange; - return newUser; + return newUser; } /// ------------- Additional stuff not mapped into the database ------------- @@ -401,6 +406,31 @@ namespace Users.Entities return hashString; } + + public virtual string ToEncodedStr() + { + return string.Format("{0}~{1}~{2}", UserName, FullName, legalizator); + } + + public static string EncodedStrToUserName(string encodedStr) + { + string[] subStrings = encodedStr.Split(new char[] { '~' }); + return (subStrings.Length >= 1) ? subStrings[0] : string.Empty; + } + + public static string EncodedStrToFullName(string encodedStr) + { + string[] subStrings = encodedStr.Split(new char[] { '~' }); + return (subStrings.Length >= 2) ? subStrings[1] : string.Empty; + } + + public static string EncodedStrToLegalizator(string encodedStr) + { + string[] subStrings = encodedStr.Split(new char[] { '~' }); + return (subStrings.Length >= 3) ? subStrings[2] : string.Empty; + } + + /// /// Returns 'true' when authentication data are valid for a power user. /// diff --git a/Users/GlobalData.cs b/Users/GlobalData.cs index 4dcbe8b5d..5be249748 100644 --- a/Users/GlobalData.cs +++ b/Users/GlobalData.cs @@ -7,7 +7,7 @@ namespace Users public static DBSettings RemoteUsersDB = null; public static DBSettings LocalUsersDB = null; - public static IUser CurrentUser; + public static Entities.User CurrentUser; public static Entities.AuthorizedAs AuthorizedAs; public static DateTime LastAuthorization = DateTime.Now; } diff --git a/Users/IUser.cs b/Users/IUser.cs deleted file mode 100644 index 21d5203cd..000000000 --- a/Users/IUser.cs +++ /dev/null @@ -1,29 +0,0 @@ -/// -/// Copyright (c) 2013-2017 Sensus Metering Systems -/// -using System; - -namespace Users -{ - public interface IUser - { - string UserName { get; } - string FullName { get; } - int Number { get; } - - bool IsMemberOf(Grp.GID group); - - bool Authorize(string userName, string password); - bool Authorize(string userName, string password, Grp.GID requiredGroup); - - bool AuthorizeFullName(string fullName, string password); - bool AuthorizeFullName(string fullName, string password, Grp.GID requiredGroup); - - bool AuthorizeNumber(int number, string password); - bool AuthorizeNumber(int number, string password, Grp.GID requiredGroup); - - //IUser LoadUserByName(string username, DBSettings dbSettings); - //IUser LoadUserByFullName(string alias, DBSettings dbSettings); - //IUser LoadUserByNumber(int number, DBSettings dbSettings); - } -} diff --git a/Users/Properties/AssemblyInfo.cs b/Users/Properties/AssemblyInfo.cs index fb7529b8c..f85087e2a 100644 --- a/Users/Properties/AssemblyInfo.cs +++ b/Users/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.12.499.0")] -[assembly: AssemblyFileVersion("2.12.499.0")] +[assembly: AssemblyVersion("2.16.667.0")] +[assembly: AssemblyFileVersion("2.16.667.0")] diff --git a/Users/Users.csproj b/Users/Users.csproj index 4b88b073b..7582325d3 100644 --- a/Users/Users.csproj +++ b/Users/Users.csproj @@ -82,7 +82,6 @@ LoginDlg.cs -