Add Group To Group Assignment
This commit is contained in:
parent
bad7cea8d6
commit
e9c08de50d
@ -9,11 +9,10 @@ Public Class ClassCommonCommands
|
|||||||
_Logger = LogConfig.GetLogger()
|
_Logger = LogConfig.GetLogger()
|
||||||
End Sub
|
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
|
Try
|
||||||
Dim oSQL = "SELECT FNICM_RADM_NEW_USER2GROUP({0},{1}, '{2}') FROM RDB$DATABASE;"
|
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 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))
|
Dim oResult = Await My.Channel.ReturnScalarAsync(String.Format(oSQL, UserId, GroupId, Environment.UserName))
|
||||||
Await My.Channel.CloseDatabaseRequestAsync()
|
Await My.Channel.CloseDatabaseRequestAsync()
|
||||||
@ -29,12 +28,32 @@ Public Class ClassCommonCommands
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
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)
|
Public Async Function FNICM_DELETE_RECORD_FINALLY(RecordId As Integer) As Task(Of Boolean)
|
||||||
Try
|
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 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()
|
Await My.Channel.CloseDatabaseRequestAsync()
|
||||||
|
|
||||||
Return oResult.OK
|
Return oResult.OK
|
||||||
|
|||||||
@ -159,7 +159,7 @@ Public Class UserControlAssignment
|
|||||||
For Each oChildId In oChildIds
|
For Each oChildId In oChildIds
|
||||||
Dim oRelationRecordId = GetAssignmentRecord(_ParentRecordId, oChildId)
|
Dim oRelationRecordId = GetAssignmentRecord(_ParentRecordId, oChildId)
|
||||||
|
|
||||||
RaiseEvent ChildAdded(_ParentRecordId, oChildId, oRelationRecordId)
|
RaiseEvent ChildRemoved(_ParentRecordId, oChildId, oRelationRecordId)
|
||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ Public Class UserControlAssignment
|
|||||||
For Each oChildId In oChildIds
|
For Each oChildId In oChildIds
|
||||||
Dim oRelationRecordId = GetAssignmentRecord(_ParentRecordId, oChildId)
|
Dim oRelationRecordId = GetAssignmentRecord(_ParentRecordId, oChildId)
|
||||||
|
|
||||||
RaiseEvent ChildRemoved(_ParentRecordId, oChildId, oRelationRecordId)
|
RaiseEvent ChildAdded(_ParentRecordId, oChildId, oRelationRecordId)
|
||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ Public Class UserControlAssignment
|
|||||||
Where oAssignedChildIds.Contains(oRow.Item(ClassConstants.ATTRIBUTE_ID_COLUMN))
|
Where oAssignedChildIds.Contains(oRow.Item(ClassConstants.ATTRIBUTE_ID_COLUMN))
|
||||||
|
|
||||||
Dim oNotAssignedChildren As EnumerableRowCollection(Of DataRow) = From oRow In _ChildList.AsEnumerable()
|
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)
|
GridAssignedToParent.DataSource = MaybeCopyToDataTable(oAssignedChildren)
|
||||||
GridNotAssignedToParent.DataSource = MaybeCopyToDataTable(oNotAssignedChildren)
|
GridNotAssignedToParent.DataSource = MaybeCopyToDataTable(oNotAssignedChildren)
|
||||||
|
|||||||
@ -14,10 +14,13 @@ Public Class frmUserManager
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Async Sub frmUserManager_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
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 HandleUserAddedToGroup
|
||||||
AddHandler UCUserToGroup.ChildAdded, AddressOf HandleUserDismissedFromGroup
|
AddHandler UCUserToGroup.ChildRemoved, AddressOf HandleUserRemovedFromGroup
|
||||||
|
|
||||||
|
AddHandler UCGroupToGroup.ChildAdded, AddressOf HandleGroupAddedToGroup
|
||||||
|
AddHandler UCGroupToGroup.ChildRemoved, AddressOf HandleGroupRemovedFromGroup
|
||||||
|
|
||||||
RibbonControl.SelectPage(RibbonPageUserManager)
|
RibbonControl.SelectPage(RibbonPageUserManager)
|
||||||
End Sub
|
End Sub
|
||||||
@ -28,32 +31,48 @@ Public Class frmUserManager
|
|||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Async Function InitUserToGroupData() As Task
|
Private Async Function InitData() As Task
|
||||||
Dim oUserTable = Await GetAttributeListAsync("User")
|
Dim oUserTable = Await GetAttributeListAsync("User")
|
||||||
Dim oGroupTable = Await GetAttributeListAsync("Group")
|
Dim oGroupTable = Await GetAttributeListAsync("Group")
|
||||||
Dim oUserGroupTable = Await GetAttributeListAsync("User2Group")
|
Dim oUserGroupTable = Await GetAttributeListAsync("User2Group")
|
||||||
|
Dim oGroupGroupTable = Await GetAttributeListAsync("Group2Group")
|
||||||
|
|
||||||
UCUserToGroup.Init(oGroupTable, oUserTable, oUserGroupTable, "GROUP_ID", "USER_ID")
|
UCUserToGroup.Init(oGroupTable, oUserTable, oUserGroupTable, "GROUP_ID", "USER_ID")
|
||||||
|
UCGroupToGroup.Init(oGroupTable, oGroupTable, oGroupGroupTable, "GROUP2_ID", "GROUP1_ID")
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Async Function UpdateUserToGroupData() As Task
|
Private Async Function UpdateData() As Task
|
||||||
Dim oUserTable = Await GetAttributeListAsync("User")
|
Dim oUserTable = Await GetAttributeListAsync("User")
|
||||||
Dim oGroupTable = Await GetAttributeListAsync("Group")
|
Dim oGroupTable = Await GetAttributeListAsync("Group")
|
||||||
Dim oUserGroupTable = Await GetAttributeListAsync("User2Group")
|
Dim oUserGroupTable = Await GetAttributeListAsync("User2Group")
|
||||||
|
Dim oGroupGroupTable = Await GetAttributeListAsync("Group2Group")
|
||||||
|
|
||||||
UCUserToGroup.UpdateData(oGroupTable, oUserTable, oUserGroupTable)
|
UCUserToGroup.UpdateData(oGroupTable, oUserTable, oUserGroupTable)
|
||||||
|
UCGroupToGroup.UpdateData(oGroupTable, oGroupTable, oGroupGroupTable)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Async Sub HandleUserAssignedToGroup(GroupId As Integer, UserId As Integer, RelationRecordId As Integer)
|
Private Async Sub HandleUserAddedToGroup(GroupId As Integer, UserId As Integer, RelationRecordId As Integer)
|
||||||
Dim oRecordId = Await _CommonCommands.FNICM_RADM_NEW_USER2GROUP(GroupId, UserId)
|
Dim oRecordId = Await _CommonCommands.FNICM_RADM_NEW_USER2GROUP(UserId, GroupId)
|
||||||
|
|
||||||
Await UpdateUserToGroupData()
|
Await UpdateData()
|
||||||
End Sub
|
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)
|
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
|
End Sub
|
||||||
|
|
||||||
Private Async Function GetAttributeListAsync(AttributeName As String) As Task(Of DataTable)
|
Private Async Function GetAttributeListAsync(AttributeName As String) As Task(Of DataTable)
|
||||||
@ -85,7 +104,7 @@ Public Class frmUserManager
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Async Sub BarButtonRefresh_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonRefresh.ItemClick
|
Private Async Sub BarButtonRefresh_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonRefresh.ItemClick
|
||||||
Await UpdateUserToGroupData()
|
Await UpdateData()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub OfficeNavigationBar1_SelectedItemChanged(sender As Object, e As DevExpress.XtraBars.Navigation.NavigationBarItemEventArgs) Handles OfficeNavigationBar1.SelectedItemChanged
|
Private Sub OfficeNavigationBar1_SelectedItemChanged(sender As Object, e As DevExpress.XtraBars.Navigation.NavigationBarItemEventArgs) Handles OfficeNavigationBar1.SelectedItemChanged
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
Imports DigitalData.GUIs.ClientSuite.ClassUIUtils
|
Imports DigitalData.Modules.Logging
|
||||||
Imports DigitalData.Modules.Logging
|
|
||||||
|
|
||||||
Public Class frmConfigService
|
Public Class frmConfigService
|
||||||
Private _Logger As Logger
|
Private _Logger As Logger
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user