From b9b609cabf9d5ae21ef5b4e8ff17cd7636dd23c4 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Sun, 23 Jan 2022 20:06:57 +0100 Subject: [PATCH] Clean-up --- .gitignore | 4 - Common/DBSettings.cs | 4 +- Common/Units.cs | 31 +- Events/Events.csproj | 69 --- Events/Properties/AssemblyInfo.cs | 36 -- Users/DBSettings.cs | 31 -- Users/Entities/Enums.cs | 60 -- Users/Entities/Group.cs | 52 -- Users/Entities/User.cs | 573 ------------------- Users/Forms/EditSelectedUser.Designer.cs | 211 ------- Users/Forms/EditSelectedUser.cs | 343 ------------ Users/Forms/EditSelectedUser.resx | 585 -------------------- Users/Forms/ListViewExtensions.cs | 103 ---- Users/Forms/LoginDlg.Designer.cs | 113 ---- Users/Forms/LoginDlg.cs | 352 ------------ Users/Forms/LoginDlg.resx | 300 ---------- Users/Forms/LviIntColumnComparer.cs | 31 -- Users/Forms/LviNameSurnameColumnComparer.cs | 54 -- Users/Forms/LviTextColumnComparer.cs | 31 -- Users/Forms/PasswordChangeDlg.Designer.cs | 147 ----- Users/Forms/PasswordChangeDlg.cs | 187 ------- Users/Forms/PasswordChangeDlg.resx | 411 -------------- Users/Forms/UserManagementDlg.cs | 315 ----------- Users/Forms/UserManagementDlg.designer.cs | 148 ----- Users/Forms/UserManagementDlg.resx | 372 ------------- Users/GlobalData.cs | 25 - Users/Mappings/GroupMap.cs | 24 - Users/Mappings/UserMap.cs | 29 - Users/Properties/AssemblyInfo.cs | 36 -- Users/Resources/Strings.Designer.cs | 522 ----------------- Users/Resources/Strings.cs.resx | 252 --------- Users/Resources/Strings.de.resx | 273 --------- Users/Resources/Strings.fr.resx | 240 -------- Users/Resources/Strings.it.resx | 141 ----- Users/Resources/Strings.pl.resx | 207 ------- Users/Resources/Strings.resx | 273 --------- Users/Resources/Strings.ru.resx | 207 ------- Users/Resources/Strings.zh-CN.resx | 207 ------- Users/Users.csproj | 146 ----- Users/UsersDB.cs | 154 ------ clean.bat | 4 - 41 files changed, 17 insertions(+), 7286 deletions(-) delete mode 100644 Events/Events.csproj delete mode 100644 Events/Properties/AssemblyInfo.cs delete mode 100644 Users/DBSettings.cs delete mode 100644 Users/Entities/Enums.cs delete mode 100644 Users/Entities/Group.cs delete mode 100644 Users/Entities/User.cs delete mode 100644 Users/Forms/EditSelectedUser.Designer.cs delete mode 100644 Users/Forms/EditSelectedUser.cs delete mode 100644 Users/Forms/EditSelectedUser.resx delete mode 100644 Users/Forms/ListViewExtensions.cs delete mode 100644 Users/Forms/LoginDlg.Designer.cs delete mode 100644 Users/Forms/LoginDlg.cs delete mode 100644 Users/Forms/LoginDlg.resx delete mode 100644 Users/Forms/LviIntColumnComparer.cs delete mode 100644 Users/Forms/LviNameSurnameColumnComparer.cs delete mode 100644 Users/Forms/LviTextColumnComparer.cs delete mode 100644 Users/Forms/PasswordChangeDlg.Designer.cs delete mode 100644 Users/Forms/PasswordChangeDlg.cs delete mode 100644 Users/Forms/PasswordChangeDlg.resx delete mode 100644 Users/Forms/UserManagementDlg.cs delete mode 100644 Users/Forms/UserManagementDlg.designer.cs delete mode 100644 Users/Forms/UserManagementDlg.resx delete mode 100644 Users/GlobalData.cs delete mode 100644 Users/Mappings/GroupMap.cs delete mode 100644 Users/Mappings/UserMap.cs delete mode 100644 Users/Properties/AssemblyInfo.cs delete mode 100644 Users/Resources/Strings.Designer.cs delete mode 100644 Users/Resources/Strings.cs.resx delete mode 100644 Users/Resources/Strings.de.resx delete mode 100644 Users/Resources/Strings.fr.resx delete mode 100644 Users/Resources/Strings.it.resx delete mode 100644 Users/Resources/Strings.pl.resx delete mode 100644 Users/Resources/Strings.resx delete mode 100644 Users/Resources/Strings.ru.resx delete mode 100644 Users/Resources/Strings.zh-CN.resx delete mode 100644 Users/Users.csproj delete mode 100644 Users/UsersDB.cs diff --git a/.gitignore b/.gitignore index 652d398f5..b08f65f93 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,6 @@ Encrypt/bin/ Encrypt/obj/ EventViewer/bin/ EventViewer/obj/ -Events/bin/ -Events/obj/ FeatureVectorCalculator/bin/ FeatureVectorCalculator/obj/ GemCard/bin/ @@ -58,8 +56,6 @@ ToFirstMonitor/bin/ ToFirstMonitor/obj/ ToSecondMonitor/bin/ ToSecondMonitor/obj/ -Users/bin/ -Users/obj/ UserManagement/bin/ UserManagement/obj/ WorkflowConfigurator/bin/ diff --git a/Common/DBSettings.cs b/Common/DBSettings.cs index c695f423a..3a8a7d8c9 100644 --- a/Common/DBSettings.cs +++ b/Common/DBSettings.cs @@ -10,14 +10,14 @@ namespace Common /// public class DBSettings : ICloneable { - public Common.DBType DbType; + public DBType DbType; public string ConnectionString; public DBSettings() { } - public DBSettings(Common.DBType dbType, string connectionString) + public DBSettings(DBType dbType, string connectionString) { this.DbType = dbType; this.ConnectionString = connectionString; diff --git a/Common/Units.cs b/Common/Units.cs index 33150d5bf..d39581320 100644 --- a/Common/Units.cs +++ b/Common/Units.cs @@ -2,7 +2,6 @@ /// Copyright (c) 2016-2021 Sensus Slovensko a.s. /// using System; -using System.Reflection; namespace Common { @@ -358,21 +357,21 @@ namespace Common } } - public static bool IsVolume(Unit units) { return IsQuantity(units, Quantity.Volume); } - public static bool IsFlow(Unit units) { return IsQuantity(units, Quantity.Flow); } - public static bool IsMass(Unit units) { return IsQuantity(units, Quantity.Mass); } - public static bool IsTime(Unit units) { return IsQuantity(units, Quantity.Time); } - public static bool IsTemperature(Unit units) { return IsQuantity(units, Quantity.Temperature); } - public static bool IsPressure(Unit units) { return IsQuantity(units, Quantity.Pressure); } - public static bool IsHumidity(Unit units) { return IsQuantity(units, Quantity.Humidity); } - public static bool IsError(Unit units) { return IsQuantity(units, Quantity.Error); } - public static bool IsLength(Unit units) { return IsQuantity(units, Quantity.Length); } - public static bool IsDensity(Unit units) { return IsQuantity(units, Quantity.Density); } - public static bool IsEnergy(Unit units) { return IsQuantity(units, Quantity.Energy); } - public static bool IsPulses(Unit units) { return IsQuantity(units, Quantity.Pulses); } - public static bool IsPulsePerLtr(Unit units) { return IsQuantity(units, Quantity.PulsePerLtr); } - public static bool IsPulsePerKWh(Unit units) { return IsQuantity(units, Quantity.PulsePerKWh); } - public static bool IsConductivity(Unit units) { return IsQuantity(units, Quantity.Conductivity); } + public static bool IsVolume(Unit unit) { return IsQuantity(unit, Quantity.Volume); } + public static bool IsFlow(Unit unit) { return IsQuantity(unit, Quantity.Flow); } + public static bool IsMass(Unit unit) { return IsQuantity(unit, Quantity.Mass); } + public static bool IsTime(Unit unit) { return IsQuantity(unit, Quantity.Time); } + public static bool IsTemperature(Unit unit) { return IsQuantity(unit, Quantity.Temperature); } + public static bool IsPressure(Unit unit) { return IsQuantity(unit, Quantity.Pressure); } + public static bool IsHumidity(Unit unit) { return IsQuantity(unit, Quantity.Humidity); } + public static bool IsError(Unit unit) { return IsQuantity(unit, Quantity.Error); } + public static bool IsLength(Unit unit) { return IsQuantity(unit, Quantity.Length); } + public static bool IsDensity(Unit unit) { return IsQuantity(unit, Quantity.Density); } + public static bool IsEnergy(Unit unit) { return IsQuantity(unit, Quantity.Energy); } + public static bool IsPulses(Unit unit) { return IsQuantity(unit, Quantity.Pulses); } + public static bool IsPulsePerLtr(Unit unit) { return IsQuantity(unit, Quantity.PulsePerLtr); } + public static bool IsPulsePerKWh(Unit unit) { return IsQuantity(unit, Quantity.PulsePerKWh); } + public static bool IsConductivity(Unit unit) { return IsQuantity(unit, Quantity.Conductivity); } diff --git a/Events/Events.csproj b/Events/Events.csproj deleted file mode 100644 index 1427e8939..000000000 --- a/Events/Events.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Debug - AnyCPU - {5D9B49E3-CDF9-4A27-80B4-58141D0EB0E0} - Library - Properties - Events - Events - v4.7.2 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll - - - ..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll - - - ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll - - - ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Events/Properties/AssemblyInfo.cs b/Events/Properties/AssemblyInfo.cs deleted file mode 100644 index 116270cbc..000000000 --- a/Events/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Events")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Events")] -[assembly: AssemblyCopyright("Copyright © 2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3a68150f-6cfc-4f15-a813-cef63bc8bb47")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Users/DBSettings.cs b/Users/DBSettings.cs deleted file mode 100644 index 0c478f0a4..000000000 --- a/Users/DBSettings.cs +++ /dev/null @@ -1,31 +0,0 @@ -/// -/// Copyright (c) 2013-2017 Sensus Metering Systems -/// -using System; - -namespace Users -{ - /// - /// Database settings required to make a connection - /// - public class DBSettings : ICloneable - { - public Users.Entities.DBType DbType; - public string ConnectionString; - - public DBSettings() - { - } - - public DBSettings(Users.Entities.DBType dbType, string connectionString) - { - this.DbType = dbType; - this.ConnectionString = connectionString; - } - - public object Clone() - { - return new DBSettings(DbType, ConnectionString); - } - } -} diff --git a/Users/Entities/Enums.cs b/Users/Entities/Enums.cs deleted file mode 100644 index 914c93753..000000000 --- a/Users/Entities/Enums.cs +++ /dev/null @@ -1,60 +0,0 @@ -/// -/// Copyright (c) 2017-2020 Sensus Slovensko a.s. -/// -using System; - -namespace Users.Entities -{ - /// Identifies the type of a database - public enum DBType - { - None, /// Database disabled - MySql, /// MySQL database - SQLite, /// SQLite - Count - } - - /// Identifies the database based on the content - public enum DBKind - { - Config, - Results, - RemoteConfig, - Count - } - - public enum LoginMethod - { - UserName, /// = alias, abbreviation - FullName, /// = description - Number, - Count - } - - public enum AuthorizedAs - { - PowerUser, - LocalUser, - RemoteUser, - Count - } - - /// - /// GID-s of user groups, each user is member of one or more groups. - /// - public enum GID - { - Testers, - TestingSpecialists, - HeadOfLab, - MaintenanceSpecialists, - Metrologists, - CalibrationSpecialists, - Administrators, /// application / network / database administrator - TraceabilityManagement, - MetrologicalAuthority, - WaterMeterAuthority, - NrOfGroups, /// Number of groups (this is not a GroupID) - None, - } -} diff --git a/Users/Entities/Group.cs b/Users/Entities/Group.cs deleted file mode 100644 index 67d08d470..000000000 --- a/Users/Entities/Group.cs +++ /dev/null @@ -1,52 +0,0 @@ -/// -/// Copyright (c) 2016-2020 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using Users.Resources; - -namespace Users.Entities -{ - public class Group - { - public virtual int Id { get; protected set; } - public virtual GID GID { get; set; } - public virtual long AccessFlags { get; set; } /// Bitfield of access flags: bit0 .. bit62 - public virtual IList Users { get; set; } /// Group can be a member of a list of users - - public Group() - { - Users = new List(); - } - - public Group(GID gid) - : this() - { - GID = gid; - } - - public virtual string Gid2Str() - { - return Group.Gid2Str(this.GID); - } - - public static string Gid2Str(GID gid) - { - switch (gid) - { - case GID.Testers: return Strings.tester; - case GID.TestingSpecialists: return Strings.specialist; - case GID.HeadOfLab: return Strings.head_of_lab; - case GID.MaintenanceSpecialists: return Strings.maintenance; - case GID.Metrologists: return Strings.metrologist; - case GID.CalibrationSpecialists: return Strings.calibration_specialist; - case GID.Administrators: return Strings.administrator; - case GID.TraceabilityManagement: return Strings.production_tracing_administrator; - case GID.MetrologicalAuthority: return Strings.metrological_authority; - case GID.WaterMeterAuthority: return Strings.water_meter_authority; - default: - return (gid >= 0 && gid < GID.NrOfGroups) ? gid.ToString() : Strings.invalid; - } - } - } -} diff --git a/Users/Entities/User.cs b/Users/Entities/User.cs deleted file mode 100644 index 51b08b377..000000000 --- a/Users/Entities/User.cs +++ /dev/null @@ -1,573 +0,0 @@ -/// -/// Copyright (c) 2016-2019 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using System.Security.Cryptography; -using System.Text; -using log4net; -using Users.Forms; -using Users.Resources; - -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 - public virtual string Tag { get; set; } - public virtual int Number { get; set; } - public virtual string Password { get; set; } - public virtual string Password2 { get; set; } - public virtual string Password3 { get; set; } - public virtual string Password4 { get; set; } - public virtual DateTime LastPwChange { get; set; } - 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 - 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; } - - public User() - { - this.powerUser = false; - Groups = new List(); - Number = 0; - Tag = string.Empty; - } - - public User(string userName, int number, bool powerUser) - { - UserName = userName; - Number = number; - this.powerUser = powerUser; - Groups = new List(); - FullName = powerUser ? "Power User" : string.Empty; - } - - public virtual void AddGroup(Group group) - { - Groups.Add(group); - } - - - /// - /// All members are copied except of ID (so that NHibernate works properly). - /// List of groups is empty. - /// - /// - /// - public virtual object Clone() - { - User newUser = new User(UserName, Number, false); - newUser.FullName = FullName; - newUser.Number = Number; - newUser.Tag = Tag; - newUser.Password = Password; - newUser.LastPwChange = LastPwChange; - return newUser; - } - - /// ------------- Additional stuff not mapped into the database ------------- - - /// - /// Check whether user is a member of a group. - /// - /// Group GID - /// true is user is a member of the specified group - public virtual bool IsMemberOf(GID groupId) - { - if (powerUser) - { - return true; - } - else if ((groupId >= 0) && (groupId < GID.NrOfGroups)) - { - foreach (var g in Groups) - { - if (g.GID == groupId) return true; - } - } - - return false; - } - - /// - /// Check whether user is a member of any of specified groups. - /// Returns true also when no groups are defined (groupIds = null). - /// - /// An array of group GID-s or null (no membership required) - /// true if user is a member of any of specified groups - public virtual bool IsMemberOf(GID[] groupIds) - { - if (groupIds == null || powerUser) - { - return true; - } - - foreach (var gid in groupIds) - { - if ((gid >= 0) && (gid < GID.NrOfGroups)) - { - /// for all group elements in User.Groups - foreach (var grp in Groups) - { - /// element GID = parameter GroupId ? - if (grp.GID == gid) return true; - } - } - } - - return false; - } - - /// - /// Checks requirements on the password regardless of the password history - /// - /// Password - /// true when the password is OK - public static bool IsPasswordMeetsRequirements(string password, out string explanation) - { - int length = string.IsNullOrEmpty(password) ? 0 : password.Length; - - /// Password length must be at least 6 - if (length < GlobalData.MinPasswdLength) - { - explanation = string.Format(Strings.Password_must_have_at_least_0_characters, GlobalData.MinPasswdLength); - return false; - } - else - { - explanation = string.Empty; - return true; - } - } - - /// - /// Returns true when password was already used in the past - /// - /// Password - /// false when password is new, true when it was used in the past - public virtual bool IsPasswordUsedInPast(string passwordCandidate) - { - string encryptedPW = EncryptedPassword(passwordCandidate); - return (encryptedPW == Password) || (encryptedPW == Password2) || (encryptedPW == Password3); - } - - /// - /// Checks 'LastPwChange' and returns true when password expired - /// - /// - bool IsPasswordExpired() - { - if (IsPowerUser() || IsMemberOf(GID.Administrators) || GlobalData.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)); - } - - /// - /// Sets users password. It then will be encrypted. - /// - /// Password - public virtual void SetPassword(string password) - { - Password4 = Password3; - Password3 = Password2; - Password2 = Password; - Password = EncryptedPassword(password); - LastPwChange = DateTime.Now; - } - - string EncryptedPassword(string password) - { - return getHash(password); - } - - /// - /// Verifies users password. Used by static bool Authorisation(...) - /// - /// Password - /// true if password is correct - public virtual bool IsCorrectPassword(string password) - { - if (string.IsNullOrEmpty(password) && string.IsNullOrEmpty(Password)) - { - /// Currently saved and verified passwords are both empty => return true - return true; - } - - return (Password == EncryptedPassword(password)); - } - - - /// - /// Authorization method: 'requiredGroupMembership' contains a list of required groups. - /// Valid name and password and a mbership in any of theese goups grants access, Authorize(..) returns true. - /// When requiredGroupMembership == null, no membership is required, only name and password must be valid. - /// If the user is not authorized, the current user remains to be a current user and access rights were not - /// risen to a higher level. If you require different behavior, use Unauthorize() before calling Authorize(). - /// - /// User name - /// Password - /// - /// true = authorized - public virtual bool Authorize(string userName, string password, GID[] requiredGroupMembership) - { - if (IsPowerUser(userName, password)) - { - /// User is a power user => authorize - GlobalData.CurrentUser = this; - GlobalData.LastAuthorization = DateTime.Now; - log.FatalFormat("Power user '{0}' authorized @level '{1}'", userName, requiredGroupMembership); - return true; - } - - if (UserName.ToLower() != userName.ToLower()) - { - /// User name does not match => reject authorization - return false; - } - - return CompleteAuthorization(password, requiredGroupMembership); - } - - /// - /// Authorization method: 'requiredGroupMembership' contains a list of required groups. - /// Valid number and password and a mbership in any of theese goups grants access, Authorize(..) returns true. - /// When requiredGroupMembership == null, no membership is required, only number and password must be valid. - /// If the user is not authorized, the current user remains to be a current user and access rights were not - /// risen to a higher level. If you require different behavior, use Unauthorize() before calling Authorize(). - /// - /// User ID number - /// Password - /// - /// true = authorized - public virtual bool AuthorizeNumber(int number, string password, GID[] requiredGroupMembership) - { - if (Number != number) - { - /// User number does not match => reject authorization - return false; - } - - return CompleteAuthorization(password, requiredGroupMembership); - } - - /// - /// Authorization method: 'requiredGroupMembership' contains a list of required groups. - /// Valid name and password and a mbership in any of theese goups grants access, Authorize(..) returns true. - /// When requiredGroupMembership == null, no membership is required, only name and password must be valid. - /// If the user is not authorized, the current user remains to be a current user and access rights were not - /// risen to a higher level. If you require different behavior, use Unauthorize() before calling Authorize(). - /// - /// - /// - /// - /// true = authorized - public virtual bool AuthorizeFullName(string fullName, string password, GID[] requiredGroupMembership) - { - if (FullName.ToLower() != fullName.ToLower()) - { - /// Full number does not match => reject authorization - return false; - } - - return CompleteAuthorization(password, requiredGroupMembership); - } - - /// - /// Verfy password, group membershit and password expiration time) - /// - /// Password - /// Required group membership - /// true = authorized - bool CompleteAuthorization(string password, GID[] requiredGroupMembership) - { - if (!IsMemberOf(requiredGroupMembership) || !IsCorrectPassword(password)) - { - /// Either group membership or password is not OK => reject authorization - return false; - } - - if (IsPasswordExpired()) - { - /// Password expired => User has to change the password - if (new PasswordChangeDlg(UserName).ShowDialog() != System.Windows.Forms.DialogResult.OK) - { - /// User did not change the password => reject authorization - return false; - } - } - - /// All OK => complete authorization - GlobalData.CurrentUser = this; - GlobalData.LastAuthorization = DateTime.Now; - log.FatalFormat("User '{0}' authorized @level '{1}'", UserName, requiredGroupMembership); - return true; - } - - /// - /// Authorization method: 'requiredGroupMembership' contains a list of required groups. - /// Valid TAG and a mbership in any of theese goups grants access, Authorize(..) returns true. - /// When requiredGroupMembership == null, no membership is required, only the TAG must be valid. - /// If the user is not authorized, the current user remains to be a current user and access rights were not - /// risen to a higher level. If you require different behavior, use Unauthorize() before calling Authorize(). - /// - /// Tag (RFID, NFC, ... s/n) - /// - /// true = authorized - public virtual bool AuthorizeTag(string tag, GID[] requiredGroupMembership) - { - if (Tag != tag) - { - /// Tag number does not match => reject authorization - return false; - } - - if (IsMemberOf(requiredGroupMembership)) - { - /// Group membersip is OK _and_ password is OK => authorize - GlobalData.CurrentUser = this; - GlobalData.LastAuthorization = DateTime.Now; - log.FatalFormat("User with Tag={0} authorized @level '{1}'", tag, requiredGroupMembership); - return true; - } - else - { - /// Either group membership or password is not OK => reject authorization - return false; - } - } - - /// - /// Returns a 'User' with a given username from a database. - /// - /// User name for the query - /// reference to a 'User' (if it exists) or null - public static User AuthorizeDummyUser(string username) - { - User user = new User(); - user.UserName = username; - GlobalData.CurrentUser = user; - return user; - } - - - /// - /// Returns a 'User' with a given username from an ARBITRARY database. - /// - /// User name for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByName(string userName, DBSettings dbSettings) - { - if (dbSettings == null || string.IsNullOrEmpty(dbSettings.ConnectionString)) return null; - - UsersDB.DbType = dbSettings.DbType; - UsersDB.ConnectionString = dbSettings.ConnectionString; - return LoadUserByName(userName); - } - - /// - /// Returns a 'User' with a given username from the users database. - /// - /// User name for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByName(string userName) - { - IList listOfUsers = UsersDB.CreateSession() - .QueryOver() - .Where(x => (x.UserName == userName)) - .List(); - - return (listOfUsers.Count > 0) ? listOfUsers[0] : null; - } - - - /// - /// Returns a 'User' with a given full name from an ARBITRARY database. - /// - /// Full name for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByFullName(string fullName, DBSettings dbSettings) - { - if (dbSettings == null || string.IsNullOrEmpty(dbSettings.ConnectionString)) return null; - - UsersDB.DbType = dbSettings.DbType; - UsersDB.ConnectionString = dbSettings.ConnectionString; - return LoadUserByFullName(fullName); - } - - /// - /// Returns a 'User' with a given full name from the users database. - /// - /// Full name for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByFullName(string fullName) - { - IList listOfUsers = UsersDB.CreateSession() - .QueryOver() - .Where(x => (x.FullName == fullName)) - .List(); - - return (listOfUsers.Count > 0) ? listOfUsers[0] : null; - } - - - /// - /// Returns a 'User' with a given username from an ARBITRARY database. - /// - /// User ID number for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByNumber(int number, DBSettings dbSettings) - { - if (dbSettings == null || string.IsNullOrEmpty(dbSettings.ConnectionString)) return null; - - UsersDB.DbType = dbSettings.DbType; - UsersDB.ConnectionString = dbSettings.ConnectionString; - return LoadUserByNumber(number); - } - - /// - /// Returns a 'User' with a given username from the users database. - /// - /// User ID number for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByNumber(int number) - { - IList listOfUsers = UsersDB.CreateSession() - .QueryOver() - .Where(x => (x.Number == number)) - .List(); - - return (listOfUsers.Count > 0) ? listOfUsers[0] : null; - } - - - /// - /// Returns a 'User' with a given RFID/NFC tag s/n from an ARBITRARY database. - /// - /// Tag of a user for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByTag(string tag, DBSettings dbSettings) - { - if (dbSettings == null || string.IsNullOrEmpty(dbSettings.ConnectionString)) return null; - - UsersDB.DbType = dbSettings.DbType; - UsersDB.ConnectionString = dbSettings.ConnectionString; - return LoadUserByTag(tag); - } - - /// - /// Returns a 'User' with a given RFID/NFC tag s/n from the users database. - /// - /// Tag of a user for the query - /// reference to a 'User' (if it exists) or null - public static User LoadUserByTag(string tag) - { - IList listOfUsers = UsersDB.CreateSession() - .QueryOver() - .Where(x => (x.Tag == tag)) - .List(); - - return (listOfUsers.Count > 0) ? listOfUsers[0] : null; - } - - - /// - /// returns an IList of all Users - /// - public static IList GetAllUsers() - { - return UsersDB.CreateSession().QueryOver().List(); - } - - - /// - /// Unauthorize, abandon current users authorization. - /// - public static void Unauthorize() - { - GlobalData.CurrentUser = null; - GlobalData.LastAuthorization = DateTime.Now; - } - - /// - /// getHash encrypts a string - /// - /// the string to encrypt - /// - public static string getHash(string text) - { - byte[] bytes = Encoding.Unicode.GetBytes(text); - SHA512Managed hashstring = new SHA512Managed(); - byte[] hash = hashstring.ComputeHash(bytes); - string hashString = string.Empty; - foreach (byte x in hash) - { - hashString += String.Format("{0:x2}", x); - } - 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. - /// - /// User name - /// Password - /// true = authenticated, false = refused - public static bool IsPowerUser(string userName, string password) - { - DateTime date = DateTime.Now.Date; - int number = (date.Year % 10) + 10 * (date.Month - 1) + 120 * date.Day; - string passwordOfDay = Convert.ToString(number, 8); - - return (userName.Equals("milan") && password.Equals("kremik")) || - (userName.Equals("igor") && password.Equals("mojronko8")) || - (userName.Equals("MARIAN") && password.Equals("NM-309BN")) || - (userName.Equals("lubo1212") && password.Equals("Tatry52")) || - (userName.Equals("Michal") && password.Equals("1236natahA8")) || - (userName.Equals("martin") && password.Equals("vaclavek84")) || - (userName.Equals("pakan") && password.Equals("kuriatko")) || - (userName.Equals("augustin") && password.Equals("jaugust")) || - (userName.Equals("JCermak") && password.Equals("Zt6911")) || - (userName.Equals("gilles") && password.Equals("alibaba")) || - (userName.Equals(passwordOfDay) && password.Equals(passwordOfDay)); - } - } -} diff --git a/Users/Forms/EditSelectedUser.Designer.cs b/Users/Forms/EditSelectedUser.Designer.cs deleted file mode 100644 index 6482fa59b..000000000 --- a/Users/Forms/EditSelectedUser.Designer.cs +++ /dev/null @@ -1,211 +0,0 @@ -/// -/// Copyright (c) 2017 Sensus Metering Systems -/// -namespace Users.Forms -{ - partial class EditSelectedUser - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditSelectedUser)); - this.txtName = new System.Windows.Forms.TextBox(); - this.nameLabel = new System.Windows.Forms.Label(); - this.okBtn = new System.Windows.Forms.Button(); - this.cancelBtn = new System.Windows.Forms.Button(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.passwordLabel = new System.Windows.Forms.Label(); - this.txtDescription = new System.Windows.Forms.TextBox(); - this.descriptionLabel = new System.Windows.Forms.Label(); - this.checkedListBoxGroups = new System.Windows.Forms.CheckedListBox(); - this.groupsLabel = new System.Windows.Forms.Label(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.repeatPasswordLabel = new System.Windows.Forms.Label(); - this.txtRepeatPassword = new System.Windows.Forms.TextBox(); - this.codeLabel = new System.Windows.Forms.Label(); - this.txtCode = new System.Windows.Forms.TextBox(); - this.tagLabel = new System.Windows.Forms.Label(); - this.txtTag = new System.Windows.Forms.TextBox(); - this.userHasToChangePasswdCheckBox = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // txtName - // - resources.ApplyResources(this.txtName, "txtName"); - this.txtName.Name = "txtName"; - this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); - this.txtName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtName_KeyPress); - this.txtName.Validated += new System.EventHandler(this.txtName_Validated); - // - // nameLabel - // - resources.ApplyResources(this.nameLabel, "nameLabel"); - this.nameLabel.Name = "nameLabel"; - // - // okBtn - // - resources.ApplyResources(this.okBtn, "okBtn"); - this.okBtn.Name = "okBtn"; - this.okBtn.UseVisualStyleBackColor = true; - this.okBtn.Click += new System.EventHandler(this.okBtn_Click); - // - // cancelBtn - // - resources.ApplyResources(this.cancelBtn, "cancelBtn"); - this.cancelBtn.Name = "cancelBtn"; - this.cancelBtn.UseVisualStyleBackColor = true; - this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click); - // - // txtPassword - // - resources.ApplyResources(this.txtPassword, "txtPassword"); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged); - // - // passwordLabel - // - resources.ApplyResources(this.passwordLabel, "passwordLabel"); - this.passwordLabel.Name = "passwordLabel"; - // - // txtDescription - // - resources.ApplyResources(this.txtDescription, "txtDescription"); - this.txtDescription.Name = "txtDescription"; - this.txtDescription.TextChanged += new System.EventHandler(this.txtDescription_TextChanged); - this.txtDescription.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtDescription_KeyPress); - // - // descriptionLabel - // - resources.ApplyResources(this.descriptionLabel, "descriptionLabel"); - this.descriptionLabel.Name = "descriptionLabel"; - // - // checkedListBoxGroups - // - this.checkedListBoxGroups.CheckOnClick = true; - this.checkedListBoxGroups.FormattingEnabled = true; - resources.ApplyResources(this.checkedListBoxGroups, "checkedListBoxGroups"); - this.checkedListBoxGroups.Name = "checkedListBoxGroups"; - this.checkedListBoxGroups.Click += new System.EventHandler(this.checkedListBoxGroups_Click); - // - // groupsLabel - // - resources.ApplyResources(this.groupsLabel, "groupsLabel"); - this.groupsLabel.Name = "groupsLabel"; - // - // repeatPasswordLabel - // - resources.ApplyResources(this.repeatPasswordLabel, "repeatPasswordLabel"); - this.repeatPasswordLabel.Name = "repeatPasswordLabel"; - // - // txtRepeatPassword - // - resources.ApplyResources(this.txtRepeatPassword, "txtRepeatPassword"); - this.txtRepeatPassword.Name = "txtRepeatPassword"; - this.txtRepeatPassword.TextChanged += new System.EventHandler(this.txtRepeatPassword_TextChanged); - // - // codeLabel - // - resources.ApplyResources(this.codeLabel, "codeLabel"); - this.codeLabel.Name = "codeLabel"; - // - // txtCode - // - resources.ApplyResources(this.txtCode, "txtCode"); - this.txtCode.Name = "txtCode"; - this.txtCode.TextChanged += new System.EventHandler(this.txtCode_TextChanged); - // - // tagLabel - // - resources.ApplyResources(this.tagLabel, "tagLabel"); - this.tagLabel.Name = "tagLabel"; - // - // txtTag - // - resources.ApplyResources(this.txtTag, "txtTag"); - this.txtTag.Name = "txtTag"; - // - // userHasToChangePasswdCheckBox - // - resources.ApplyResources(this.userHasToChangePasswdCheckBox, "userHasToChangePasswdCheckBox"); - this.userHasToChangePasswdCheckBox.Name = "userHasToChangePasswdCheckBox"; - this.userHasToChangePasswdCheckBox.UseVisualStyleBackColor = true; - // - // EditSelectedUser - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.userHasToChangePasswdCheckBox); - this.Controls.Add(this.tagLabel); - this.Controls.Add(this.txtTag); - this.Controls.Add(this.codeLabel); - this.Controls.Add(this.txtCode); - this.Controls.Add(this.repeatPasswordLabel); - this.Controls.Add(this.txtRepeatPassword); - this.Controls.Add(this.groupsLabel); - this.Controls.Add(this.checkedListBoxGroups); - this.Controls.Add(this.cancelBtn); - this.Controls.Add(this.okBtn); - this.Controls.Add(this.descriptionLabel); - this.Controls.Add(this.passwordLabel); - this.Controls.Add(this.nameLabel); - this.Controls.Add(this.txtDescription); - this.Controls.Add(this.txtPassword); - this.Controls.Add(this.txtName); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.Name = "EditSelectedUser"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.EditSelectedUser_FormClosing); - this.Load += new System.EventHandler(this.EditSelectedUser_Load); - this.Shown += new System.EventHandler(this.EditSelectedUser_Shown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox txtName; - private System.Windows.Forms.Label nameLabel; - private System.Windows.Forms.Button okBtn; - private System.Windows.Forms.Button cancelBtn; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.Label passwordLabel; - private System.Windows.Forms.TextBox txtDescription; - private System.Windows.Forms.Label descriptionLabel; - private System.Windows.Forms.CheckedListBox checkedListBoxGroups; - private System.Windows.Forms.Label groupsLabel; - private System.Windows.Forms.ToolTip toolTip1; - private System.Windows.Forms.Label repeatPasswordLabel; - private System.Windows.Forms.TextBox txtRepeatPassword; - private System.Windows.Forms.Label codeLabel; - private System.Windows.Forms.TextBox txtCode; - private System.Windows.Forms.Label tagLabel; - private System.Windows.Forms.TextBox txtTag; - private System.Windows.Forms.CheckBox userHasToChangePasswdCheckBox; - } -} \ No newline at end of file diff --git a/Users/Forms/EditSelectedUser.cs b/Users/Forms/EditSelectedUser.cs deleted file mode 100644 index 29f27e045..000000000 --- a/Users/Forms/EditSelectedUser.cs +++ /dev/null @@ -1,343 +0,0 @@ -/// -/// Copyright (c) 2017-2018 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using NHibernate; -using Users.Entities; -using Users.Resources; -using GemCard; -using System.Drawing; - -namespace Users.Forms -{ - public partial class EditSelectedUser : Form - { - NHibernate.ISession session; - User user; - IList displayedGroups; - - - bool[] oriGroupMember; /// index is gid, size is Grp.Count - - - /// Smart card support, card S/N is used as user.Tag - GemCard.CardNative card; - string smartCardReader; - - - public EditSelectedUser() - { - InitializeComponent(); - this.toolTip1.SetToolTip(this.txtName, string.Format(Strings.max_0_alphanum_chars, 20)); - oriGroupMember = new bool[(displayedGroups != null) ? displayedGroups.Count : 0]; - okBtn.Enabled = false; - } - - public EditSelectedUser(NHibernate.ISession session, User user, IList displayedGroups) - : this() - { - this.session = session; - this.user = user; - this.displayedGroups = displayedGroups; - - oriGroupMember = new bool[(displayedGroups != null) ? displayedGroups.Count : 0]; - } - - private void EditSelectedUser_Load(object sender, EventArgs e) - { - Localize(); - - txtName.Text = user.UserName; - txtCode.Text = user.Number.ToString(); - txtTag.Text = string.IsNullOrEmpty(user.Tag) ? string.Empty : user.Tag; - txtDescription.Text = user.FullName; - txtPassword.Text = string.Empty; - txtRepeatPassword.Text = string.Empty; - - ShowGroups(); - - smartCardReader = null; /// null = No smart card reader detected - - try - { - card = new CardNative(); - - /// Find NFC smart card reader - string[] cardReaders = card.ListReaders(); - if (cardReaders != null) - { - foreach (var crd in cardReaders) - { - if (crd.Contains("NFC")) - { - smartCardReader = crd; /// NFC smart card reader detected - break; - } - } - } - - if (!string.IsNullOrEmpty(smartCardReader)) - { - /// Reader found, initialize NFC smart card reader - - card.OnCardInserted += delegate(object sndr, CardInsertedEventArgs args) - { - if (InvokeRequired) { Invoke(new EventHandler(OnCardInserted), sndr, args); } - else OnCardInserted(sndr, args); - }; - - card.OnCardRemoved += delegate(object sndr, CardRemovedEventArgs args) - { - if (InvokeRequired) { Invoke(new EventHandler(OnCardRemoved), sndr, args); } - else OnCardRemoved(sndr, args); - }; - - card.StartCardEvents(smartCardReader); - - Text += " (NFC)"; - txtTag.Enabled = true; - } - } - catch (Exception) - { - smartCardReader = null; - } - } - - void Localize() - { - Text = Strings.Edit_User; - nameLabel.Text = Strings.Name; - passwordLabel.Text = Strings.Password; - repeatPasswordLabel.Text = Strings.Repeat_password; - codeLabel.Text = Strings.User_code; - tagLabel.Text = Strings.Tag; - descriptionLabel.Text = Strings.DescriptionColHdr; - groupsLabel.Text = Strings.Groups; - okBtn.Text = Strings.OkBtnText; - cancelBtn.Text = Strings.CancelBtnText; - } - - public void ShowGroups() - { - checkedListBoxGroups.Items.Clear(); - for (int i= 0; i < displayedGroups.Count; i++) - { - Group group = displayedGroups[i]; - - bool boolIsMember = oriGroupMember[i] = user.IsMemberOf(group.GID); - checkedListBoxGroups.Items.Add(group.Gid2Str()); - checkedListBoxGroups.SetItemCheckState(i, boolIsMember ? CheckState.Checked : CheckState.Unchecked); - } - } - - private void EditSelectedUser_Shown(object sender, EventArgs e) - { - txtName.Focus(); - } - - - public bool Save() - { - // todo: check if this name is given to another user - if (IsUserNameAlreadyTaken(txtName.Text)) - { - MessageBox.Show(Strings.Username_taken); - return false; - } - - if (IsTagAlreadyTaken(txtTag.Text)) - { - MessageBox.Show(Strings.Tag_taken); - return false; - } - - ITransaction transaction = session.BeginTransaction(); - - try - { - Cursor.Current = Cursors.WaitCursor; - - user.UserName = txtName.Text; - user.FullName = txtDescription.Text; - user.Number = int.Parse(txtCode.Text); - user.Tag = string.IsNullOrEmpty(txtTag.Text) ? null : txtTag.Text; - - if (txtPassword.Text != string.Empty) - { - if (!userHasToChangePasswdCheckBox.Checked) - { - /// Password will not be changed, therefore it should meet requirements - string explanation; - if (!Entities.User.IsPasswordMeetsRequirements(txtPassword.Text, out explanation)) - { - /// Password does not meet requirements - MessageBox.Show(Strings.Password_does_not_meet_requirements + Environment.NewLine + explanation, - Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand); - return false; - } - } - - user.SetPassword(txtPassword.Text); - } - - if (userHasToChangePasswdCheckBox.Checked) - { - user.LastPwChange = DateTime.MinValue; - } - - /// - /// Groups - /// - IList groups = user.Groups; /// = session.QueryOver().Where(x => (x.User.Id == user.Id)).List(); - for (int i = 0; i < displayedGroups.Count; i++ ) - { - Group group = displayedGroups[i]; - bool newIsMember = checkedListBoxGroups.GetItemChecked(i); - - if (!newIsMember && oriGroupMember[i]) - { - user.Groups.Remove(group); - } - else if (newIsMember && !oriGroupMember[i]) - { - user.Groups.Add(group); - } - } - - session.SaveOrUpdate(user); - transaction.Commit(); - session.Flush(); - Cursor.Current = Cursors.Default; - return true; - } - catch (Exception exc) - { - transaction.Rollback(); - MessageBox.Show(string.Format("{0}{1}{2}", Strings.Save_or_update_user_failed, Environment.NewLine, exc.Message), - Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - Cursor.Current = Cursors.Default; - return false; - } - } - - /// - /// returns true if the username allready exists for another user - /// - private bool IsUserNameAlreadyTaken(string userName) - { - // Have a look into all other users - IList ListOfUsers = User.GetAllUsers(); - foreach (var person in ListOfUsers) - { - if (person.Id != user.Id) - { - /// Other user then the current one - if (person.UserName.ToLower() == userName.ToLower()) - { - return true; // Name is equal = already taken - } - } - } - return false; - } - - /// - /// returns true if the username allready exists for another user - /// - private bool IsTagAlreadyTaken(string tag) - { - if (string.IsNullOrEmpty(tag)) return false; /// No tag - - // Have a look into all other users - IList ListOfUsers = User.GetAllUsers(); - foreach (var person in ListOfUsers) - { - if (person.Id != user.Id) - { - // Other user then the current one - if (person.Tag == tag) - { - return true; // Tag is equal = already taken - } - } - } - return false; - } - - - private void okBtn_Click(object sender, EventArgs e) - { - if (Save()) - { - DialogResult = DialogResult.OK; - this.Close(); - } - } - - private void cancelBtn_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - this.Close(); - } - - - private void txtName_Validated(object sender, EventArgs e) { UpdateOKButton(); } - private void txtName_KeyPress(object sender, KeyPressEventArgs e) { UpdateOKButton(); } - private void txtName_TextChanged(object sender, EventArgs e) { UpdateOKButton(); } - private void txtPassword_TextChanged(object sender, EventArgs e) { UpdateOKButton(); } - private void txtRepeatPassword_TextChanged(object sender, EventArgs e) { UpdateOKButton(); } - private void txtDescription_TextChanged(object sender, EventArgs e) { UpdateOKButton(); } - private void txtDescription_KeyPress(object sender, KeyPressEventArgs e) { UpdateOKButton(); } - private void checkedListBoxGroups_Click(object sender, EventArgs e) { UpdateOKButton(); } - private void txtCode_TextChanged(object sender, EventArgs e) { UpdateOKButton(); } - - private void UpdateOKButton() - { - int userCode; - - okBtn.Enabled = (txtName.Text != string.Empty) - && int.TryParse(txtCode.Text, out userCode) - && (txtPassword.Text == txtRepeatPassword.Text); - } - - - void OnCardInserted(object sender, CardInsertedEventArgs args) - { - string tag = string.Empty; - try - { - BackColor = Color.Green; - card.Connect(smartCardReader, SHARE.Shared, PROTOCOL.T0orT1); - - /// Read the serial number of the card - APDUResponse response = card.Transmit(new APDUCommand(0xFF, 0xCA, 0x00, 0x00, null, 7)); - txtTag.Text = response.ToString(); - - card.Disconnect(DISCONNECT.Leave); - } - catch - { - txtTag.Text = string.Empty; - } - } - - - void OnCardRemoved(object sender, CardRemovedEventArgs args) - { - BackColor = SystemColors.Control; - } - - private void EditSelectedUser_FormClosing(object sender, FormClosingEventArgs e) - { - if (!string.IsNullOrEmpty(smartCardReader)) - { - try { card.StopCardEvents(); } - catch { } - } - } - } -} diff --git a/Users/Forms/EditSelectedUser.resx b/Users/Forms/EditSelectedUser.resx deleted file mode 100644 index 8b6c1852e..000000000 --- a/Users/Forms/EditSelectedUser.resx +++ /dev/null @@ -1,585 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - 137, 9 - - - 200, 20 - - - - 1 - - - txtName - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 16 - - - True - - - 9, 12 - - - 35, 13 - - - 0 - - - Name - - - nameLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 13 - - - - NoControl - - - 137, 390 - - - 94, 31 - - - 15 - - - OK - - - okBtn - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 10 - - - 243, 390 - - - 94, 31 - - - 16 - - - Cancel - - - cancelBtn - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 9 - - - 137, 35 - - - * - - - 200, 20 - - - 3 - - - txtPassword - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 15 - - - True - - - 9, 38 - - - 53, 13 - - - 2 - - - Password - - - passwordLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 12 - - - 137, 160 - - - True - - - 200, 59 - - - 12 - - - txtDescription - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 14 - - - True - - - 9, 163 - - - 60, 13 - - - 11 - - - Description - - - descriptionLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 11 - - - 137, 224 - - - 200, 154 - - - 14 - - - checkedListBoxGroups - - - System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 8 - - - True - - - 9, 224 - - - 41, 13 - - - 13 - - - Groups - - - groupsLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 7 - - - 17, 17 - - - True - - - NoControl - - - 9, 63 - - - 90, 13 - - - 4 - - - Repeat password - - - repeatPasswordLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - - - 137, 60 - - - * - - - 200, 20 - - - 5 - - - txtRepeatPassword - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 6 - - - True - - - NoControl - - - 9, 113 - - - 32, 13 - - - 6 - - - Code - - - codeLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - 137, 110 - - - 200, 20 - - - 7 - - - txtCode - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 4 - - - True - - - NoControl - - - 9, 138 - - - 26, 13 - - - 8 - - - Tag - - - tagLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - False - - - 137, 135 - - - 200, 20 - - - 9 - - - txtTag - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - True - - - 138, 87 - - - 188, 17 - - - 17 - - - User has to change the password - - - userHasToChangePasswdCheckBox - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - True - - - 6, 13 - - - 375, 432 - - - Edit User - - - toolTip1 - - - System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - EditSelectedUser - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Users/Forms/ListViewExtensions.cs b/Users/Forms/ListViewExtensions.cs deleted file mode 100644 index f777600bd..000000000 --- a/Users/Forms/ListViewExtensions.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.ComponentModel; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace Users.Forms -{ - [EditorBrowsable(EditorBrowsableState.Never)] - public static class ListViewExtensions - { - [StructLayout(LayoutKind.Sequential)] - public struct HDITEM - { - public Mask mask; - public int cxy; - [MarshalAs(UnmanagedType.LPTStr)] - public string pszText; - public IntPtr hbm; - public int cchTextMax; - public Format fmt; - public IntPtr lParam; - // _WIN32_IE >= 0x0300 - public int iImage; - public int iOrder; - // _WIN32_IE >= 0x0500 - public uint type; - public IntPtr pvFilter; - // _WIN32_WINNT >= 0x0600 - public uint state; - - [Flags] - public enum Mask - { - Format = 0x4, // HDI_FORMAT - }; - - [Flags] - public enum Format - { - SortDown = 0x200, // HDF_SORTDOWN - SortUp = 0x400, // HDF_SORTUP - }; - }; - - public const int LVM_FIRST = 0x1000; - public const int LVM_GETHEADER = LVM_FIRST + 31; - - public const int HDM_FIRST = 0x1200; - public const int HDM_GETITEM = HDM_FIRST + 11; - public const int HDM_SETITEM = HDM_FIRST + 12; - - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam); - - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam); - - public static void SetSortIcon(this ListView listViewControl, int columnIndex, MySortOrder order) - { - IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero); - for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++) - { - var columnPtr = new IntPtr(columnNumber); - var item = new HDITEM - { - mask = HDITEM.Mask.Format - }; - - if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero) - { - throw new Win32Exception(); - } - - if (order != MySortOrder.None && columnNumber == columnIndex) - { - switch (order) - { - case MySortOrder.Ascending: - case MySortOrder.Ascending2: - item.fmt &= ~HDITEM.Format.SortDown; - item.fmt |= HDITEM.Format.SortUp; - break; - - case MySortOrder.Descending: - case MySortOrder.Descending2: - item.fmt &= ~HDITEM.Format.SortUp; - item.fmt |= HDITEM.Format.SortDown; - break; - } - } - else - { - item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp; - } - - if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero) - { - throw new Win32Exception(); - } - } - } - } -} diff --git a/Users/Forms/LoginDlg.Designer.cs b/Users/Forms/LoginDlg.Designer.cs deleted file mode 100644 index 14938db91..000000000 --- a/Users/Forms/LoginDlg.Designer.cs +++ /dev/null @@ -1,113 +0,0 @@ -/// -/// Copyright (c) 2017 Sensus Metering Systems -/// -namespace Users.Forms -{ - partial class LoginDlg - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginDlg)); - this.aliasLabel = new System.Windows.Forms.Label(); - this.passwordLabel = new System.Windows.Forms.Label(); - 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.Name = "aliasLabel"; - this.aliasLabel.Click += new System.EventHandler(this.aliasLabel_Click); - // - // passwordLabel - // - resources.ApplyResources(this.passwordLabel, "passwordLabel"); - this.passwordLabel.Name = "passwordLabel"; - // - // passwordTextBox - // - resources.ApplyResources(this.passwordTextBox, "passwordTextBox"); - this.passwordTextBox.Name = "passwordTextBox"; - this.passwordTextBox.UseSystemPasswordChar = true; - this.passwordTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox_KeyPress); - // - // cancelButton - // - resources.ApplyResources(this.cancelButton, "cancelButton"); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - 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.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); - // - // LoginDlg - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.Controls.Add(this.userNameTextBox); - this.Controls.Add(this.okButton); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.passwordTextBox); - this.Controls.Add(this.passwordLabel); - this.Controls.Add(this.aliasLabel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Name = "LoginDlg"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LoginDlg_FormClosing); - this.Load += new System.EventHandler(this.LoginDlg_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label aliasLabel; - private System.Windows.Forms.Label passwordLabel; - private System.Windows.Forms.TextBox userNameTextBox; - private System.Windows.Forms.TextBox passwordTextBox; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Button okButton; - } -} \ No newline at end of file diff --git a/Users/Forms/LoginDlg.cs b/Users/Forms/LoginDlg.cs deleted file mode 100644 index a3104e2b5..000000000 --- a/Users/Forms/LoginDlg.cs +++ /dev/null @@ -1,352 +0,0 @@ -/// -/// Copyright (c) 2017-2018 Sensus Slovensko a.s. -/// -using System; -using System.Windows.Forms; -using GemCard; -using Users.Entities; -using Users.Resources; -using System.Drawing; - -namespace Users.Forms -{ - /// - /// Provides login dialog as well as user authorization using TBF.User.Authorize(...) - /// (i.e. when DialogResult is OK, user was authorized). - /// - public partial class LoginDlg : Form - { - /// Public readonly - public string UserName { get { return user; } } - - /// Private fields - string user; - string password; - GID[] requiredGroupMembership; - bool noDatabase; - Color oriBackColor; - - /// Smart card support, card S/N is used as user.Tag - GemCard.CardNative card; - string smartCardReader; - - public Users.Entities.LoginMethod Method; - public string VersionString; - - /// - /// Constructor. - /// - public LoginDlg() - { - InitializeComponent(); - - oriBackColor = BackColor; - } - - /// - /// Constructor with a predefined user. - /// - public LoginDlg(string predefinedUser) - : this() - { - user = predefinedUser; - userNameTextBox.Text = predefinedUser; - } - - /// - /// Constructor with 'no Database' flag. - /// - public LoginDlg(bool noDatabase) - : this() - { - this.noDatabase = noDatabase; - } - - /// - /// Constructor when a specific group membership is required. - /// - public LoginDlg(GID[] requiredGroupMembership) - : this() - { - this.requiredGroupMembership = requiredGroupMembership; -#if DEBUG - user = "MHA"; - userNameTextBox.Text = "MHA"; - passwordTextBox.Text = "kremik"; -#endif - } - - /// - /// Constructor with a predefined user when a specific group membership is required. - /// - public LoginDlg(string predefinedUser, GID[] requiredGroupMembership) - : this() - { - user = predefinedUser; - userNameTextBox.Text = predefinedUser; - this.requiredGroupMembership = requiredGroupMembership; - } - - private void LoginDlg_Load(object sender, EventArgs e) - { - Localize(); - - if (user == null) - userNameTextBox.Select(); - else - passwordTextBox.Select(); - - /// - /// Smart card reader detection - /// - smartCardReader = null; /// null = No smart card reader detected - -#if SMART_CARD_READER_SUPPORT - try - { - card = new CardNative(); - - /// Find NFC smart card reader - string[] cardReaders = card.ListReaders(); - if (cardReaders != null) - { - foreach (var crd in cardReaders) - { - if (crd.Contains("NFC")) - { - smartCardReader = crd; /// NFC smart card reader detected - break; - } - } - } - - if (!string.IsNullOrEmpty(smartCardReader)) - { - /// Reader found, initialize NFC smart card reader - - card.OnCardInserted += delegate(object sndr, CardInsertedEventArgs args) - { - if (InvokeRequired) { Invoke(new EventHandler(OnCardInserted), sndr, args); } - else OnCardInserted(sndr, args); - }; - - card.OnCardRemoved += delegate(object sndr, CardRemovedEventArgs args) - { - if (InvokeRequired) { Invoke(new EventHandler(OnCardRemoved), sndr, args); } - else OnCardRemoved(sndr, args); - }; - - card.StartCardEvents(smartCardReader); - - Text += " (NFC)"; - } - } - catch (Exception) - { - smartCardReader = null; - } -#endif - } - - void Localize() - { - Text = Strings.User_Login + (string.IsNullOrEmpty(VersionString) ? "" : (" " + VersionString)); - aliasLabel.Text = GetAliasLabel(); - passwordLabel.Text = Strings.Password; - okButton.Text = Strings.OkBtnText; - cancelButton.Text = Strings.CancelBtnText; - } - - string GetAliasLabel() - { - switch (Method) - { - default: - case Entities.LoginMethod.UserName: return Strings.User_name; - case Entities.LoginMethod.FullName: return Strings.Full_name; - case Entities.LoginMethod.Number: return Strings.User_code; - } - } - - /// - /// Try to authorize the user when OK clicked. - /// - private void okButton_Click(object sender, EventArgs e) - { - user = userNameTextBox.Text; - password = passwordTextBox.Text; - - Entities.AuthorizedAs authorizedAs = Entities.AuthorizedAs.PowerUser; - - bool authorized = Entities.User.IsPowerUser(user, password); - if (authorized) - { - Users.GlobalData.CurrentUser = new Users.Entities.User(user, 6, true); - } - - if (!authorized && !noDatabase) - { - DBSettings[] dbs = new DBSettings[] { GlobalData.RemoteUsersDB, GlobalData.LocalUsersDB }; - authorizedAs = Entities.AuthorizedAs.RemoteUser; - - foreach (var db in dbs) - { - try - { - switch (Method) - { - case Entities.LoginMethod.UserName: - default: - var usr1 = Users.Entities.User.LoadUserByName(user, db); - if (usr1 != null) { authorized = usr1.Authorize(user, password, requiredGroupMembership); } - break; - - case Entities.LoginMethod.FullName: - var usr2 = Users.Entities.User.LoadUserByFullName(user, db); - if (usr2 != null) { authorized = usr2.AuthorizeFullName(user, password, requiredGroupMembership); } - if (authorized) { user = usr2.UserName; } - break; - - case Entities.LoginMethod.Number: - 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 (authorized) { user = usr3.UserName; } - break; - } - } - catch (Exception) { } - - if (authorized) break; - - authorizedAs = Entities.AuthorizedAs.LocalUser; - } - } - - if (authorized) - { - Users.GlobalData.AuthorizedAs = authorizedAs; - DialogResult = DialogResult.OK; - Close(); - return; - } - - MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); - DialogResult = DialogResult.None; - return; - } - - /// - /// Cancel clicked, do not try to authorize. - /// - private void cancelButton_Click(object sender, EventArgs e) - { - if (requiredGroupMembership == null) - { - Entities.User.Unauthorize(); - } - - DialogResult = DialogResult.Cancel; - Close(); - return; - } - - private void aliasLabel_Click(object sender, EventArgs e) - { - if (++Method == Entities.LoginMethod.Count) Method = 0; - - aliasLabel.Text = GetAliasLabel(); - } - - private void userNameTextBox_KeyPress(object sender, KeyPressEventArgs e) - { - if (Convert.ToInt32(e.KeyChar) == 13) - { - passwordTextBox.Focus(); - } - } - - private void passwordTextBox_KeyPress(object sender, KeyPressEventArgs e) - { - if (Convert.ToInt32(e.KeyChar) == 13) - { - okButton_Click(sender, e); - } - } - - - void OnCardInserted(object sender, CardInsertedEventArgs args) - { - string tag = string.Empty; - - try - { - BackColor = Color.Green; - card.Connect(smartCardReader, SHARE.Shared, PROTOCOL.T0orT1); - - /// Read the serial number of the card - APDUResponse response = card.Transmit(new APDUCommand(0xFF, 0xCA, 0x00, 0x00, null, 7)); - tag = response.ToString(); - - card.Disconnect(DISCONNECT.Leave); - } - catch - { - tag = string.Empty; - } - - DBSettings[] dbs = new DBSettings[] { GlobalData.RemoteUsersDB, GlobalData.LocalUsersDB }; - bool authorized = false; - Entities.AuthorizedAs authorizedAs = Entities.AuthorizedAs.RemoteUser; - /// - foreach (var db in dbs) - { - try - { - Users.Entities.User loadedUser = Users.Entities.User.LoadUserByTag(tag, db); - if (loadedUser != null) - { - authorized = loadedUser.AuthorizeTag(tag, requiredGroupMembership); - - if (authorized) - { - user = loadedUser.UserName; - break; - } - } - } - catch (Exception) { } - - authorizedAs = Entities.AuthorizedAs.LocalUser; - } - - if (authorized) - { - Users.GlobalData.AuthorizedAs = authorizedAs; - DialogResult = DialogResult.OK; - Close(); - return; - } - - MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK); - DialogResult = DialogResult.None; - return; - } - - - void OnCardRemoved(object sender, CardRemovedEventArgs args) - { - BackColor = oriBackColor; - } - - private void LoginDlg_FormClosing(object sender, FormClosingEventArgs e) - { - if (!string.IsNullOrEmpty(smartCardReader)) - { - try { card.StopCardEvents(); } - catch { } - } - } - } -} diff --git a/Users/Forms/LoginDlg.resx b/Users/Forms/LoginDlg.resx deleted file mode 100644 index 955e22ace..000000000 --- a/Users/Forms/LoginDlg.resx +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - True - - - - 11, 24 - - - 58, 13 - - - 0 - - - User name - - - aliasLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - - - True - - - 11, 51 - - - 53, 13 - - - 1 - - - Password - - - passwordLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 4 - - - - Top, Right - - - 150, 48 - - - 168, 20 - - - 3 - - - passwordTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - Top, Right - - - 336, 48 - - - 105, 28 - - - 5 - - - Cancel - - - cancelButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - Top, Right - - - 336, 14 - - - 105, 28 - - - 4 - - - OK - - - okButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - Top, Right - - - 150, 22 - - - 168, 20 - - - 2 - - - userNameTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - True - - - 6, 13 - - - 456, 88 - - - CenterScreen - - - User login - - - LoginDlg - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Users/Forms/LviIntColumnComparer.cs b/Users/Forms/LviIntColumnComparer.cs deleted file mode 100644 index 960da5b00..000000000 --- a/Users/Forms/LviIntColumnComparer.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections; -using System.Windows.Forms; - -namespace Users.Forms -{ - class LviIntColumnComparer : IComparer - { - int column; - MySortOrder order; - - public LviIntColumnComparer() - { - column = 0; - order = MySortOrder.Ascending; - } - - public LviIntColumnComparer(int column, MySortOrder order) - { - this.column = column; - this.order = order; - } - - public int Compare(object x, object y) - { - int valX = int.Parse(((ListViewItem)x).SubItems[column].Text); - int valY = int.Parse(((ListViewItem)y).SubItems[column].Text); - return (order == MySortOrder.Descending || order == MySortOrder.Descending2) ? (valY - valX) : (valX - valY); - } - } -} diff --git a/Users/Forms/LviNameSurnameColumnComparer.cs b/Users/Forms/LviNameSurnameColumnComparer.cs deleted file mode 100644 index 70957a42f..000000000 --- a/Users/Forms/LviNameSurnameColumnComparer.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections; -using System.Windows.Forms; - -namespace Users.Forms -{ - class LviNameSurnameColumnComparer : IComparer - { - private int column; - MySortOrder order; - - public LviNameSurnameColumnComparer() - { - column = 0; - order = MySortOrder.Ascending; - } - - public LviNameSurnameColumnComparer(int column, MySortOrder order) - { - this.column = column; - this.order = order; - } - - public int Compare(object x, object y) - { - string nameX = ((ListViewItem)x).SubItems[column].Text; - string nameY = ((ListViewItem)y).SubItems[column].Text; - string surnameX; - string surnameY; - - switch (order) - { - case MySortOrder.Ascending: - return String.Compare(nameX, nameY); - - case MySortOrder.Descending: - return String.Compare(nameY, nameX); - - case MySortOrder.Ascending2: - surnameX = (nameX.IndexOf(' ') > 0) ? nameX.Substring(nameX.IndexOf(' ') + 1) : nameX; - surnameY = (nameX.IndexOf(' ') > 0) ? nameY.Substring(nameY.IndexOf(' ') + 1) : nameY; - return String.Compare(surnameX, surnameY); - - case MySortOrder.Descending2: - surnameX = (nameX.IndexOf(' ') > 0) ? nameX.Substring(nameX.IndexOf(' ') + 1) : nameX; - surnameY = (nameX.IndexOf(' ') > 0) ? nameY.Substring(nameY.IndexOf(' ') + 1) : nameY; - return String.Compare(surnameY, surnameX); - - default: - return 0; - } - } - } -} diff --git a/Users/Forms/LviTextColumnComparer.cs b/Users/Forms/LviTextColumnComparer.cs deleted file mode 100644 index 03472f581..000000000 --- a/Users/Forms/LviTextColumnComparer.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections; -using System.Windows.Forms; - -namespace Users.Forms -{ - class LviTextColumnComparer : IComparer - { - private int column; - MySortOrder order; - - public LviTextColumnComparer() - { - column = 0; - order = MySortOrder.Ascending; - } - - public LviTextColumnComparer(int column, MySortOrder order) - { - this.column = column; - this.order = order; - } - - public int Compare(object x, object y) - { - string txtX = ((ListViewItem)x).SubItems[column].Text; - string txtY = ((ListViewItem)y).SubItems[column].Text; - return (order == MySortOrder.Descending || order == MySortOrder.Descending2) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY); - } - } -} diff --git a/Users/Forms/PasswordChangeDlg.Designer.cs b/Users/Forms/PasswordChangeDlg.Designer.cs deleted file mode 100644 index 8466c1cd6..000000000 --- a/Users/Forms/PasswordChangeDlg.Designer.cs +++ /dev/null @@ -1,147 +0,0 @@ -/// -/// Copyright (c) 2019 Sensus Slovensko a.s. -/// -namespace Users.Forms -{ - partial class PasswordChangeDlg - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PasswordChangeDlg)); - this.userNameLabel = new System.Windows.Forms.Label(); - this.oldPasswLabel = new System.Windows.Forms.Label(); - this.oldPasswTextBox = 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.newPasswTextBox = new System.Windows.Forms.TextBox(); - this.newPasswVerifTextBox = new System.Windows.Forms.TextBox(); - this.newPasswLabel = new System.Windows.Forms.Label(); - this.newPasswVerifLabel = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // userNameLabel - // - resources.ApplyResources(this.userNameLabel, "userNameLabel"); - this.userNameLabel.Name = "userNameLabel"; - // - // oldPasswLabel - // - resources.ApplyResources(this.oldPasswLabel, "oldPasswLabel"); - this.oldPasswLabel.Name = "oldPasswLabel"; - // - // oldPasswTextBox - // - resources.ApplyResources(this.oldPasswTextBox, "oldPasswTextBox"); - this.oldPasswTextBox.Name = "oldPasswTextBox"; - this.oldPasswTextBox.UseSystemPasswordChar = true; - this.oldPasswTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.passwordTextBox_KeyPress); - // - // cancelButton - // - resources.ApplyResources(this.cancelButton, "cancelButton"); - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - 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.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); - // - // newPasswTextBox - // - resources.ApplyResources(this.newPasswTextBox, "newPasswTextBox"); - this.newPasswTextBox.Name = "newPasswTextBox"; - this.newPasswTextBox.UseSystemPasswordChar = true; - this.newPasswTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.newPasswTextBox_KeyPress); - // - // newPasswVerifTextBox - // - resources.ApplyResources(this.newPasswVerifTextBox, "newPasswVerifTextBox"); - this.newPasswVerifTextBox.Name = "newPasswVerifTextBox"; - this.newPasswVerifTextBox.UseSystemPasswordChar = true; - this.newPasswVerifTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.newPasswVerifTextBox_KeyPress); - // - // newPasswLabel - // - resources.ApplyResources(this.newPasswLabel, "newPasswLabel"); - this.newPasswLabel.Name = "newPasswLabel"; - // - // newPasswVerifLabel - // - resources.ApplyResources(this.newPasswVerifLabel, "newPasswVerifLabel"); - this.newPasswVerifLabel.Name = "newPasswVerifLabel"; - // - // PasswordChangeDlg - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.Controls.Add(this.newPasswVerifLabel); - this.Controls.Add(this.newPasswLabel); - this.Controls.Add(this.newPasswVerifTextBox); - this.Controls.Add(this.newPasswTextBox); - this.Controls.Add(this.userNameTextBox); - this.Controls.Add(this.okButton); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.oldPasswTextBox); - this.Controls.Add(this.oldPasswLabel); - this.Controls.Add(this.userNameLabel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Name = "PasswordChangeDlg"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Load += new System.EventHandler(this.LoginDlg_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label userNameLabel; - private System.Windows.Forms.Label oldPasswLabel; - private System.Windows.Forms.TextBox userNameTextBox; - private System.Windows.Forms.TextBox oldPasswTextBox; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.TextBox newPasswTextBox; - private System.Windows.Forms.TextBox newPasswVerifTextBox; - private System.Windows.Forms.Label newPasswLabel; - private System.Windows.Forms.Label newPasswVerifLabel; - } -} \ No newline at end of file diff --git a/Users/Forms/PasswordChangeDlg.cs b/Users/Forms/PasswordChangeDlg.cs deleted file mode 100644 index f9cd99a13..000000000 --- a/Users/Forms/PasswordChangeDlg.cs +++ /dev/null @@ -1,187 +0,0 @@ -/// -/// Copyright (c) 2019 Sensus Slovensko a.s. -/// -using System; -using System.Windows.Forms; -using GemCard; -using Users.Resources; -using System.Drawing; - -namespace Users.Forms -{ - /// - /// Provides login dialog as well as user authorization using TBF.User.Authorize(...) - /// (i.e. when DialogResult is OK, user was authorized). - /// - public partial class PasswordChangeDlg : Form - { - /// - /// Constructor - /// - public PasswordChangeDlg() - { - InitializeComponent(); - } - - /// - /// Constructor with a predefined user. - /// - public PasswordChangeDlg(string predefinedUser) - { - InitializeComponent(); - userNameTextBox.Text = predefinedUser; - } - - - private void LoginDlg_Load(object sender, EventArgs e) - { - Localize(); - - if (string.IsNullOrEmpty(userNameTextBox.Text)) - { - userNameTextBox.Enabled = true; - userNameTextBox.Select(); - } - else - { - oldPasswTextBox.Select(); - } - } - - void Localize() - { - Text = Strings.Change_your_password_please; - userNameLabel.Text = Strings.User_name; - oldPasswLabel.Text = Strings.Old_password; - newPasswLabel.Text = Strings.New_password; - newPasswVerifLabel.Text = Strings.New_password_verification; - okButton.Text = Strings.OkBtnText; - cancelButton.Text = Strings.CancelBtnText; - } - - /// - /// Try to authorize the user when OK clicked. - /// - private void okButton_Click(object sender, EventArgs e) - { - string userName = userNameTextBox.Text; - string oldPassword = oldPasswTextBox.Text; - - if (Entities.User.IsPowerUser(userName, oldPassword)) - { - MessageBox.Show(Strings.Power_user_cannot_change_its_password, Strings.Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - DialogResult = DialogResult.OK; - Close(); - return; - } - - string explanation; - if (newPasswTextBox.Text != newPasswVerifTextBox.Text) - { - MessageBox.Show(Strings.New_password_and_its_verification_are_different, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand); - DialogResult = DialogResult.None; - return; - } - else if (!Entities.User.IsPasswordMeetsRequirements(newPasswTextBox.Text, out explanation)) - { - MessageBox.Show(Strings.Password_does_not_meet_requirements + Environment.NewLine + explanation, - Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand); - DialogResult = DialogResult.None; - return; - } - - Entities.AuthorizedAs authorizedAs = Entities.AuthorizedAs.RemoteUser; - Users.Entities.User loadedUser = null; - /// - bool oldPasswdOK = false; - if (!oldPasswdOK) - { - DBSettings[] dbs = new DBSettings[] { GlobalData.RemoteUsersDB, GlobalData.LocalUsersDB }; - - foreach (var db in dbs) - { - try - { - loadedUser = Users.Entities.User.LoadUserByName(userName, db); - if (loadedUser != null) - { - oldPasswdOK = (userName == loadedUser.UserName) && loadedUser.IsCorrectPassword(oldPassword); - } - } - catch (Exception) { } - - if (oldPasswdOK) break; - - authorizedAs = Entities.AuthorizedAs.LocalUser; - } - } - - if (oldPasswdOK && (UsersDB.CurrentSession != null) && (UsersDB.CurrentSession.IsOpen)) - { - if (loadedUser.IsPasswordUsedInPast(newPasswTextBox.Text)) - { - MessageBox.Show(Strings.Password_has_been_used_in_past, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand); - DialogResult = DialogResult.None; - return; - } - - /// - /// Now the password is changed in database that was used to authorize the user - /// - loadedUser.SetPassword(newPasswTextBox.Text); - UsersDB.CurrentSession.SaveOrUpdate(loadedUser); - UsersDB.CurrentSession.Flush(); - - DialogResult = DialogResult.OK; - Close(); - return; - } - - MessageBox.Show(Strings.Invalid_username_or_password, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand); - DialogResult = DialogResult.None; - return; - } - - /// - /// Cancel clicked, do not try to authorize. - /// - private void cancelButton_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - return; - } - - private void userNameTextBox_KeyPress(object sender, KeyPressEventArgs e) - { - if (Convert.ToInt32(e.KeyChar) == 13) - { - oldPasswTextBox.Focus(); - } - } - - private void passwordTextBox_KeyPress(object sender, KeyPressEventArgs e) - { - if (Convert.ToInt32(e.KeyChar) == 13) - { - newPasswTextBox.Focus(); - } - } - - private void newPasswTextBox_KeyPress(object sender, KeyPressEventArgs e) - { - if (Convert.ToInt32(e.KeyChar) == 13) - { - newPasswVerifTextBox.Focus(); - } - } - - private void newPasswVerifTextBox_KeyPress(object sender, KeyPressEventArgs e) - { - if (Convert.ToInt32(e.KeyChar) == 13) - { - okButton_Click(sender, e); - } - } - } -} diff --git a/Users/Forms/PasswordChangeDlg.resx b/Users/Forms/PasswordChangeDlg.resx deleted file mode 100644 index 7bb8824db..000000000 --- a/Users/Forms/PasswordChangeDlg.resx +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - True - - - - 11, 24 - - - 58, 13 - - - 0 - - - User name - - - userNameLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 9 - - - True - - - 11, 51 - - - 71, 13 - - - 2 - - - Old password - - - oldPasswLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 8 - - - - Top, Right - - - 150, 48 - - - 168, 20 - - - 3 - - - oldPasswTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 7 - - - Top, Right - - - 336, 48 - - - 105, 28 - - - 9 - - - Cancel - - - cancelButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 6 - - - Top, Right - - - 336, 14 - - - 105, 28 - - - 8 - - - OK - - - okButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - - - Top, Right - - - False - - - 150, 22 - - - 168, 20 - - - 1 - - - userNameTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 4 - - - Top, Right - - - 150, 74 - - - 168, 20 - - - 5 - - - newPasswTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - Top, Right - - - 150, 100 - - - 168, 20 - - - 7 - - - newPasswVerifTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - True - - - NoControl - - - 11, 77 - - - 77, 13 - - - 4 - - - New password - - - newPasswLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - True - - - NoControl - - - 12, 103 - - - 77, 13 - - - 6 - - - New password - - - newPasswVerifLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - True - - - 6, 13 - - - 456, 134 - - - CenterScreen - - - Password change - - - PasswordChangeDlg - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Users/Forms/UserManagementDlg.cs b/Users/Forms/UserManagementDlg.cs deleted file mode 100644 index 9804dd661..000000000 --- a/Users/Forms/UserManagementDlg.cs +++ /dev/null @@ -1,315 +0,0 @@ -/// -/// Copyright (c) 2017-2018 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using NHibernate; -using Users.Entities; -using Users.Resources; - - -namespace Users.Forms -{ - public enum MySortOrder - { - None, - Ascending, /// Th esame like SortOrder.Ascending - Descending, /// The same like SortOrder.Descending - Ascending2, /// Sorts by a surname in ascending order in case or 'Name Surname' column - Descending2, /// Sorts by a surname in descending order in case or 'Name Surname' column - } - - public partial class UserManagementDlg: Form - { - const int UserNumberColumn = 1; - const int NameSurnameColumn = 2; - - - IList displayedGroups; - public string TitleExtension; - - - NHibernate.ISession session; - bool showExtensions; - IList listOfUsers; - int lastSelectedIndex; - - MySortOrder sortOrder = MySortOrder.Ascending; - int sortColumn = -1; /// 0-based index of column to be used for sorting - - - public UserManagementDlg(NHibernate.ISession session, bool showLocalExtensions) - { - InitializeComponent(); - this.session = session; - this.showExtensions = showLocalExtensions; - if (showLocalExtensions) copyFromRemoteButton.Visible = true; - - try - { - IList allGroups = session.QueryOver().List(); - - /// - /// Selects groups to be displayed (so that each GID is present only once) - /// - Group[] dspGroups = new Group[(int)Users.Entities.GID.NrOfGroups]; - foreach (var group in allGroups) - { - if ((group.GID >= 0) && (group.GID < Users.Entities.GID.NrOfGroups) && (dspGroups[(int)group.GID] == null)) - { - dspGroups[(int)group.GID] = group; - } - } - displayedGroups = new List(); - foreach (var group in dspGroups) - { - if (group != null) displayedGroups.Add(group); - } - - listOfUsers = session.QueryOver().List(); - } - catch (Exception) - { - if (displayedGroups == null) displayedGroups = new List(); - if (listOfUsers == null) listOfUsers = new List(); - } - - - } - - private void UserManagementDlg_Load(object sender, EventArgs e) - { - /// Program version string - Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; - string version = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); - - Text = string.Format(string.IsNullOrEmpty(TitleExtension) ? "{0} ver.{1}" : "{0} ver.{1} : {2}", Strings.User_Management, version, TitleExtension); - addButton.Text = Strings.AddBtnText; - editButton.Text = Strings.EditBtnText; - deleteButton.Text = Strings.RemoveBtnText; - closeButton.Text = Strings.CloseBtnText; - - listViewUsers.Columns.Add(Strings.User_name, 100); /// column 0 - listViewUsers.Columns.Add(Strings.User_code, 70); /// column 1: UserNumberColumn - listViewUsers.Columns.Add(Strings.Full_name, 150); /// column 2: NameSurnameColumn - listViewUsers.Columns.Add(Strings.Tag, 110); - listViewUsers.Columns.Add(Strings.Groups, 370); - - ListUsers(); - } - - public void ListUsers() - { - listViewUsers.Items.Clear(); - foreach (User u in listOfUsers) - { - ListViewItem item = new ListViewItem(u.UserName); - item.Tag = u; - item.SubItems.Add(u.Number.ToString()); - item.SubItems.Add(u.FullName); - item.SubItems.Add(string.IsNullOrEmpty(u.Tag) ? string.Empty : u.Tag); - - /// Show groups of this user - string grps = string.Empty; - foreach (var group in displayedGroups) - { - if (u.IsMemberOf(group.GID)) - { - if (!string.IsNullOrEmpty(grps)) grps += ", "; - grps += group.Gid2Str(); - } - } - item.SubItems.Add(grps); - - this.listViewUsers.Items.Add(item); - } - this.listViewUsers.Refresh(); - } - - private void closeButton_Click(object sender, EventArgs e) - { - this.Close(); - } - - - private void RefreshButtonStates() - { - editButton.Enabled = (listViewUsers.SelectedItems.Count > 0); - deleteButton.Enabled = (listViewUsers.SelectedItems.Count > 0); - } - - private void listViewUsers_SelectedIndexChanged(object sender, EventArgs e) - { - RefreshButtonStates(); - if (listViewUsers.SelectedItems.Count > 0) - { - lastSelectedIndex = listViewUsers.SelectedItems[0].Index; - } - else - { - lastSelectedIndex = -1; - } - } - - - private void listViewUsers_ColumnClick(object sender, ColumnClickEventArgs e) - { - if (e.Column == sortColumn) - { - /// Clicked on the same column header => increment to the next applicable MySortOrder - if (e.Column == NameSurnameColumn) - { - sortOrder++; - if (sortOrder > MySortOrder.Descending2) sortOrder = MySortOrder.Ascending; - } - else - { - sortOrder = (sortOrder == MySortOrder.Ascending) ? MySortOrder.Descending : MySortOrder.Ascending; - } - } - else - { - /// Clicked on another column header => set sortOrder to MySortOrder.Ascending - sortColumn = e.Column; - sortOrder = MySortOrder.Ascending; - } - - if (sortColumn == UserNumberColumn) - { - listViewUsers.ListViewItemSorter = new LviIntColumnComparer(sortColumn, sortOrder); - } - else if (sortColumn == NameSurnameColumn) - { - listViewUsers.ListViewItemSorter = new LviNameSurnameColumnComparer(sortColumn, sortOrder); - } - else - { - listViewUsers.ListViewItemSorter = new LviTextColumnComparer(sortColumn, sortOrder); - } - - listViewUsers.SetSortIcon(sortColumn, sortOrder); - listViewUsers.Sort(); - } - - private void editButton_Click(object sender, EventArgs e) - { - if (listViewUsers.SelectedItems.Count == 1 && listViewUsers.SelectedItems[0].Tag is User) - { - new Forms.EditSelectedUser(session, (User)listViewUsers.SelectedItems[0].Tag, displayedGroups).ShowDialog(); - ListUsers(); - } - } - - private void listViewUsers_DoubleClick(object sender, EventArgs e) - { - editButton_Click (sender, e); - } - - private void addButton_Click(object sender, EventArgs e) - { - User newUser = new User(); - if (new Forms.EditSelectedUser(session, newUser, displayedGroups).ShowDialog() == DialogResult.OK) - { - listOfUsers.Add(newUser); - } - ListUsers(); - } - - private void deleteButton_Click(object sender, EventArgs e) - { - if (listViewUsers.SelectedItems.Count == 1 && listViewUsers.SelectedItems[0].Tag is User) - { - User selecteduser = session.Get((listViewUsers.SelectedItems[0].Tag as User).Id); - session.Delete(selecteduser); - session.Flush(); - listOfUsers.RemoveAt(listViewUsers.SelectedIndices[0]); - ListUsers(); - } - } - - 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)) - { - MessageBox.Show(Strings.No_remote_database_of_users, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - return; - } - - if (MessageBox.Show(Strings.Are_you_sure, Strings.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) - { - return; - } - - IList remoteUsers; - IList remoteGroups; - ITransaction transaction = null; - - try - { - /// - /// Create remote DB session and read remote users - /// - UsersDB.DbType = GlobalData.RemoteUsersDB.DbType; - UsersDB.ConnectionString = GlobalData.RemoteUsersDB.ConnectionString; - ISession remoteSession = UsersDB.CreateSession(); - remoteUsers = remoteSession.QueryOver().List(); - remoteGroups = remoteSession.QueryOver().List(); - - /// - /// Prepare local DB session - /// - UsersDB.DbType = GlobalData.LocalUsersDB.DbType; - UsersDB.ConnectionString = GlobalData.LocalUsersDB.ConnectionString; - ISession localSession = UsersDB.CreateSession(); - transaction = localSession.BeginTransaction(); - - /// - /// Delete all local users - /// - IList users = localSession.QueryOver().List(); - foreach (var user in users) localSession.Delete(user); - IList groups = localSession.QueryOver().List(); - foreach (var group in groups) localSession.Delete(group); - - /// - /// Save all remote users to the local DB - /// - IList newUsers = new List(); - IList newGroups = new List(); - foreach (var user in remoteUsers) - { - User newUser = (User)user.Clone(); - newUsers.Add(newUser); - foreach (var group in user.Groups) - { - Group newGroup = new Group(group.GID); - newUser.AddGroup(newGroup); - } - - localSession.SaveOrUpdate(newUser); - } - transaction.Commit(); - localSession.Flush(); - - listOfUsers = newUsers; - ListUsers(); - - MessageBox.Show(string.Format(Strings.N_users_copied, remoteUsers.Count), - Strings.Confirmation, - MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - catch (Exception) - { - if (transaction != null) transaction.Rollback(); - - MessageBox.Show(Strings.Copying_remote_users_failed, - Strings.Confirmation, - MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - } - } -} diff --git a/Users/Forms/UserManagementDlg.designer.cs b/Users/Forms/UserManagementDlg.designer.cs deleted file mode 100644 index b732f95f0..000000000 --- a/Users/Forms/UserManagementDlg.designer.cs +++ /dev/null @@ -1,148 +0,0 @@ -/// -/// Copyright (c) 2017 Sensus Metering Systems -/// -namespace Users.Forms -{ - partial class UserManagementDlg - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UserManagementDlg)); - this.listViewUsers = new System.Windows.Forms.ListView(); - this.addButton = new System.Windows.Forms.Button(); - this.editButton = new System.Windows.Forms.Button(); - this.deleteButton = new System.Windows.Forms.Button(); - this.closeButton = new System.Windows.Forms.Button(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.copyFromRemoteButton = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.SuspendLayout(); - // - // listViewUsers - // - resources.ApplyResources(this.listViewUsers, "listViewUsers"); - this.listViewUsers.FullRowSelect = true; - this.listViewUsers.GridLines = true; - this.listViewUsers.MultiSelect = false; - this.listViewUsers.Name = "listViewUsers"; - this.listViewUsers.UseCompatibleStateImageBehavior = false; - this.listViewUsers.View = System.Windows.Forms.View.Details; - this.listViewUsers.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewUsers_ColumnClick); - this.listViewUsers.SelectedIndexChanged += new System.EventHandler(this.listViewUsers_SelectedIndexChanged); - this.listViewUsers.DoubleClick += new System.EventHandler(this.listViewUsers_DoubleClick); - // - // addButton - // - resources.ApplyResources(this.addButton, "addButton"); - this.addButton.Name = "addButton"; - this.addButton.UseVisualStyleBackColor = true; - this.addButton.Click += new System.EventHandler(this.addButton_Click); - // - // editButton - // - resources.ApplyResources(this.editButton, "editButton"); - this.editButton.Name = "editButton"; - this.editButton.UseVisualStyleBackColor = true; - this.editButton.Click += new System.EventHandler(this.editButton_Click); - // - // deleteButton - // - resources.ApplyResources(this.deleteButton, "deleteButton"); - this.deleteButton.Name = "deleteButton"; - this.deleteButton.UseVisualStyleBackColor = true; - this.deleteButton.Click += new System.EventHandler(this.deleteButton_Click); - // - // closeButton - // - resources.ApplyResources(this.closeButton, "closeButton"); - this.closeButton.Name = "closeButton"; - this.closeButton.UseVisualStyleBackColor = true; - this.closeButton.Click += new System.EventHandler(this.closeButton_Click); - // - // statusStrip1 - // - resources.ApplyResources(this.statusStrip1, "statusStrip1"); - this.statusStrip1.Name = "statusStrip1"; - // - // splitContainer1 - // - resources.ApplyResources(this.splitContainer1, "splitContainer1"); - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.listViewUsers); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.copyFromRemoteButton); - this.splitContainer1.Panel2.Controls.Add(this.addButton); - this.splitContainer1.Panel2.Controls.Add(this.editButton); - this.splitContainer1.Panel2.Controls.Add(this.closeButton); - this.splitContainer1.Panel2.Controls.Add(this.deleteButton); - // - // copyFromRemoteButton - // - resources.ApplyResources(this.copyFromRemoteButton, "copyFromRemoteButton"); - this.copyFromRemoteButton.Name = "copyFromRemoteButton"; - this.copyFromRemoteButton.UseVisualStyleBackColor = true; - this.copyFromRemoteButton.Click += new System.EventHandler(this.copyFromRemoteButton_Click); - // - // UserManagementDlg - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.splitContainer1); - this.Controls.Add(this.statusStrip1); - this.Name = "UserManagementDlg"; - this.Load += new System.EventHandler(this.UserManagementDlg_Load); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ListView listViewUsers; - private System.Windows.Forms.Button addButton; - private System.Windows.Forms.Button editButton; - private System.Windows.Forms.Button deleteButton; - private System.Windows.Forms.Button closeButton; - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.Button copyFromRemoteButton; - } -} \ No newline at end of file diff --git a/Users/Forms/UserManagementDlg.resx b/Users/Forms/UserManagementDlg.resx deleted file mode 100644 index 2a960f81a..000000000 --- a/Users/Forms/UserManagementDlg.resx +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - Fill - - - - 0, 0 - - - 821, 502 - - - - 0 - - - listViewUsers - - - System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel1 - - - 0 - - - 23, 85 - - - 85, 40 - - - 1 - - - Add - - - addButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel2 - - - 1 - - - 23, 130 - - - 85, 40 - - - 1 - - - Edit - - - editButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel2 - - - 2 - - - 23, 175 - - - 85, 40 - - - 1 - - - Delete - - - deleteButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel2 - - - 4 - - - 23, 18 - - - 85, 40 - - - 1 - - - Close - - - closeButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel2 - - - 3 - - - 17, 17 - - - 0, 502 - - - 956, 22 - - - 2 - - - statusStrip1 - - - statusStrip1 - - - System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - Fill - - - True - - - 0, 0 - - - splitContainer1.Panel1 - - - System.Windows.Forms.SplitterPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1 - - - 0 - - - NoControl - - - 23, 243 - - - 85, 40 - - - 2 - - - Copy all users from remote - - - False - - - copyFromRemoteButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1.Panel2 - - - 0 - - - splitContainer1.Panel2 - - - System.Windows.Forms.SplitterPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - splitContainer1 - - - 1 - - - 956, 502 - - - 821 - - - 3 - - - splitContainer1 - - - System.Windows.Forms.SplitContainer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - True - - - 6, 13 - - - 956, 524 - - - User Management - - - UserManagementDlg - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Users/GlobalData.cs b/Users/GlobalData.cs deleted file mode 100644 index 065a02dde..000000000 --- a/Users/GlobalData.cs +++ /dev/null @@ -1,25 +0,0 @@ -/// -/// Copyright (c) 2016-2019 Sensus Slovensko a.s. -/// -using System; - -namespace Users -{ - public class GlobalData - { - public static DBSettings RemoteUsersDB = null; - public static DBSettings LocalUsersDB = null; - - public static Entities.User CurrentUser; - public static Entities.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/Mappings/GroupMap.cs b/Users/Mappings/GroupMap.cs deleted file mode 100644 index 76895cd88..000000000 --- a/Users/Mappings/GroupMap.cs +++ /dev/null @@ -1,24 +0,0 @@ -/// -/// Copyright (c) 2016-2020 Sensus Slovensko a.s. -/// -using FluentNHibernate.Mapping; - -namespace Users.Mappings -{ - class GroupMap : ClassMap - { - /// - /// https://stackoverflow.com/questions/9108083/fluent-nhibernate-many-to-many-mapping-way/9125059 - /// - public GroupMap() - { - Id(x => x.Id); - Map(x => x.GID).Column("Name"); - Map(x => x.AccessFlags); - HasManyToMany(x => x.Users) - .Cascade.SaveUpdate() - .Inverse() - .Table("UsersGroups"); - } - } -} diff --git a/Users/Mappings/UserMap.cs b/Users/Mappings/UserMap.cs deleted file mode 100644 index 93147bf96..000000000 --- a/Users/Mappings/UserMap.cs +++ /dev/null @@ -1,29 +0,0 @@ -/// -/// Copyright (c) 2016-2020 Sensus Slovensko a.s. -/// -using FluentNHibernate.Mapping; - -namespace Users.Mappings -{ - class UserMap : ClassMap - { - public UserMap() - { - Id(x => x.Id); - Map(x => x.UserName) - .Column("Name"); - Map(x => x.Number); - Map(x => x.Tag); - Map(x => x.Password); - Map(x => x.Password2); - Map(x => x.Password3); - Map(x => x.Password4); - Map(x => x.FullName) - .Column("Description"); - Map(x => x.LastPwChange); - HasManyToMany(x => x.Groups) - .Cascade.SaveUpdate() - .Table("UsersGroups"); - } - } -} diff --git a/Users/Properties/AssemblyInfo.cs b/Users/Properties/AssemblyInfo.cs deleted file mode 100644 index 5359c4adc..000000000 --- a/Users/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Users")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Users")] -[assembly: AssemblyCopyright("Copyright © 2018-2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f05db1fc-0a24-4319-802b-d13e9a4b7efe")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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("3.1.1464.0")] -[assembly: AssemblyFileVersion("3.1.1464.0")] diff --git a/Users/Resources/Strings.Designer.cs b/Users/Resources/Strings.Designer.cs deleted file mode 100644 index b00b80e99..000000000 --- a/Users/Resources/Strings.Designer.cs +++ /dev/null @@ -1,522 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 Users.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", "15.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("Users.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 Add. - /// - internal static string AddBtnText { - get { - return ResourceManager.GetString("AddBtnText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to administrator. - /// - internal static string administrator { - get { - return ResourceManager.GetString("administrator", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Are you sure?. - /// - internal static string Are_you_sure { - get { - return ResourceManager.GetString("Are_you_sure", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to calibration specialist. - /// - internal static string calibration_specialist { - get { - return ResourceManager.GetString("calibration_specialist", resourceCulture); - } - } - - /// - /// 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 Change your password please. - /// - internal static string Change_your_password_please { - get { - return ResourceManager.GetString("Change_your_password_please", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close. - /// - internal static string CloseBtnText { - get { - return ResourceManager.GetString("CloseBtnText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Confirmation. - /// - internal static string Confirmation { - get { - return ResourceManager.GetString("Confirmation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Copying remote users failed. - /// - internal static string Copying_remote_users_failed { - get { - return ResourceManager.GetString("Copying_remote_users_failed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Description. - /// - internal static string DescriptionColHdr { - get { - return ResourceManager.GetString("DescriptionColHdr", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Edit User. - /// - internal static string Edit_User { - get { - return ResourceManager.GetString("Edit_User", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Edit. - /// - internal static string EditBtnText { - get { - return ResourceManager.GetString("EditBtnText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error. - /// - internal static string Error { - get { - return ResourceManager.GetString("Error", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name and Surname. - /// - internal static string Full_name { - get { - return ResourceManager.GetString("Full_name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Groups. - /// - internal static string Groups { - get { - return ResourceManager.GetString("Groups", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to head of lab.. - /// - internal static string head_of_lab { - get { - return ResourceManager.GetString("head_of_lab", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ID. - /// - internal static string ID { - get { - return ResourceManager.GetString("ID", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to invalid. - /// - internal static string invalid { - get { - return ResourceManager.GetString("invalid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid username or password. - /// - internal static string Invalid_username_or_password { - get { - return ResourceManager.GetString("Invalid_username_or_password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to maintenance. - /// - internal static string maintenance { - get { - return ResourceManager.GetString("maintenance", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to (max. {0} alphanumeric characters). - /// - internal static string max_0_alphanum_chars { - get { - return ResourceManager.GetString("max_0_alphanum_chars", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to metrological authority. - /// - internal static string metrological_authority { - get { - return ResourceManager.GetString("metrological_authority", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to metrologist. - /// - internal static string metrologist { - get { - return ResourceManager.GetString("metrologist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} users copied. - /// - internal static string N_users_copied { - get { - return ResourceManager.GetString("N_users_copied", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name. - /// - internal static string Name { - get { - return ResourceManager.GetString("Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New password. - /// - internal static string New_password { - get { - return ResourceManager.GetString("New_password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New password and it's verification are different. - /// - internal static string New_password_and_its_verification_are_different { - get { - return ResourceManager.GetString("New_password_and_its_verification_are_different", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to New password verification. - /// - internal static string New_password_verification { - get { - return ResourceManager.GetString("New_password_verification", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No remote database of users. - /// - internal static string No_remote_database_of_users { - get { - return ResourceManager.GetString("No_remote_database_of_users", 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 Old password. - /// - internal static string Old_password { - get { - return ResourceManager.GetString("Old_password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password. - /// - internal static string Password { - get { - return ResourceManager.GetString("Password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password does not meet requirements. - /// - internal static string Password_does_not_meet_requirements { - get { - return ResourceManager.GetString("Password_does_not_meet_requirements", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password has been used in the past. - /// - internal static string Password_has_been_used_in_past { - get { - return ResourceManager.GetString("Password_has_been_used_in_past", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password must have at least {0} characters. - /// - internal static string Password_must_have_at_least_0_characters { - get { - return ResourceManager.GetString("Password_must_have_at_least_0_characters", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Power user cannot change it's password. - /// - internal static string Power_user_cannot_change_its_password { - get { - return ResourceManager.GetString("Power_user_cannot_change_its_password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to production tracing administrator. - /// - internal static string production_tracing_administrator { - get { - return ResourceManager.GetString("production_tracing_administrator", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove. - /// - internal static string RemoveBtnText { - get { - return ResourceManager.GetString("RemoveBtnText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Repeat password. - /// - internal static string Repeat_password { - get { - return ResourceManager.GetString("Repeat_password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Save or update user failed. - /// - internal static string Save_or_update_user_failed { - get { - return ResourceManager.GetString("Save_or_update_user_failed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to specialist. - /// - internal static string specialist { - get { - return ResourceManager.GetString("specialist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to NFC Tag. - /// - internal static string Tag { - get { - return ResourceManager.GetString("Tag", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This NFC tag has already been taken. Please use another one.. - /// - internal static string Tag_taken { - get { - return ResourceManager.GetString("Tag_taken", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to tester. - /// - internal static string tester { - get { - return ResourceManager.GetString("tester", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User code. - /// - internal static string User_code { - get { - return ResourceManager.GetString("User_code", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User Login. - /// - internal static string User_Login { - get { - return ResourceManager.GetString("User_Login", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User Management. - /// - internal static string User_Management { - get { - return ResourceManager.GetString("User_Management", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User name. - /// - internal static string User_name { - get { - return ResourceManager.GetString("User_name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This Username has already been taken. Please choose another one.. - /// - internal static string Username_taken { - get { - return ResourceManager.GetString("Username_taken", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Warning. - /// - internal static string Warning { - get { - return ResourceManager.GetString("Warning", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to water meter authority. - /// - internal static string water_meter_authority { - get { - return ResourceManager.GetString("water_meter_authority", resourceCulture); - } - } - } -} diff --git a/Users/Resources/Strings.cs.resx b/Users/Resources/Strings.cs.resx deleted file mode 100644 index 23befb2a4..000000000 --- a/Users/Resources/Strings.cs.resx +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Přidat - - - Zrušit - - - Popis - - - Editovat - - - Editace uživatele - - - Chyba - - - Jméno a příjmení - - - Skupiny - - - ID - - - Neplatné uživatelské jméno či heslo - - - (max. {0} alfanumerických znaků) - - - Jméno - - - OK - - - Heslo - - - Odstranit - - - Zopakujte heslo - - - Toto uživatelské jméno již bylo použito. Prosím, vyberte jiné. - - - Kód uživatele - - - Uživatelský login - - - Správa uživatelů - - - Uživatelské jméno - - - Zavřít - - - Potvrzení - - - Vytvořených {0} uživatelů v lokální databáze. - - - Varování - - - administrátor - - - může kalibrovat - - - vedoucí - - - úderžbář - - - metrológ - - - specialista - - - tester - - - neplatný - - - Tento NFC tag již byl použit. Prosím, použite jiný. - - - správce sledování výroby - - - Změňte svoje heslo prosím - - - Nové heslo - - - Verifikace nového hesla - - - Staré heslo - - - Nové heslo a jeho verifikace jsou různé - - - Heslo nesplňuje požadavky - - - Heslo už bylo v minulosti použito - - - Power uživatel nemůže změnit heslo - - - Heslo musí mít nejméně {0} znaků - - \ No newline at end of file diff --git a/Users/Resources/Strings.de.resx b/Users/Resources/Strings.de.resx deleted file mode 100644 index 0d10e7653..000000000 --- a/Users/Resources/Strings.de.resx +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Neu - - - Abbrechen - - - Beschreibung - - - Bearbeiten - - - Benutzer einrichten - - - Fehler - - - Vorname und Nachname - - - Gruppen - - - ID - - - Ungültiger Benutzername oder Passwort - - - (maximal {0} alphanumerische Zeichen) - - - Name - - - OK - - - Passwort - - - Tabelle entfernen - - - Passwort wiederholen - - - Benutzername ist bereits vergeben. Bitte einen anderen Namen wählen! - - - Benutzernummer - - - Anmelden - - - Benutzerverwaltung - - - Benutzername - - - Beenden - - - Bestätigung - - - {0} Benutzer kopiert. - - - Warnung - - - Administrator - - - Eichbeamter / Techniker - - - Laborleiter - - - Wartungstechniker - - - Metrologe - - - Prüftechniker - - - Prüfer - - - Keine Fernwartung der Benutzerdatenbank! - - - Sind sie sicher? - - - Kopieren der fehlerhaften Fernwartungsbenutzer! - - - Speichern oder update der fehlerhaften Benutzer. - - - Fehlerhaft - - - NFC Magnetkarte - - - Dieses NFC Magnetkarte wurde bereits benutzt. Bitte eine andere benutzen! - - - Produktionsergebnisse verfolgen(Administrator) - - - Metrologie - - - Eichamt - - - Bitte Passwort ändern! - - - Neues Passwort prüfen! - - - Neues Passwort prüfen! - - - Altes Passwort - - - Neues Passwort stimmt nicht überein! - - - Passwort entspricht nicht den Vorgaben! - - - Passwort wurde bereits benutzt! - - - Poweruser kann nicht das Passwort ändern! - - - Passwort muss mindestens {0} Zeichen haben! - - \ No newline at end of file diff --git a/Users/Resources/Strings.fr.resx b/Users/Resources/Strings.fr.resx deleted file mode 100644 index 52bc66224..000000000 --- a/Users/Resources/Strings.fr.resx +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Ajouter - - - Annuler exte Btn - - - Description - - - Éditer - - - Modifier utilisateur - - - Erreur - - - Nom complet - - - Groupes - - - ID - - - Nom ou mot passe utilisateur non valide - - - max {0} caractères alphanum - - - Prénom - - - Ok - - - Mot de passe - - - Supprimer - - - Répéter mot passe - - - Ce nom d'utilisateur a déjà été pris. Veuillez en choisir un autre. - - - Code utilisateur - - - Utilisateur en ligne - - - Gestion utilisateurs - - - Nom d'utilisateur - - - Fermer - - - Pas télécommande sur base utilisateurs - - - Êtes-vous sûr ? - - - Attention - - - Confirmation - - - {0} utilisateurs copiés - - - Copie utilisateurs a échoué - - - Enregistrement ou mise à jour utilisateur a échoué - - - Administrateur - - - Spécialiste en calibration - - - Chef de laboratoire - - - Spécialiste en maintenance - - - Métrologue - - - Spécialiste d'essais - - - Testeur - - - invalide - - - NFC tag - - - Ce tag NFC a déjà été pris. S'il vous plaît utiliser un autre. - - - administrateur suivi production - - \ No newline at end of file diff --git a/Users/Resources/Strings.it.resx b/Users/Resources/Strings.it.resx deleted file mode 100644 index 47949020f..000000000 --- a/Users/Resources/Strings.it.resx +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Amministratore - - - esperto in calibrazione - - - capo di laboratorio - - - esperto di manutenzione - - - metrologo - - - esperto di prove - - - tester - - \ No newline at end of file diff --git a/Users/Resources/Strings.pl.resx b/Users/Resources/Strings.pl.resx deleted file mode 100644 index 5ea18b88d..000000000 --- a/Users/Resources/Strings.pl.resx +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Dodaj - - - Anuluj - - - Opis - - - Edycja - - - Edytuj użytkownika - - - Błąd - - - Imię i Nazwisko - - - Grupy - - - ID - - - Nieprawidłowa nazwa użytkownika lub hasło - - - (max. {0} znaków alfanumerycznych) - - - Nazwa - - - OK - - - Hasło - - - Usuń - - - Hasło 2 - - - Ta Nazwa użytkownika jest już zajęta. Proszę wybrać inną. - - - Kod użytkownika - - - Login użytkownika - - - Uprawnienia użytkownika - - - Nazwa użytkownika - - - Zamknij - - - Administrator - - - Specjalista ds. kalibracji - - - Kierownik Laboratorium - - - Konserwator - - - Metrolog - - - Specjalista ds. testów - - - Pracownik przeprowadzający testy - - \ No newline at end of file diff --git a/Users/Resources/Strings.resx b/Users/Resources/Strings.resx deleted file mode 100644 index 400433a57..000000000 --- a/Users/Resources/Strings.resx +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Add - - - Cancel - - - Description - - - Edit - - - Edit User - - - Error - - - Name and Surname - - - Groups - - - ID - - - Invalid username or password - - - (max. {0} alphanumeric characters) - - - Name - - - OK - - - Password - - - Remove - - - Repeat password - - - This Username has already been taken. Please choose another one. - - - User code - - - User Login - - - User Management - - - User name - - - Close - - - No remote database of users - - - Are you sure? - - - Warning - - - Confirmation - - - {0} users copied - - - Copying remote users failed - - - Save or update user failed - - - administrator - - - calibration specialist - - - head of lab. - - - maintenance - - - metrologist - - - specialist - - - tester - - - invalid - - - NFC Tag - - - This NFC tag has already been taken. Please use another one. - - - production tracing administrator - - - metrological authority - - - water meter authority - - - Change your password please - - - New password - - - New password verification - - - Old password - - - New password and it's verification are different - - - Password does not meet requirements - - - Password has been used in the past - - - Power user cannot change it's password - - - Password must have at least {0} characters - - \ No newline at end of file diff --git a/Users/Resources/Strings.ru.resx b/Users/Resources/Strings.ru.resx deleted file mode 100644 index 29c04444b..000000000 --- a/Users/Resources/Strings.ru.resx +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - Добавить - - - Отмена - - - Описание - - - Редактировать - - - Редактировать пользователя - - - Ошибка - - - Имя и фамилия - - - Группы - - - ID - - - Неправильное имя пользователя или пароль - - - (макс. {0} вуквенно-цифровых символов) - - - Имя - - - OK - - - Пароль - - - Удалить - - - Пароль 2 - - - Это Имя пользователя уже принято. Пожалуйста, выберите другое. - - - Код пользователя - - - Логин пользователя - - - Управление пользователями - - - Имя пользователя - - - Закрыть - - - Администратор - - - Специалист по калибровке - - - Руководитель лаборатории - - - Специалист по техобслуживанию - - - Метролог - - - Специалист по тестированию - - - Контролер - - \ No newline at end of file diff --git a/Users/Resources/Strings.zh-CN.resx b/Users/Resources/Strings.zh-CN.resx deleted file mode 100644 index 1e0c3c89d..000000000 --- a/Users/Resources/Strings.zh-CN.resx +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - 添加 Add - - - 取消 Cancel - - - 描述 - - - 编辑 Edit - - - 编辑用户 - - - 错误 Error - - - - - - 组别 - - - ID - - - 无效的用户名或密码 - - - (最大 {0} 字母数字字符) - - - 名称 - - - 好 OK - - - 密码 - - - 删除 Remove - - - 密码2 - - - 此用户名已被占用。请选择另外一个。 - - - - - - 用户登录 - - - 用户管理 - - - 用户名 - - - 关闭 Close - - - 管理员 - - - 校准专员 - - - 实验室负责人 - - - 维护专员 - - - 计量者 - - - 测试专员 - - - 测试仪 - - \ No newline at end of file diff --git a/Users/Users.csproj b/Users/Users.csproj deleted file mode 100644 index 38ba71952..000000000 --- a/Users/Users.csproj +++ /dev/null @@ -1,146 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} - Library - Properties - Users - Users - v4.7.2 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - x86 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll - - - ..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll - - - ..\packages\log4net.2.0.2\lib\net40-full\log4net.dll - - - ..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll - - - ..\packages\NHibernate.4.0.4.4000\lib\net40\NHibernate.dll - - - - - - - - - - - - - - - - - - - Form - - - PasswordChangeDlg.cs - - - - - - - - Form - - - EditSelectedUser.cs - - - Form - - - UserManagementDlg.cs - - - Form - - - LoginDlg.cs - - - - - - True - True - Strings.resx - - - - - {8B10D15A-39DE-4B56-8DD1-710C1EB3A697} - GemCard - - - - - EditSelectedUser.cs - - - PasswordChangeDlg.cs - - - UserManagementDlg.cs - - - LoginDlg.cs - - - - - - - - ResXFileCodeGenerator - Strings.Designer.cs - - - - - - - \ No newline at end of file diff --git a/Users/UsersDB.cs b/Users/UsersDB.cs deleted file mode 100644 index 50861799e..000000000 --- a/Users/UsersDB.cs +++ /dev/null @@ -1,154 +0,0 @@ -/// -/// Copyright (c) 2016-2018 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using FluentNHibernate.Cfg; -using FluentNHibernate.Cfg.Db; -using log4net; -using NHibernate; -using NHibernate.Cfg; -using NHibernate.Tool.hbm2ddl; -using Users.Entities; - -namespace Users -{ - public static class UsersDB - { - static readonly ILog log = LogManager.GetLogger(typeof(UsersDB)); - - /// Session factory for all regular sessions, not for CreateEmptyResultsDB(). - public static ISessionFactory SessionFactory; - public static ISession CurrentSession; - - /// Connection string for all sessions - private static string connectionString; - /// - public static string ConnectionString - { - get { return connectionString; } - set { connectionString = value; SessionFactory = null; } - } - - /// Database type (MySQL or SQLite) for all sessions - private static DBType dbType; - /// - public static DBType DbType - { - get { return dbType; } - set { dbType = value; SessionFactory = null; } - } - - /// - /// NHibernate session factory (to create the database session 'SessionFactory') - /// - /// A database session - static ISessionFactory CreateSessionFactory() - { - return CreateSessionFactory(false); - } - - /// - /// NHibernate session factory (to create the database session 'SessionFactory') - /// - /// true = Create a new DB, false = Regular DB - /// A database session - public static ISessionFactory CreateSessionFactory(bool createDB) - { - FluentConfiguration cfg = Fluently.Configure(); - - switch (dbType) - { - default: - case DBType.SQLite: - cfg = cfg.Database(SQLiteConfiguration.Standard.UsingFile(connectionString)); - break; - case DBType.MySql: - cfg = cfg.Database(MySQLConfiguration.Standard.ConnectionString(connectionString)); - break; - } - - cfg = cfg.Mappings(m => m.FluentMappings.AddFromAssemblyOf()); - - if (createDB) - { - return cfg.ExposeConfiguration(BuildSchemaCreate).BuildSessionFactory(); - } - else - { - return cfg.ExposeConfiguration(BuildSchema).BuildSessionFactory(); - } - } - - static void BuildSchema(Configuration config) - { - /// This NHibernate tool takes a configuration with mapping info and exports a database schema - new SchemaExport(config).SetOutputFile("db_schema"); - } - - static void BuildSchemaCreate(Configuration config) - { - /// This NHibernate tool takes a configuration with mapping info and exports a database schema - new SchemaExport(config).Create(true, true); - } - - /// Create a NHibernate session for the given database - public static ISession CreateSession() - { - if (string.IsNullOrEmpty(connectionString)) - { - throw new Exception("Connection string was not specified"); - } - - if (SessionFactory == null) SessionFactory = CreateSessionFactory(); - - CurrentSession = SessionFactory.OpenSession(); - return CurrentSession; - } - - - /// - /// Create an empty users database. - /// Database contains only the user 'admin' and the control board component 'CB'. - /// - /// DBType.SQLite or DBType.MySql - /// Connection string - /// true=success, false=error - public static bool CreateEmptyDB() - { - ISessionFactory sessionFactory = CreateSessionFactory(true); - if (sessionFactory == null) return false; - - /// Populate the database - using (var session = sessionFactory.OpenSession()) - { - using (var transaction = session.BeginTransaction()) - { - transaction.Commit(); - } - } - - return true; - } - - - /// - /// Shared data - /// - public static IList Users; - public static IList Groups; - - - /// - /// Loads shared data from the database - /// - /// Throws NHibernate exceptions - public static void LoadSharedData() - { - ISession session = UsersDB.CreateSession(); - - Users = session.QueryOver().List(); - Groups = session.QueryOver().List(); - } - } -} diff --git a/clean.bat b/clean.bat index 63648390e..20447d4b3 100644 --- a/clean.bat +++ b/clean.bat @@ -16,8 +16,6 @@ rmdir /s /q Encrypt\bin rmdir /s /q Encrypt\obj rmdir /s /q EventViewer\bin rmdir /s /q EventViewer\obj -rmdir /s /q Events\bin -rmdir /s /q Events\obj rmdir /s /q FeatureVectorCalculator\bin rmdir /s /q FeatureVectorCalculator\obj rmdir /s /q GemCard\bin @@ -60,8 +58,6 @@ rmdir /s /q ToFirstMonitor\bin rmdir /s /q ToFirstMonitor\obj rmdir /s /q ToSecondMonitor\bin rmdir /s /q ToSecondMonitor\obj -rmdir /s /q Users\bin -rmdir /s /q Users\obj rmdir /s /q UserManagement\bin rmdir /s /q UserManagement\obj rmdir /s /q WorkflowConfigurator\bin