diff --git a/TestBenchFramework/Program.cs b/TestBenchFramework/Program.cs index f9414e11f..6c91e683f 100644 --- a/TestBenchFramework/Program.cs +++ b/TestBenchFramework/Program.cs @@ -9,7 +9,6 @@ using log4net; using Config.Entities; using TBF.Resources; using TBF.Forms; -using TBF.ErrorHandler; namespace TBF { diff --git a/UserManagement/DatabaseSettingsDlg.Designer.cs b/UserManagement/DatabaseSettingsDlg.Designer.cs new file mode 100644 index 000000000..17078f96c --- /dev/null +++ b/UserManagement/DatabaseSettingsDlg.Designer.cs @@ -0,0 +1,123 @@ +namespace UserManagement +{ + partial class DatabaseSettingsDlg + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.connectionStringTextBox1 = new System.Windows.Forms.TextBox(); + this.connectionStringLabel = new System.Windows.Forms.Label(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.languageLabel = new System.Windows.Forms.Label(); + this.languageTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // connectionStringTextBox1 + // + this.connectionStringTextBox1.Location = new System.Drawing.Point(29, 44); + this.connectionStringTextBox1.Name = "connectionStringTextBox1"; + this.connectionStringTextBox1.Size = new System.Drawing.Size(555, 20); + this.connectionStringTextBox1.TabIndex = 0; + // + // connectionStringLabel + // + this.connectionStringLabel.AutoSize = true; + this.connectionStringLabel.Location = new System.Drawing.Point(26, 19); + this.connectionStringLabel.Name = "connectionStringLabel"; + this.connectionStringLabel.Size = new System.Drawing.Size(89, 13); + this.connectionStringLabel.TabIndex = 3; + this.connectionStringLabel.Text = "Connection string"; + // + // okButton + // + this.okButton.Location = new System.Drawing.Point(378, 85); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(95, 38); + this.okButton.TabIndex = 6; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(489, 85); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(95, 38); + this.cancelButton.TabIndex = 7; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // languageLabel + // + this.languageLabel.AutoSize = true; + this.languageLabel.Location = new System.Drawing.Point(26, 79); + this.languageLabel.Name = "languageLabel"; + this.languageLabel.Size = new System.Drawing.Size(55, 13); + this.languageLabel.TabIndex = 11; + this.languageLabel.Text = "Language"; + // + // languageTextBox + // + this.languageTextBox.Location = new System.Drawing.Point(29, 103); + this.languageTextBox.Name = "languageTextBox"; + this.languageTextBox.Size = new System.Drawing.Size(100, 20); + this.languageTextBox.TabIndex = 12; + // + // DatabaseSettingsDlg + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(613, 141); + this.Controls.Add(this.languageTextBox); + this.Controls.Add(this.languageLabel); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.connectionStringLabel); + this.Controls.Add(this.connectionStringTextBox1); + this.Name = "DatabaseSettingsDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Database Settings"; + this.Load += new System.EventHandler(this.DatabaseSettings_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox connectionStringTextBox1; + private System.Windows.Forms.Label connectionStringLabel; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Label languageLabel; + private System.Windows.Forms.TextBox languageTextBox; + } +} \ No newline at end of file diff --git a/UserManagement/DatabaseSettingsDlg.cs b/UserManagement/DatabaseSettingsDlg.cs new file mode 100644 index 000000000..cfdbe465f --- /dev/null +++ b/UserManagement/DatabaseSettingsDlg.cs @@ -0,0 +1,51 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using UserManagement.Resources; + +namespace UserManagement +{ + public partial class DatabaseSettingsDlg : Form + { + public DatabaseSettingsDlg() + { + InitializeComponent(); + } + + private void DatabaseSettings_Load(object sender, EventArgs e) + { + Localize(); + + connectionStringTextBox1.Text = Program.LocalSettings.ConnectionString; + languageTextBox.Text = Program.LocalSettings.Language; + } + + void Localize() + { + Text = Strings.Settings; + connectionStringLabel.Text = Strings.Connection_string; + languageLabel.Text = Strings.Language; + okButton.Text = Strings.OkBtnText; + cancelButton.Text = Strings.CancelBtnText; + } + + private void okButton_Click(object sender, EventArgs e) + { + Program.LocalSettings.ConnectionString = connectionStringTextBox1.Text; + Program.LocalSettings.Language = languageTextBox.Text; + + Program.LocalSettings.Save(); + + DialogResult = DialogResult.OK; + Close(); + } + + private void cancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/UserManagement/DatabaseSettingsDlg.resx b/UserManagement/DatabaseSettingsDlg.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/UserManagement/DatabaseSettingsDlg.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/UserManagement/LocalSettings.cs b/UserManagement/LocalSettings.cs new file mode 100644 index 000000000..94a6983aa --- /dev/null +++ b/UserManagement/LocalSettings.cs @@ -0,0 +1,132 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; + +namespace UserManagement +{ + /// + /// Class to be serialized to an XML file... + /// Public members are local settings. + /// These settings are modified by dialogs invoked by menu items + /// Edit->Preferences ... PreferencesDlg ... S1.1(language, etc. local settings), and + /// Edit->Advanced settings ... AdvancedSettingsDlg ... S1.2(spec. where bench settings are stored) + /// + [XmlRootAttribute("UserManagement")] + public class LocalSettings + { + /// + /// User interface language (used as CultureInfo(..) constructor argument). + /// + public string Language = "en"; + + public string ConnectionString; + + /// + /// Login method: UserName, FullName or Number + /// + public Config.Entities.LoginMethod LoginMethod; + + /// MainWnd + public int MainWndLeft; + public int MainWndTop; + public int MainWndWidth; + public int MainWndHeight; + public bool ManiWndMaximized; + + + public LocalSettings() + { + } + + /// + /// Load public fields of this class from the XML file. + /// + /// LocalSettings object or null when Load() fails + public static LocalSettings Load(string fileName) + { + try + { + using (TextReader reader = new StreamReader(fileName)) + { + LocalSettings ls = (new XmlSerializer(typeof(LocalSettings))).Deserialize(reader) as LocalSettings; + // Copy the settings just in case De-serialize() completes OK + return ls; + } + } + catch (Exception e) + { + string msg = e.Message; + return null; + } + } + + /// + /// Save public fields of this class to the XML file. + /// + public void Save() + { + try + { + using (TextWriter writer = new StreamWriter(Program.LocalSettingsFileName)) + { + (new XmlSerializer(typeof(LocalSettings))).Serialize(writer, this); + } + } + catch (Exception e) + { + string msg = e.Message; + } + } + + /// + /// Updates history stored in a string array by a new latest string. + /// + /// Lste entered string + /// true = updated and saved + public bool UpdateHistory(string lastStrValue, ref string[] history, int maxHistoryLen = 10) + { + if (string.IsNullOrEmpty(lastStrValue)) return false; + + int currentHistoryCount = (history != null) ? history.Length : 0; + + int match = -1; + for (int i = 0; i < currentHistoryCount; i++) + { + if (history[i] == lastStrValue) + { + match = i; + break; + } + } + + if (match >= 0 || currentHistoryCount >= maxHistoryLen) + { + /// History does not have to be (because of a match) or should not be extended (because of the lenght) + if (match < 0) match = currentHistoryCount - 1; + + for (int j = match; j > 0; j--) + { + history[j] = history[j - 1]; + } + history[0] = lastStrValue; + } + else + { + /// History wiil be extended, new item inserted at the beginning + string[] newHistory = new string[currentHistoryCount + 1]; + newHistory[0] = lastStrValue; + for (int j = 1; j <= currentHistoryCount; j++) + { + newHistory[j] = history[j - 1]; + } + history = newHistory; + } + Save(); + return true; + } + } +} diff --git a/UserManagement/Program.cs b/UserManagement/Program.cs index 77dd22867..0becff2ff 100644 --- a/UserManagement/Program.cs +++ b/UserManagement/Program.cs @@ -1,21 +1,284 @@ -using System; +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Windows.Forms; -using Users; +using Users.Entities; +using Users.Forms; +using NHibernate; +using FluentNHibernate; namespace UserManagement { static class Program { + public const string HomeDir = "C:\\UserManagement\\"; /// Contains subdirectories Results, Logs, Images, ... + + /// Program information + public static string Version; /// version string + public static DateTime BuildDateTime; /// date and time of program build + + /// Local settings + public static LocalSettings LocalSettings; + public const string LocalSettingsFileName = "config.xml"; + public const string LocalSettingsBackupName = "config.backup.xml"; + + /// /// The main entry point for the application. /// [STAThread] static void Main() { + /// Program version string + System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); + Version ver = thisAssembly.GetName().Version; + Version = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); + BuildDateTime = new System.IO.FileInfo(thisAssembly.Location).LastWriteTime; + + /// Local program configuration directory including the trailing backslash + string locAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + + Path.DirectorySeparatorChar + "UserManagement" + Path.DirectorySeparatorChar; + + /// Check whether local application data directory exists. + /// If not, create it and copy the initial configuration to this directory. + /// This is done only once after a clean program installation on the first program start-up + try + { + if (!Directory.Exists(locAppDataDir)) + { + Directory.CreateDirectory(locAppDataDir); + Environment.CurrentDirectory = locAppDataDir; + + string sampleConfig = Application.StartupPath + Path.DirectorySeparatorChar + "SampleConfig" + Path.DirectorySeparatorChar; + if (File.Exists(sampleConfig + LocalSettingsFileName)) { File.Copy(sampleConfig + LocalSettingsFileName, LocalSettingsFileName); } + + File.SetAttributes(LocalSettingsFileName, FileAttributes.Normal); + } + else + { + Environment.CurrentDirectory = locAppDataDir; + } + } + catch (Exception e) + { + return; + } + + /// + /// Load the local settings + /// + Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName); + if (Program.LocalSettings == null || Program.LocalSettings.ConnectionString == null) + { + /// Loading local seetings from regular config file failed. Use the backup + Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsBackupName); + if (Program.LocalSettings == null || Program.LocalSettings.ConnectionString == null) + { + return; /// Fatal error + } + else + { + LocalSettings.Save(); /// Save the settings to overwrite the wrong file + } + } + else + { + /// Loading local seetings from the regular config file was successful. Update the backup + File.Copy(Program.LocalSettingsFileName, Program.LocalSettingsBackupName, true); + } + + + try + { + string culture = LocalSettings.Language.Replace('_', '-'); + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); + } + catch (Exception e) + { + string msg = e.Message; + MessageBox.Show("Selected language not supported.\nUsing English.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); + System.Threading.Thread.CurrentThread.CurrentUICulture = + new System.Globalization.CultureInfo("en"); + } + + + /// This belongs to Application.Run(new MainWnd()) ... + /// and should be executed before opening 'loginDlg' Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + + + /// User login + bool retryLogin = true; /// true = stay in a login loop + do + { + LoginDlg loginDlg; + if (LocalSettings.LastBenchName != null) + { + loginDlg = new LoginDlg(); + } + else + { + loginDlg = new LoginDlg(); + } + loginDlg.Method = LocalSettings.LoginMethod; + DialogResult dr = loginDlg.ShowDialog(); + + if (dr == DialogResult.Cancel) + { + return; /// Login canceled --> Exit application + } + else + { + for (int i = 0; i < LocalSettings.BenchesCount; i++) + { + if (LocalSettings.TestBenches[i].BenchName == loginDlg.BenchName) + { + log.FatalFormat("Test bench name: {0}", loginDlg.BenchName); + + Config.IUser loadedUser = null; + try + { + bool authorized = false; + + if (User.IsPowerUser(loginDlg.Alias, loginDlg.Password)) + { + loadedUser = new User(loginDlg.Alias, 6, true); + authorized = loadedUser.Authorize(loginDlg.Alias, loginDlg.Password); + } + + /// + /// Try authorisation with Users DB first + /// + if (!authorized) + { + bool settingsChanged = false; + + if (string.IsNullOrEmpty(LocalSettings.TestBenches[i].UsersDBSettings.ConnectionString)) + { + LocalSettings.TestBenches[i].UsersDBSettings.ConnectionString = LocalSettings.TestBenches[i].ProceduresDBSettings.ConnectionString; + LocalSettings.TestBenches[i].UsersDBSettings.DbType = LocalSettings.TestBenches[i].ProceduresDBSettings.DbType; + settingsChanged = true; + } + + /// Load and authorise user from the UsersDB database + try + { + switch (loginDlg.Method) + { + default: + case Config.Entities.LoginMethod.UserName: + loadedUser = Users.Entities.User.LoadUserByName(loginDlg.Alias, LocalSettings.TestBenches[i].UsersDBSettings); + if (loadedUser != null) authorized = loadedUser.Authorize(loginDlg.Alias, loginDlg.Password); + break; + case Config.Entities.LoginMethod.FullName: + loadedUser = Users.Entities.User.LoadUserByFullName(loginDlg.Alias, LocalSettings.TestBenches[i].UsersDBSettings); + if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlg.Alias, loginDlg.Password); + break; + case Config.Entities.LoginMethod.Number: + int number; + if (!int.TryParse(loginDlg.Alias, out number)) break; + loadedUser = Users.Entities.User.LoadUserByNumber(number, LocalSettings.TestBenches[i].UsersDBSettings); + if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlg.Password); + break; + } + } + catch + { + authorized = false; + } + + if (settingsChanged && authorized) LocalSettings.Save(); + } + + /// + /// One more attempt: authorisation with Config DB + /// + if (!authorized) + { + /// Load and authorise user from the Config database + try + { + switch (loginDlg.Method) + { + default: + case Config.Entities.LoginMethod.UserName: + loadedUser = Config.Entities.User.LoadUserByName(loginDlg.Alias, LocalSettings.TestBenches[i].ProceduresDBSettings); + if (loadedUser != null) authorized = loadedUser.Authorize(loginDlg.Alias, loginDlg.Password); + break; + case Config.Entities.LoginMethod.FullName: + loadedUser = Config.Entities.User.LoadUserByFullName(loginDlg.Alias, LocalSettings.TestBenches[i].ProceduresDBSettings); + if (loadedUser != null) authorized = loadedUser.AuthorizeFullName(loginDlg.Alias, loginDlg.Password); + break; + case Config.Entities.LoginMethod.Number: + int number; + if (!int.TryParse(loginDlg.Alias, out number)) break; + loadedUser = Config.Entities.User.LoadUserByNumber(number, LocalSettings.TestBenches[i].ProceduresDBSettings); + if (loadedUser != null) authorized = loadedUser.AuthorizeNumber(number, loginDlg.Password); + break; + } + } + catch + { + authorized = false; + } + } + + if (authorized) + { + LocalSettings.LoginMethod = loginDlg.Method; /// Save the login method actually used + + Users.DB.ConnectionString = Config.Data.CurrentBench.WaterMetersDBSettings.ConnectionString; + Users.DB.LoadSharedData(); + + /// This is to trigger an exception in case of a power user and no Config database + IList listOfProcedures = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config) + .QueryOver() + .List(); + + retryLogin = false; + break; + } + + if (retryLogin) + { + /// Close Fluent NHibernate + MessageBox.Show("Invalid user, password or bench", "Error", MessageBoxButtons.OK); + } + } + catch (Exception) + { + /// Database connect failed, ask what to do + switch ((new DatabaseSettingsDlg().ShowDialog()) + { + case DialogResult.Abort: return; /// Exit program + case DialogResult.Retry: break; /// Retry the loop + default: + /// Open 'DatabaseSetingsDlg' and retry DB connect on OK + if (new Users.Forms.LoginDlg(true).ShowDialog() == DialogResult.Cancel || + new BenchesDlg().ShowDialog() == DialogResult.Cancel) + { + return; /// Exit program + } + Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName); + if (Program.LocalSettings == null) return; /// Fatal error + break; /// Retry the loop + } + } + } // if benchname is OK + } // for all benches in local settings loop + } // not Canceled + } //do + while (retryLogin); + + IList listOfUsers = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config) + .QueryOver() + .List(); + Application.Run(new Users.Forms.UserManagementDlg()); } } diff --git a/UserManagement/Resources/Strings.Designer.cs b/UserManagement/Resources/Strings.Designer.cs new file mode 100644 index 000000000..7831d9fc3 --- /dev/null +++ b/UserManagement/Resources/Strings.Designer.cs @@ -0,0 +1,108 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace UserManagement.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Strings { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Strings() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UserManagement.Resources.Strings", typeof(Strings).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Cancel. + /// + internal static string CancelBtnText { + get { + return ResourceManager.GetString("CancelBtnText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Connection string. + /// + internal static string Connection_string { + get { + return ResourceManager.GetString("Connection_string", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Language. + /// + internal static string Language { + get { + return ResourceManager.GetString("Language", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to OK. + /// + internal static string OkBtnText { + get { + return ResourceManager.GetString("OkBtnText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Settings. + /// + internal static string Settings { + get { + return ResourceManager.GetString("Settings", resourceCulture); + } + } + } +} diff --git a/UserManagement/Resources/Strings.resx b/UserManagement/Resources/Strings.resx new file mode 100644 index 000000000..810de16e5 --- /dev/null +++ b/UserManagement/Resources/Strings.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cancel + + + Connection string + + + Language + + + OK + + + Settings + + \ No newline at end of file diff --git a/UserManagement/UserManagement.csproj b/UserManagement/UserManagement.csproj index 21080cdea..636b7c732 100644 --- a/UserManagement/UserManagement.csproj +++ b/UserManagement/UserManagement.csproj @@ -35,6 +35,12 @@ 4 + + ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll + + + ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll + @@ -47,8 +53,23 @@ + + Form + + + DatabaseSettingsDlg.cs + + + + True + True + Strings.resx + + + DatabaseSettingsDlg.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -59,6 +80,10 @@ Resources.resx True + + ResXFileCodeGenerator + Strings.Designer.cs + SettingsSingleFileGenerator @@ -71,6 +96,10 @@ + + {743DF7DB-C7B6-42EB-986D-0F485E5588E4} + Config + {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} Users diff --git a/Users/Forms/LoginDlg.cs b/Users/Forms/LoginDlg.cs index 91c3e5855..b413dd8ae 100644 --- a/Users/Forms/LoginDlg.cs +++ b/Users/Forms/LoginDlg.cs @@ -25,7 +25,7 @@ namespace Users.Forms bool noDatabase; - Config.Entities.LoginMethod method; + public Config.Entities.LoginMethod Method; public string VersionString; @@ -97,7 +97,7 @@ namespace Users.Forms string GetAliasLabel() { - switch (method) + switch (Method) { default: case Config.Entities.LoginMethod.UserName: return Strings.User_name; @@ -121,7 +121,7 @@ namespace Users.Forms Config.Entities.User loadedUser = Config.Entities.User.LoadUserByName(user); if (loadedUser != null) { - switch (method) + switch (Method) { default: case Config.Entities.LoginMethod.UserName: @@ -168,9 +168,8 @@ namespace Users.Forms private void aliasLabel_Click(object sender, EventArgs e) { - method++; - if (method == Config.Entities.LoginMethod.Count) - method = 0; + if (++Method == Config.Entities.LoginMethod.Count) Method = 0; + aliasLabel.Text = GetAliasLabel(); } }