UsersGroups table added to config DB, User and Group have ManyToMany relation, ver. 2.25.1400
This commit is contained in:
parent
ab43cabc57
commit
4090bd1618
@ -1,7 +1,8 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Config.Entities
|
namespace Config.Entities
|
||||||
{
|
{
|
||||||
@ -9,14 +10,18 @@ namespace Config.Entities
|
|||||||
{
|
{
|
||||||
public virtual int Id { get; protected set; }
|
public virtual int Id { get; protected set; }
|
||||||
public virtual Users.Entities.GID GID { get; set; }
|
public virtual Users.Entities.GID GID { get; set; }
|
||||||
|
public virtual long AccessFlags { get; set; } /// Bitfield of access flags: bit0 .. bit62
|
||||||
|
public virtual IList<User> Users { get; set; } /// Group can be a member of a list of users
|
||||||
|
|
||||||
public Group()
|
public Group()
|
||||||
{
|
{
|
||||||
|
Users = new List<User>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Group(Users.Entities.GID gid)
|
public Group(Users.Entities.GID gid)
|
||||||
{
|
: this()
|
||||||
|
{
|
||||||
GID = gid;
|
GID = gid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,17 +145,8 @@ namespace Config
|
|||||||
using (var transaction = session.BeginTransaction())
|
using (var transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
/// Prepare all groups
|
/// Create user 'admin'
|
||||||
///
|
///
|
||||||
var testers = new Config.Entities.Group(Users.Entities.GID.Testers);
|
|
||||||
var testingSpecialists = new Config.Entities.Group(Users.Entities.GID.TestingSpecialists);
|
|
||||||
var headOfLab = new Config.Entities.Group(Users.Entities.GID.HeadOfLab);
|
|
||||||
var maintenanceSpecialists = new Config.Entities.Group(Users.Entities.GID.MaintenanceSpecialists);
|
|
||||||
var metrologists = new Config.Entities.Group(Users.Entities.GID.Metrologists);
|
|
||||||
var calibrationSpecialists = new Config.Entities.Group(Users.Entities.GID.CalibrationSpecialists);
|
|
||||||
var administrators = new Config.Entities.Group(Users.Entities.GID.Administrators);
|
|
||||||
|
|
||||||
/// Create the user 'admin' add his groups
|
|
||||||
var admin = new Config.Entities.User
|
var admin = new Config.Entities.User
|
||||||
{
|
{
|
||||||
UserName = Data.AdminUsername,
|
UserName = Data.AdminUsername,
|
||||||
@ -163,20 +154,35 @@ namespace Config
|
|||||||
LastPwChange = DateTime.Now
|
LastPwChange = DateTime.Now
|
||||||
};
|
};
|
||||||
admin.SetPassword(Data.AdminPassword);
|
admin.SetPassword(Data.AdminPassword);
|
||||||
admin.AddGroup(testers);
|
|
||||||
admin.AddGroup(testingSpecialists);
|
|
||||||
admin.AddGroup(headOfLab);
|
|
||||||
admin.AddGroup(maintenanceSpecialists);
|
|
||||||
admin.AddGroup(metrologists);
|
|
||||||
admin.AddGroup(calibrationSpecialists);
|
|
||||||
admin.AddGroup(administrators);
|
|
||||||
|
|
||||||
session.SaveOrUpdate(admin);
|
///
|
||||||
|
/// Prepare all groups, add some of them to admin
|
||||||
///// Create the control board component
|
///
|
||||||
//var cmpnt = (new BenchControl.Elde.ControlBoardCfg(new BenchControl.Elde.ControlBoardFactory())).CreateDbEntity();
|
for (Users.Entities.GID gid = 0; gid < Users.Entities.GID.NrOfGroups; gid++)
|
||||||
//session.SaveOrUpdate(cmpnt);
|
{
|
||||||
|
Config.Entities.Group group = new Config.Entities.Group(gid);
|
||||||
|
switch (gid)
|
||||||
|
{
|
||||||
|
case Users.Entities.GID.Testers:
|
||||||
|
case Users.Entities.GID.TestingSpecialists:
|
||||||
|
case Users.Entities.GID.HeadOfLab:
|
||||||
|
case Users.Entities.GID.MaintenanceSpecialists:
|
||||||
|
case Users.Entities.GID.Metrologists:
|
||||||
|
case Users.Entities.GID.CalibrationSpecialists:
|
||||||
|
case Users.Entities.GID.Administrators:
|
||||||
|
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
|
||||||
|
case Users.Entities.GID.TraceabilityManagement:
|
||||||
|
#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_END
|
||||||
|
case Users.Entities.GID.MetrologicalAuthority:
|
||||||
|
case Users.Entities.GID.WaterMeterAuthority:
|
||||||
|
#endif
|
||||||
|
admin.AddGroup(group);
|
||||||
|
session.SaveOrUpdate(group); /// Save this group
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.SaveOrUpdate(admin); /// Save user 'admin'
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using FluentNHibernate.Mapping;
|
using FluentNHibernate.Mapping;
|
||||||
|
|
||||||
@ -7,10 +7,18 @@ namespace Config.Mappings
|
|||||||
{
|
{
|
||||||
class GroupMap : ClassMap<Entities.Group>
|
class GroupMap : ClassMap<Entities.Group>
|
||||||
{
|
{
|
||||||
|
/// <seealso>
|
||||||
|
/// https://stackoverflow.com/questions/9108083/fluent-nhibernate-many-to-many-mapping-way/9125059
|
||||||
|
/// </seealso>
|
||||||
public GroupMap()
|
public GroupMap()
|
||||||
{
|
{
|
||||||
Id(x => x.Id);
|
Id(x => x.Id);
|
||||||
Map(x => x.GID).Column("Name"); ;
|
Map(x => x.GID).Column("Name");
|
||||||
|
Map(x => x.AccessFlags);
|
||||||
|
HasManyToMany(x => x.Users)
|
||||||
|
.Cascade.SaveUpdate()
|
||||||
|
.Inverse()
|
||||||
|
.Table("UsersGroups");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using FluentNHibernate.Mapping;
|
using FluentNHibernate.Mapping;
|
||||||
|
|
||||||
@ -19,8 +19,9 @@ namespace Config.Mappings
|
|||||||
Map(x => x.Password4);
|
Map(x => x.Password4);
|
||||||
Map(x => x.FullName).Column("Description");
|
Map(x => x.FullName).Column("Description");
|
||||||
Map(x => x.LastPwChange);
|
Map(x => x.LastPwChange);
|
||||||
HasMany(x => x.Groups)
|
HasManyToMany(x => x.Groups)
|
||||||
.Cascade.All();
|
.Cascade.SaveUpdate()
|
||||||
|
.Table("UsersGroups");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.24.1382.0")]
|
[assembly: AssemblyVersion("2.25.1400.0")]
|
||||||
[assembly: AssemblyFileVersion("2.24.1382.0")]
|
[assembly: AssemblyFileVersion("2.25.1400.0")]
|
||||||
|
|||||||
@ -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.24.1390.0")]
|
[assembly: AssemblyVersion("2.25.1400.0")]
|
||||||
[assembly: AssemblyFileVersion("2.24.1390.0")]
|
[assembly: AssemblyFileVersion("2.25.1400.0")]
|
||||||
|
|||||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.24.1391.0")]
|
[assembly: AssemblyVersion("2.25.1400.0")]
|
||||||
[assembly: AssemblyFileVersion("2.24.1391.0")]
|
[assembly: AssemblyFileVersion("2.25.1400.0")]
|
||||||
|
|||||||
@ -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.24.1368.0")]
|
[assembly: AssemblyVersion("2.25.1400.0")]
|
||||||
[assembly: AssemblyFileVersion("2.24.1368.0")]
|
[assembly: AssemblyFileVersion("2.25.1400.0")]
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -11,16 +11,25 @@ namespace Users.Entities
|
|||||||
{
|
{
|
||||||
public virtual int Id { get; protected set; }
|
public virtual int Id { get; protected set; }
|
||||||
public virtual GID GID { get; set; }
|
public virtual GID GID { get; set; }
|
||||||
|
public virtual long AccessFlags { get; set; } /// Bitfield of access flags: bit0 .. bit62
|
||||||
|
public virtual IList<User> Users { get; set; } /// Group can be a member of a list of users
|
||||||
|
|
||||||
public Group()
|
public Group()
|
||||||
{
|
{
|
||||||
}
|
Users = new List<User>();
|
||||||
|
}
|
||||||
|
|
||||||
public Group(GID gid)
|
public Group(GID gid)
|
||||||
|
: this()
|
||||||
{
|
{
|
||||||
GID = gid;
|
GID = gid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string Gid2Str()
|
||||||
|
{
|
||||||
|
return Group.Gid2Str(this.GID);
|
||||||
|
}
|
||||||
|
|
||||||
public static string Gid2Str(GID gid)
|
public static string Gid2Str(GID gid)
|
||||||
{
|
{
|
||||||
switch (gid)
|
switch (gid)
|
||||||
|
|||||||
@ -87,7 +87,7 @@ namespace Users.Entities
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ((groupId >= 0) && (groupId < GID.NrOfGroups) && (Groups != null))
|
else if ((groupId >= 0) && (groupId < GID.NrOfGroups))
|
||||||
{
|
{
|
||||||
foreach (var g in Groups)
|
foreach (var g in Groups)
|
||||||
{
|
{
|
||||||
@ -113,7 +113,7 @@ namespace Users.Entities
|
|||||||
|
|
||||||
foreach (var gid in groupIds)
|
foreach (var gid in groupIds)
|
||||||
{
|
{
|
||||||
if (gid >= 0 && gid < GID.NrOfGroups)
|
if ((gid >= 0) && (gid < GID.NrOfGroups))
|
||||||
{
|
{
|
||||||
/// for all group elements in User.Groups
|
/// for all group elements in User.Groups
|
||||||
foreach (var grp in Groups)
|
foreach (var grp in Groups)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ namespace Users.Forms
|
|||||||
{
|
{
|
||||||
NHibernate.ISession session;
|
NHibernate.ISession session;
|
||||||
User user;
|
User user;
|
||||||
GID[] displayedGIDs;
|
IList<Group> displayedGroups;
|
||||||
|
|
||||||
|
|
||||||
bool[] oriGroupMember; /// index is gid, size is Grp.Count
|
bool[] oriGroupMember; /// index is gid, size is Grp.Count
|
||||||
@ -32,18 +32,18 @@ namespace Users.Forms
|
|||||||
{
|
{
|
||||||
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[(displayedGIDs != null) ? displayedGIDs.Length : 0];
|
oriGroupMember = new bool[(displayedGroups != null) ? displayedGroups.Count : 0];
|
||||||
okBtn.Enabled = false;
|
okBtn.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditSelectedUser(NHibernate.ISession session, User user, GID[] displayedGIDs)
|
public EditSelectedUser(NHibernate.ISession session, User user, IList<Group> displayedGroups)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.displayedGIDs = displayedGIDs;
|
this.displayedGroups = displayedGroups;
|
||||||
|
|
||||||
oriGroupMember = new bool[(displayedGIDs != null) ? displayedGIDs.Length : 0];
|
oriGroupMember = new bool[(displayedGroups != null) ? displayedGroups.Count : 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EditSelectedUser_Load(object sender, EventArgs e)
|
private void EditSelectedUser_Load(object sender, EventArgs e)
|
||||||
@ -124,12 +124,12 @@ namespace Users.Forms
|
|||||||
public void ShowGroups()
|
public void ShowGroups()
|
||||||
{
|
{
|
||||||
checkedListBoxGroups.Items.Clear();
|
checkedListBoxGroups.Items.Clear();
|
||||||
for (int i= 0; i < displayedGIDs.Length; i++)
|
for (int i= 0; i < displayedGroups.Count; i++)
|
||||||
{
|
{
|
||||||
GID gid = displayedGIDs[i];
|
Group group = displayedGroups[i];
|
||||||
|
|
||||||
bool boolIsMember = oriGroupMember[i] = user.IsMemberOf(gid);
|
bool boolIsMember = oriGroupMember[i] = user.IsMemberOf(group.GID);
|
||||||
checkedListBoxGroups.Items.Add(Group.Gid2Str(gid));
|
checkedListBoxGroups.Items.Add(group.Gid2Str());
|
||||||
checkedListBoxGroups.SetItemCheckState(i, boolIsMember ? CheckState.Checked : CheckState.Unchecked);
|
checkedListBoxGroups.SetItemCheckState(i, boolIsMember ? CheckState.Checked : CheckState.Unchecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,30 +189,22 @@ namespace Users.Forms
|
|||||||
user.LastPwChange = DateTime.MinValue;
|
user.LastPwChange = DateTime.MinValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
/// Groups
|
/// Groups
|
||||||
|
///
|
||||||
IList<Group> groups = user.Groups; /// = session.QueryOver<Group>().Where(x => (x.User.Id == user.Id)).List();
|
IList<Group> groups = user.Groups; /// = session.QueryOver<Group>().Where(x => (x.User.Id == user.Id)).List();
|
||||||
for (int i = 0; i < displayedGIDs.Length; i++ )
|
for (int i = 0; i < displayedGroups.Count; i++ )
|
||||||
{
|
{
|
||||||
GID gid = displayedGIDs[i];
|
Group group = displayedGroups[i];
|
||||||
bool newIsMember = checkedListBoxGroups.GetItemChecked(i);
|
bool newIsMember = checkedListBoxGroups.GetItemChecked(i);
|
||||||
|
|
||||||
if (!newIsMember && oriGroupMember[i])
|
if (!newIsMember && oriGroupMember[i])
|
||||||
{
|
{
|
||||||
for (int j = 0; j < user.Groups.Count; j++)
|
user.Groups.Remove(group);
|
||||||
{
|
|
||||||
Group grp = user.Groups[j];
|
|
||||||
if (grp.GID == gid)
|
|
||||||
{
|
|
||||||
session.Delete(user.Groups[j]);
|
|
||||||
user.Groups.RemoveAt(j);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (newIsMember && !oriGroupMember[i])
|
else if (newIsMember && !oriGroupMember[i])
|
||||||
{
|
{
|
||||||
Group newGroup = new Group(gid);
|
user.Groups.Add(group);
|
||||||
user.Groups.Add(newGroup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,39 +26,7 @@ namespace Users.Forms
|
|||||||
const int NameSurnameColumn = 2;
|
const int NameSurnameColumn = 2;
|
||||||
|
|
||||||
|
|
||||||
static GID[] DisplayedGIDs = new GID[]
|
IList<Group> displayedGroups;
|
||||||
{
|
|
||||||
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
|
|
||||||
GID.Testers,
|
|
||||||
GID.TestingSpecialists,
|
|
||||||
GID.HeadOfLab,
|
|
||||||
GID.MaintenanceSpecialists,
|
|
||||||
GID.Metrologists,
|
|
||||||
GID.CalibrationSpecialists,
|
|
||||||
GID.Administrators,
|
|
||||||
GID.TraceabilityManagement,
|
|
||||||
#elif KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_END
|
|
||||||
GID.Testers,
|
|
||||||
GID.TestingSpecialists,
|
|
||||||
GID.HeadOfLab,
|
|
||||||
GID.MaintenanceSpecialists,
|
|
||||||
GID.Metrologists,
|
|
||||||
GID.CalibrationSpecialists,
|
|
||||||
GID.Administrators,
|
|
||||||
GID.MetrologicalAuthority,
|
|
||||||
GID.WaterMeterAuthority,
|
|
||||||
#else
|
|
||||||
GID.Testers,
|
|
||||||
GID.TestingSpecialists,
|
|
||||||
GID.HeadOfLab,
|
|
||||||
GID.MaintenanceSpecialists,
|
|
||||||
GID.Metrologists,
|
|
||||||
GID.CalibrationSpecialists,
|
|
||||||
GID.Administrators,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public string TitleExtension;
|
public string TitleExtension;
|
||||||
|
|
||||||
|
|
||||||
@ -77,6 +45,17 @@ namespace Users.Forms
|
|||||||
this.session = session;
|
this.session = session;
|
||||||
this.showExtensions = showLocalExtensions;
|
this.showExtensions = showLocalExtensions;
|
||||||
if (showLocalExtensions) copyFromRemoteButton.Visible = true;
|
if (showLocalExtensions) copyFromRemoteButton.Visible = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
displayedGroups = session.QueryOver<Group>().List();
|
||||||
|
listOfUsers = session.QueryOver<User>().List();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (displayedGroups == null) displayedGroups = new List<Group>();
|
||||||
|
if (listOfUsers == null) listOfUsers = new List<User>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UserManagementDlg_Load(object sender, EventArgs e)
|
private void UserManagementDlg_Load(object sender, EventArgs e)
|
||||||
@ -97,47 +76,35 @@ namespace Users.Forms
|
|||||||
listViewUsers.Columns.Add(Strings.Tag, 110);
|
listViewUsers.Columns.Add(Strings.Tag, 110);
|
||||||
listViewUsers.Columns.Add(Strings.Groups, 370);
|
listViewUsers.Columns.Add(Strings.Groups, 370);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
listOfUsers = session.QueryOver<User>().List();
|
|
||||||
}
|
|
||||||
catch (Exception exc)
|
|
||||||
{
|
|
||||||
string msg = exc.Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
ListUsers();
|
ListUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ListUsers()
|
public void ListUsers()
|
||||||
{
|
{
|
||||||
Cursor.Current = Cursors.WaitCursor;
|
|
||||||
|
|
||||||
listViewUsers.Items.Clear();
|
listViewUsers.Items.Clear();
|
||||||
foreach (User u in listOfUsers)
|
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;
|
string grps = string.Empty;
|
||||||
///
|
foreach (var group in displayedGroups)
|
||||||
foreach (var gid in DisplayedGIDs)
|
|
||||||
{
|
{
|
||||||
if (u.IsMemberOf(gid))
|
if (u.IsMemberOf(group.GID))
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(grps)) grps += ", ";
|
if (!string.IsNullOrEmpty(grps)) grps += ", ";
|
||||||
grps += Group.Gid2Str(gid);
|
grps += group.Gid2Str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListViewItem item = new ListViewItem(u.UserName);
|
|
||||||
item.SubItems.Add(u.Number.ToString());
|
|
||||||
item.SubItems.Add(u.FullName);
|
|
||||||
item.SubItems.Add(string.IsNullOrEmpty(u.Tag) ? string.Empty : u.Tag);
|
|
||||||
item.SubItems.Add(grps);
|
item.SubItems.Add(grps);
|
||||||
item.Tag = u;
|
|
||||||
this.listViewUsers.Items.Add(item);
|
this.listViewUsers.Items.Add(item);
|
||||||
}
|
}
|
||||||
this.listViewUsers.Refresh();
|
this.listViewUsers.Refresh();
|
||||||
|
|
||||||
Cursor.Current = Cursors.Default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeButton_Click(object sender, EventArgs e)
|
private void closeButton_Click(object sender, EventArgs e)
|
||||||
@ -209,7 +176,7 @@ namespace Users.Forms
|
|||||||
{
|
{
|
||||||
if (listViewUsers.SelectedItems.Count == 1 && listViewUsers.SelectedItems[0].Tag is User)
|
if (listViewUsers.SelectedItems.Count == 1 && listViewUsers.SelectedItems[0].Tag is User)
|
||||||
{
|
{
|
||||||
new Forms.EditSelectedUser(session, (User)listViewUsers.SelectedItems[0].Tag, DisplayedGIDs).ShowDialog();
|
new Forms.EditSelectedUser(session, (User)listViewUsers.SelectedItems[0].Tag, displayedGroups).ShowDialog();
|
||||||
ListUsers();
|
ListUsers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +189,7 @@ namespace Users.Forms
|
|||||||
private void addButton_Click(object sender, EventArgs e)
|
private void addButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
User newUser = new User();
|
User newUser = new User();
|
||||||
if (new Forms.EditSelectedUser(session, newUser, DisplayedGIDs).ShowDialog() == DialogResult.OK)
|
if (new Forms.EditSelectedUser(session, newUser, displayedGroups).ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
listOfUsers.Add(newUser);
|
listOfUsers.Add(newUser);
|
||||||
}
|
}
|
||||||
@ -233,10 +200,10 @@ namespace Users.Forms
|
|||||||
{
|
{
|
||||||
if (listViewUsers.SelectedItems.Count == 1 && listViewUsers.SelectedItems[0].Tag is User)
|
if (listViewUsers.SelectedItems.Count == 1 && listViewUsers.SelectedItems[0].Tag is User)
|
||||||
{
|
{
|
||||||
User Selecteduser = listViewUsers.SelectedItems[0].Tag as User;
|
User selecteduser = session.Get<User>((listViewUsers.SelectedItems[0].Tag as User).Id);
|
||||||
session.Delete(Selecteduser);
|
session.Delete(selecteduser);
|
||||||
session.Flush();
|
session.Flush();
|
||||||
listOfUsers.Remove(Selecteduser);
|
listOfUsers.RemoveAt(listViewUsers.SelectedIndices[0]);
|
||||||
ListUsers();
|
ListUsers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using FluentNHibernate.Mapping;
|
using FluentNHibernate.Mapping;
|
||||||
|
|
||||||
@ -7,10 +7,18 @@ namespace Users.Mappings
|
|||||||
{
|
{
|
||||||
class GroupMap : ClassMap<Entities.Group>
|
class GroupMap : ClassMap<Entities.Group>
|
||||||
{
|
{
|
||||||
|
/// <seealso>
|
||||||
|
/// https://stackoverflow.com/questions/9108083/fluent-nhibernate-many-to-many-mapping-way/9125059
|
||||||
|
/// </seealso>
|
||||||
public GroupMap()
|
public GroupMap()
|
||||||
{
|
{
|
||||||
Id(x => x.Id);
|
Id(x => x.Id);
|
||||||
Map(x => x.GID).Column("Name"); ;
|
Map(x => x.GID).Column("Name");
|
||||||
|
Map(x => x.AccessFlags);
|
||||||
|
HasManyToMany(x => x.Users)
|
||||||
|
.Cascade.SaveUpdate()
|
||||||
|
.Inverse()
|
||||||
|
.Table("UsersGroups");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2016-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using FluentNHibernate.Mapping;
|
using FluentNHibernate.Mapping;
|
||||||
|
|
||||||
@ -19,8 +19,9 @@ namespace Users.Mappings
|
|||||||
Map(x => x.Password4);
|
Map(x => x.Password4);
|
||||||
Map(x => x.FullName).Column("Description");
|
Map(x => x.FullName).Column("Description");
|
||||||
Map(x => x.LastPwChange);
|
Map(x => x.LastPwChange);
|
||||||
HasMany(x => x.Groups)
|
HasManyToMany(x => x.Groups)
|
||||||
.Cascade.All();
|
.Cascade.SaveUpdate()
|
||||||
|
.Table("UsersGroups");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.24.1382.0")]
|
[assembly: AssemblyVersion("2.25.1400.0")]
|
||||||
[assembly: AssemblyFileVersion("2.24.1382.0")]
|
[assembly: AssemblyFileVersion("2.25.1400.0")]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user