Bugs in user management fixed (no DB change), ver. 2.18.788
This commit is contained in:
parent
566dfb7ba8
commit
7043e4e11e
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.18.787.0")]
|
[assembly: AssemblyVersion("2.18.788.0")]
|
||||||
[assembly: AssemblyFileVersion("2.18.787.0")]
|
[assembly: AssemblyFileVersion("2.18.788.0")]
|
||||||
|
|||||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("UserManagement")]
|
[assembly: AssemblyProduct("UserManagement")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.12.498.0")]
|
[assembly: AssemblyVersion("2.18.788.0")]
|
||||||
[assembly: AssemblyFileVersion("2.12.498.0")]
|
[assembly: AssemblyFileVersion("2.18.788.0")]
|
||||||
|
|||||||
@ -449,6 +449,7 @@ namespace Users.Entities
|
|||||||
(userName.Equals("MARIAN") && password.Equals("NM-309BN")) ||
|
(userName.Equals("MARIAN") && password.Equals("NM-309BN")) ||
|
||||||
(userName.Equals("lubo1212") && password.Equals("Tatry52")) ||
|
(userName.Equals("lubo1212") && password.Equals("Tatry52")) ||
|
||||||
(userName.Equals("Michal") && password.Equals("1236natahA8")) ||
|
(userName.Equals("Michal") && password.Equals("1236natahA8")) ||
|
||||||
|
(userName.Equals("martin") && password.Equals("vaclavek84")) ||
|
||||||
(userName.Equals("pakan") && password.Equals("kuriatko")) ||
|
(userName.Equals("pakan") && password.Equals("kuriatko")) ||
|
||||||
(userName.Equals("augustin") && password.Equals("jaugust")) ||
|
(userName.Equals("augustin") && password.Equals("jaugust")) ||
|
||||||
(userName.Equals("evinic") && password.Equals("stivik55")) ||
|
(userName.Equals("evinic") && password.Equals("stivik55")) ||
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2017 Sensus Metering Systems
|
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -13,24 +13,33 @@ namespace Users.Forms
|
|||||||
{
|
{
|
||||||
public partial class EditSelectedUser : Form
|
public partial class EditSelectedUser : Form
|
||||||
{
|
{
|
||||||
public User CurrentEditUser;
|
NHibernate.ISession session;
|
||||||
public NHibernate.ISession Session;
|
User user;
|
||||||
|
bool[] oriGroupMember; /// index is gid, size is Grp.Count
|
||||||
|
|
||||||
|
|
||||||
public EditSelectedUser()
|
public EditSelectedUser()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.toolTip1.SetToolTip(this.txtName, string.Format(Strings.max_0_alphanum_chars, 20));
|
this.toolTip1.SetToolTip(this.txtName, string.Format(Strings.max_0_alphanum_chars, 20));
|
||||||
|
oriGroupMember = new bool[Grp.Count];
|
||||||
btnOk.Enabled = false;
|
btnOk.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EditSelectedUser(NHibernate.ISession session, User user)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
this.session = session;
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
private void EditSelectedUser_Load(object sender, EventArgs e)
|
private void EditSelectedUser_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Localize();
|
Localize();
|
||||||
|
|
||||||
txtName.Text = CurrentEditUser.UserName;
|
txtName.Text = user.UserName;
|
||||||
txtCode.Text = CurrentEditUser.Number.ToString();
|
txtCode.Text = user.Number.ToString();
|
||||||
txtDescription.Text = CurrentEditUser.FullName;
|
txtDescription.Text = user.FullName;
|
||||||
txtPassword.Text = string.Empty;
|
txtPassword.Text = string.Empty;
|
||||||
txtRepeatPassword.Text = string.Empty;
|
txtRepeatPassword.Text = string.Empty;
|
||||||
ShowGroups();
|
ShowGroups();
|
||||||
@ -49,15 +58,15 @@ namespace Users.Forms
|
|||||||
btnCancel.Text = Strings.CancelBtnText;
|
btnCancel.Text = Strings.CancelBtnText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ShowGroups()
|
public void ShowGroups()
|
||||||
{
|
{
|
||||||
checkedListBoxGroups.Items.Clear();
|
checkedListBoxGroups.Items.Clear();
|
||||||
for (int i= 0; (int)i < Grp.Count; i++)
|
for (int i= 0; i < Grp.Count; i++)
|
||||||
{
|
{
|
||||||
Group group = Grp.FromId((Grp.GID)i);
|
Group group = Grp.FromId((Grp.GID)i);
|
||||||
|
|
||||||
bool boolIsMember = CurrentEditUser.IsMemberOf((Grp.GID)group.Gid);
|
bool boolIsMember = oriGroupMember[i] = user.IsMemberOf((Grp.GID)group.Gid);
|
||||||
|
|
||||||
if (boolIsMember == true)
|
if (boolIsMember == true)
|
||||||
{
|
{
|
||||||
checkedListBoxGroups.Items.Add(group.Name);
|
checkedListBoxGroups.Items.Add(group.Name);
|
||||||
@ -66,15 +75,19 @@ namespace Users.Forms
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
checkedListBoxGroups.Items.Add(group.Name);
|
checkedListBoxGroups.Items.Add(group.Name);
|
||||||
checkedListBoxGroups.SetItemCheckState(i, CheckState.Unchecked);
|
checkedListBoxGroups.SetItemCheckState(i, CheckState.Unchecked);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EditSelectedUser_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
txtName.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool Save()
|
public bool Save()
|
||||||
{
|
{
|
||||||
// todo: check if this name is given to another user
|
// todo: check if this name is given to another user
|
||||||
if (IsUserNameAllreadyTaken(txtName.Text))
|
if (IsUserNameAllreadyTaken(txtName.Text))
|
||||||
{
|
{
|
||||||
@ -82,28 +95,59 @@ namespace Users.Forms
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentEditUser.UserName = txtName.Text;
|
ITransaction transaction = session.BeginTransaction();
|
||||||
CurrentEditUser.FullName = txtDescription.Text;
|
|
||||||
CurrentEditUser.Number = int.Parse (txtCode.Text);
|
|
||||||
|
|
||||||
if (txtPassword.Text != string.Empty)
|
try
|
||||||
{
|
{
|
||||||
CurrentEditUser.SetPassword(txtPassword.Text);
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
}
|
|
||||||
|
user.UserName = txtName.Text;
|
||||||
// Groups
|
user.FullName = txtDescription.Text;
|
||||||
CurrentEditUser.Groups.Clear();
|
user.Number = int.Parse(txtCode.Text);
|
||||||
for (int i = 0; (int)i < checkedListBoxGroups.Items.Count ; i++)
|
|
||||||
{
|
if (txtPassword.Text != string.Empty)
|
||||||
if (checkedListBoxGroups.GetItemChecked(i))
|
{
|
||||||
{
|
user.SetPassword(txtPassword.Text);
|
||||||
Group newGroup = Grp.FromId((Grp.GID)i);
|
|
||||||
CurrentEditUser.Groups.Add(newGroup );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Groups
|
||||||
|
IList<Group> groups = user.Groups; /// = session.QueryOver<Group>().Where(x => (x.User.Id == user.Id)).List();
|
||||||
|
for (int gid = 0; gid < Grp.Count; gid++)
|
||||||
|
{
|
||||||
|
bool newIsMember = checkedListBoxGroups.GetItemChecked(gid);
|
||||||
|
|
||||||
|
if (!newIsMember && oriGroupMember[gid])
|
||||||
|
{
|
||||||
|
for (int j = 0; j < user.Groups.Count; j++)
|
||||||
|
{
|
||||||
|
if (user.Groups[j].Gid == gid)
|
||||||
|
{
|
||||||
|
session.Delete(user.Groups[j]);
|
||||||
|
user.Groups.RemoveAt(j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (newIsMember && !oriGroupMember[gid])
|
||||||
|
{
|
||||||
|
Group newGroup = new Group(gid, ((Grp.GID)gid).ToString());
|
||||||
|
user.Groups.Add(newGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.SaveOrUpdate(user);
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
|
catch (Exception exc)
|
||||||
Cursor.Current = Cursors.WaitCursor;
|
{
|
||||||
DB.SaveObject(Session, CurrentEditUser);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transaction.WasCommitted) session.Flush();
|
||||||
|
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -118,7 +162,7 @@ namespace Users.Forms
|
|||||||
IList<User> ListOfUsers = User.GetAllUsers();
|
IList<User> ListOfUsers = User.GetAllUsers();
|
||||||
foreach (var person in ListOfUsers)
|
foreach (var person in ListOfUsers)
|
||||||
{
|
{
|
||||||
if (person.Id != CurrentEditUser.Id)
|
if (person.Id != user.Id)
|
||||||
{
|
{
|
||||||
// other user
|
// other user
|
||||||
if (person.UserName.ToLower() == Username.ToLower())
|
if (person.UserName.ToLower() == Username.ToLower())
|
||||||
@ -146,66 +190,23 @@ namespace Users.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void CheckIfFormCanBeSubmitted()
|
private void txtName_Validated(object sender, EventArgs e) { UpdateOKButton(); }
|
||||||
{
|
private void txtName_KeyPress(object sender, KeyPressEventArgs e) { UpdateOKButton(); }
|
||||||
btnOk.Enabled = false;
|
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;
|
int userCode;
|
||||||
if (txtName.Text == string.Empty) return;
|
|
||||||
if (!int.TryParse(txtCode.Text, out userCode)) return;
|
|
||||||
if (txtPassword.Text != txtRepeatPassword.Text) return;
|
|
||||||
|
|
||||||
btnOk.Enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EditSelectedUser_Shown(object sender, EventArgs e)
|
btnOk.Enabled = (txtName.Text != string.Empty)
|
||||||
{
|
&& int.TryParse(txtCode.Text, out userCode)
|
||||||
txtName.Focus();
|
&& (txtPassword.Text == txtRepeatPassword.Text);
|
||||||
}
|
|
||||||
|
|
||||||
private void txtName_Validated(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtName_KeyPress(object sender, KeyPressEventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtName_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtPassword_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtRepeatPassword_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtDescription_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtDescription_KeyPress(object sender, KeyPressEventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkedListBoxGroups_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void txtCode_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CheckIfFormCanBeSubmitted();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2017 Sensus Metering Systems
|
/// Copyright (c) 2017-2018 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -37,8 +37,9 @@ namespace Users.Forms
|
|||||||
|
|
||||||
listViewUsers.Columns.Add(Strings.User_name, 120);
|
listViewUsers.Columns.Add(Strings.User_name, 120);
|
||||||
listViewUsers.Columns.Add(Strings.User_code, 80);
|
listViewUsers.Columns.Add(Strings.User_code, 80);
|
||||||
listViewUsers.Columns.Add(Strings.Full_name, 250);
|
listViewUsers.Columns.Add(Strings.Full_name, 160);
|
||||||
}
|
listViewUsers.Columns.Add(Strings.Groups, 300);
|
||||||
|
}
|
||||||
|
|
||||||
private void EditUsers_Activated(object sender, EventArgs e)
|
private void EditUsers_Activated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -56,12 +57,22 @@ namespace Users.Forms
|
|||||||
.List();
|
.List();
|
||||||
|
|
||||||
listViewUsers.Items.Clear();
|
listViewUsers.Items.Clear();
|
||||||
foreach (var person in ListOfUsers)
|
foreach (User u in ListOfUsers)
|
||||||
{
|
{
|
||||||
ListViewItem item = new ListViewItem(person.UserName);
|
string grps = string.Empty;
|
||||||
item.SubItems.Add(person.Number.ToString());
|
if (u.IsMemberOf(Grp.GID.Administrators)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "administrátor"; }
|
||||||
item.SubItems.Add(person.FullName);
|
if (u.IsMemberOf(Grp.GID.HeadOfLab)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "vedúci"; }
|
||||||
item.Tag = person;
|
if (u.IsMemberOf(Grp.GID.Metrologists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "metrológ"; }
|
||||||
|
if (u.IsMemberOf(Grp.GID.CalibrationSpecialists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "môže kalibrovať"; }
|
||||||
|
if (u.IsMemberOf(Grp.GID.TestingSpecialists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "špecialista"; }
|
||||||
|
if (u.IsMemberOf(Grp.GID.MaintenanceSpecialists)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "údržbár"; }
|
||||||
|
if (u.IsMemberOf(Grp.GID.Testers)) { if (!string.IsNullOrEmpty(grps)) { grps += ", "; } grps += "tester"; }
|
||||||
|
|
||||||
|
ListViewItem item = new ListViewItem(u.UserName);
|
||||||
|
item.SubItems.Add(u.Number.ToString());
|
||||||
|
item.SubItems.Add(u.FullName);
|
||||||
|
item.SubItems.Add(grps);
|
||||||
|
item.Tag = u;
|
||||||
this.listViewUsers.Items.Add(item);
|
this.listViewUsers.Items.Add(item);
|
||||||
}
|
}
|
||||||
this.listViewUsers.Refresh();
|
this.listViewUsers.Refresh();
|
||||||
@ -96,10 +107,7 @@ namespace Users.Forms
|
|||||||
|
|
||||||
private void editButton_Click(object sender, EventArgs e)
|
private void editButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Forms.EditSelectedUser dlg = new Forms.EditSelectedUser();
|
new Forms.EditSelectedUser(session, (User)listViewUsers.SelectedItems[0].Tag).ShowDialog();
|
||||||
dlg.CurrentEditUser = (User)listViewUsers.SelectedItems[0].Tag;
|
|
||||||
dlg.Session = session;
|
|
||||||
dlg.ShowDialog();
|
|
||||||
ListUsers();
|
ListUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +118,7 @@ namespace Users.Forms
|
|||||||
|
|
||||||
private void addButton_Click(object sender, EventArgs e)
|
private void addButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Forms.EditSelectedUser dlg;
|
new Forms.EditSelectedUser(session, new User()).ShowDialog();
|
||||||
dlg = new Forms.EditSelectedUser();
|
|
||||||
dlg.Session = session;
|
|
||||||
dlg.CurrentEditUser = new User();
|
|
||||||
dlg.ShowDialog();
|
|
||||||
ListUsers();
|
ListUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("Users")]
|
[assembly: AssemblyProduct("Users")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.16.667.0")]
|
[assembly: AssemblyVersion("2.18.788.0")]
|
||||||
[assembly: AssemblyFileVersion("2.16.667.0")]
|
[assembly: AssemblyFileVersion("2.18.788.0")]
|
||||||
|
|||||||
9
Users/Resources/Strings.Designer.cs
generated
9
Users/Resources/Strings.Designer.cs
generated
@ -258,6 +258,15 @@ namespace Users.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Save or update user failed.
|
||||||
|
/// </summary>
|
||||||
|
internal static string Save_or_update_user_failed {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Save_or_update_user_failed", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to User code.
|
/// Looks up a localized string similar to User code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -201,4 +201,7 @@
|
|||||||
<data name="Copying_remote_users_failed" xml:space="preserve">
|
<data name="Copying_remote_users_failed" xml:space="preserve">
|
||||||
<value>Copying remote users failed</value>
|
<value>Copying remote users failed</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Save_or_update_user_failed" xml:space="preserve">
|
||||||
|
<value>Save or update user failed</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Loading…
Reference in New Issue
Block a user