diff --git a/EDMI_ClientSuite/ClassCommonCommands.vb b/EDMI_ClientSuite/ClassCommonCommands.vb index f8bd4096..8f5ce4cb 100644 --- a/EDMI_ClientSuite/ClassCommonCommands.vb +++ b/EDMI_ClientSuite/ClassCommonCommands.vb @@ -9,11 +9,10 @@ Public Class ClassCommonCommands _Logger = LogConfig.GetLogger() End Sub - Public Async Function FNICM_RADM_NEW_USER2GROUP(GroupId As Integer, UserId As Integer) As Task(Of Integer) + Public Async Function FNICM_RADM_NEW_USER2GROUP(UserId As Integer, GroupId As Integer) As Task(Of Integer) Try Dim oSQL = "SELECT FNICM_RADM_NEW_USER2GROUP({0},{1}, '{2}') FROM RDB$DATABASE;" Dim oRequest = Await My.Channel.CreateDatabaseRequestAsync($"Add User To Group", False) - Dim oRecordIds As New List(Of Integer) Dim oResult = Await My.Channel.ReturnScalarAsync(String.Format(oSQL, UserId, GroupId, Environment.UserName)) Await My.Channel.CloseDatabaseRequestAsync() @@ -29,12 +28,32 @@ Public Class ClassCommonCommands End Try End Function + Public Async Function FNICM_RADM_NEW_GROUP2GROUP(ParentGroupId As Integer, GroupId As Integer) As Task(Of Integer) + Try + Dim oSQL = "SELECT FNICM_RADM_NEW_GROUP2GROUP({0},{1}, '{2}') FROM RDB$DATABASE;" + Dim oRequest = Await My.Channel.CreateDatabaseRequestAsync($"Add Group To Group", False) + Dim oRecordIds As New List(Of Integer) + + Dim oResult = Await My.Channel.ReturnScalarAsync(String.Format(oSQL, GroupId, ParentGroupId, Environment.UserName)) + Await My.Channel.CloseDatabaseRequestAsync() + + If oResult.OK Then + Return oResult.Scalar + Else + Return Nothing + End If + Catch ex As Exception + _Logger.Error(ex) + Throw ex + End Try + End Function + Public Async Function FNICM_DELETE_RECORD_FINALLY(RecordId As Integer) As Task(Of Boolean) Try - Dim oSQL = "SELECT FNICM_DELETE_RECORD_FINALLY({0},'{1}') FROM RDB$DATABASE;" + Dim oSQL = $"SELECT FNICM_DELETE_RECORD_FINALLY({RecordId},'{Environment.UserName}') FROM RDB$DATABASE;" Dim oRequest = Await My.Channel.CreateDatabaseRequestAsync($"Delete Record", False) - Dim oResult = Await My.Channel.ReturnScalarAsync(String.Format(oSQL, RecordId, Environment.UserName)) + Dim oResult = Await My.Channel.ReturnScalarAsync(oSQL) Await My.Channel.CloseDatabaseRequestAsync() Return oResult.OK diff --git a/EDMI_ClientSuite/UserManager/UserControlAssignment.vb b/EDMI_ClientSuite/UserManager/UserControlAssignment.vb index 23d60722..8b89d235 100644 --- a/EDMI_ClientSuite/UserManager/UserControlAssignment.vb +++ b/EDMI_ClientSuite/UserManager/UserControlAssignment.vb @@ -159,7 +159,7 @@ Public Class UserControlAssignment For Each oChildId In oChildIds Dim oRelationRecordId = GetAssignmentRecord(_ParentRecordId, oChildId) - RaiseEvent ChildAdded(_ParentRecordId, oChildId, oRelationRecordId) + RaiseEvent ChildRemoved(_ParentRecordId, oChildId, oRelationRecordId) Next End Sub @@ -170,7 +170,7 @@ Public Class UserControlAssignment For Each oChildId In oChildIds Dim oRelationRecordId = GetAssignmentRecord(_ParentRecordId, oChildId) - RaiseEvent ChildRemoved(_ParentRecordId, oChildId, oRelationRecordId) + RaiseEvent ChildAdded(_ParentRecordId, oChildId, oRelationRecordId) Next End Sub @@ -186,7 +186,7 @@ Public Class UserControlAssignment Where oAssignedChildIds.Contains(oRow.Item(ClassConstants.ATTRIBUTE_ID_COLUMN)) Dim oNotAssignedChildren As EnumerableRowCollection(Of DataRow) = From oRow In _ChildList.AsEnumerable() - Where Not oAssignedChildIds.Contains(oRow.Item(ClassConstants.ATTRIBUTE_ID_COLUMN)) + Where Not oAssignedChildIds.Contains(oRow.Item(ClassConstants.ATTRIBUTE_ID_COLUMN)) And oRow.Item(ClassConstants.ATTRIBUTE_ID_COLUMN) <> _ParentRecordId GridAssignedToParent.DataSource = MaybeCopyToDataTable(oAssignedChildren) GridNotAssignedToParent.DataSource = MaybeCopyToDataTable(oNotAssignedChildren) diff --git a/EDMI_ClientSuite/UserManager/frmUserManager.vb b/EDMI_ClientSuite/UserManager/frmUserManager.vb index 67204187..dcf25353 100644 --- a/EDMI_ClientSuite/UserManager/frmUserManager.vb +++ b/EDMI_ClientSuite/UserManager/frmUserManager.vb @@ -14,10 +14,13 @@ Public Class frmUserManager End Sub Private Async Sub frmUserManager_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Await InitUserToGroupData() + Await InitData() - AddHandler UCUserToGroup.ChildRemoved, AddressOf HandleUserAssignedToGroup - AddHandler UCUserToGroup.ChildAdded, AddressOf HandleUserDismissedFromGroup + AddHandler UCUserToGroup.ChildAdded, AddressOf HandleUserAddedToGroup + AddHandler UCUserToGroup.ChildRemoved, AddressOf HandleUserRemovedFromGroup + + AddHandler UCGroupToGroup.ChildAdded, AddressOf HandleGroupAddedToGroup + AddHandler UCGroupToGroup.ChildRemoved, AddressOf HandleGroupRemovedFromGroup RibbonControl.SelectPage(RibbonPageUserManager) End Sub @@ -28,32 +31,48 @@ Public Class frmUserManager End If End Sub - Private Async Function InitUserToGroupData() As Task + Private Async Function InitData() As Task Dim oUserTable = Await GetAttributeListAsync("User") Dim oGroupTable = Await GetAttributeListAsync("Group") Dim oUserGroupTable = Await GetAttributeListAsync("User2Group") + Dim oGroupGroupTable = Await GetAttributeListAsync("Group2Group") UCUserToGroup.Init(oGroupTable, oUserTable, oUserGroupTable, "GROUP_ID", "USER_ID") + UCGroupToGroup.Init(oGroupTable, oGroupTable, oGroupGroupTable, "GROUP2_ID", "GROUP1_ID") End Function - Private Async Function UpdateUserToGroupData() As Task + Private Async Function UpdateData() As Task Dim oUserTable = Await GetAttributeListAsync("User") Dim oGroupTable = Await GetAttributeListAsync("Group") Dim oUserGroupTable = Await GetAttributeListAsync("User2Group") + Dim oGroupGroupTable = Await GetAttributeListAsync("Group2Group") UCUserToGroup.UpdateData(oGroupTable, oUserTable, oUserGroupTable) + UCGroupToGroup.UpdateData(oGroupTable, oGroupTable, oGroupGroupTable) End Function - Private Async Sub HandleUserAssignedToGroup(GroupId As Integer, UserId As Integer, RelationRecordId As Integer) - Dim oRecordId = Await _CommonCommands.FNICM_RADM_NEW_USER2GROUP(GroupId, UserId) + Private Async Sub HandleUserAddedToGroup(GroupId As Integer, UserId As Integer, RelationRecordId As Integer) + Dim oRecordId = Await _CommonCommands.FNICM_RADM_NEW_USER2GROUP(UserId, GroupId) - Await UpdateUserToGroupData() + Await UpdateData() End Sub - Private Async Sub HandleUserDismissedFromGroup(GroupId As Integer, UserId As Integer, RelationRecordId As Integer) + Private Async Sub HandleUserRemovedFromGroup(GroupId As Integer, UserId As Integer, RelationRecordId As Integer) Dim oResult = Await _CommonCommands.FNICM_DELETE_RECORD_FINALLY(RelationRecordId) - Await UpdateUserToGroupData() + Await UpdateData() + End Sub + + Private Async Sub HandleGroupAddedToGroup(ParentGroupId As Integer, GroupId As Integer, RelationRecordId As Integer) + Dim oRecordId = Await _CommonCommands.FNICM_RADM_NEW_GROUP2GROUP(GroupId, ParentGroupId) + + Await UpdateData() + End Sub + + Private Async Sub HandleGroupRemovedFromGroup(ParentGroupId As Integer, GroupId As Integer, RelationRecordId As Integer) + Dim oResult = Await _CommonCommands.FNICM_DELETE_RECORD_FINALLY(RelationRecordId) + + Await UpdateData() End Sub Private Async Function GetAttributeListAsync(AttributeName As String) As Task(Of DataTable) @@ -85,7 +104,7 @@ Public Class frmUserManager End Sub Private Async Sub BarButtonRefresh_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonRefresh.ItemClick - Await UpdateUserToGroupData() + Await UpdateData() End Sub Private Sub OfficeNavigationBar1_SelectedItemChanged(sender As Object, e As DevExpress.XtraBars.Navigation.NavigationBarItemEventArgs) Handles OfficeNavigationBar1.SelectedItemChanged diff --git a/EDMI_ClientSuite/frmConfigService.vb b/EDMI_ClientSuite/frmConfigService.vb index 918ffad5..b7166cd5 100644 --- a/EDMI_ClientSuite/frmConfigService.vb +++ b/EDMI_ClientSuite/frmConfigService.vb @@ -1,5 +1,4 @@ -Imports DigitalData.GUIs.ClientSuite.ClassUIUtils -Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Logging Public Class frmConfigService Private _Logger As Logger