ZooFlow: IDB Admin

This commit is contained in:
Jonathan Jenne
2021-03-08 15:34:57 +01:00
parent 526c9c349a
commit 6b814b9089
24 changed files with 835 additions and 2519 deletions

View File

@@ -1,11 +1,8 @@
Imports DevExpress.Utils
Imports System.ComponentModel
Imports DevExpress.Utils
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraTab
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.Nodes
Imports DigitalData.Modules.Logging
Public Class frmAdmin_Start
@@ -13,7 +10,7 @@ Public Class frmAdmin_Start
Private Const IDB_START = "IDB_START"
Private Const IDB_ATTRIBUTES = "IDB_ATTRIBUTES"
Private Const IDB_BUSINESS_ENTITY = "IDB_BUSINESS_ENTITY"
Private Const IDB_BUSINESS_ENTITIES = "IDB_BUSINESS_ENTITIES"
Private Const IDB_SOURCE_SQL = "IDB_SOURCE_SQL"
Private Const GLOBIX_PROFILES = "GLOBIX_PROFILES"
Private Const CW_PROFILES = "CW_PROFILES"
@@ -22,6 +19,21 @@ Public Class frmAdmin_Start
Private AdminItems As New List(Of AdminItem)
Private CurrentPage As String
Private Function IsIDBAttribute(Item As AdminItem) As Boolean
Return Item.Entity = "IDB" And Item.Scope = "ATTRIBUTE"
End Function
Private Function IsIDBEntity(Item As AdminItem) As Boolean
Return Item.Entity = "IDB" And Item.Scope = "ENTITY"
End Function
Private Function IsCWItem(Item As AdminItem) As Boolean
Return Item.Entity = "CW"
End Function
Private Function IsGLOBIXItem(Item As AdminItem) As Boolean
Return Item.Entity = "GLOBIX"
End Function
Private Class AdminItem
Public Property Guid As Integer
@@ -30,6 +42,19 @@ Public Class frmAdmin_Start
Public Property Entity As String
Public Property Scope As String
Public Property Summary As String
''' <summary>
''' The GUID coming from the Database starts with a 3-char long identifier that needs to be removed
''' </summary>
Public ReadOnly Property RealGuid As Integer
Get
Return Guid.ToString.Substring(3)
End Get
End Property
Public Overrides Function ToString() As String
Return $"{Title} ({Guid})"
End Function
End Class
Private Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -37,6 +62,11 @@ Public Class frmAdmin_Start
TreeListMenu.ExpandAll()
AddHandler TreeListIDBAttributes.DoubleClick, AddressOf TreeList_DoubleClick
AddHandler TreeListIDBEntities.DoubleClick, AddressOf TreeList_DoubleClick
AddHandler TreeListCWProfiles.DoubleClick, AddressOf TreeList_DoubleClick
AddHandler TreeListGLOBIXProfiles.DoubleClick, AddressOf TreeList_DoubleClick
' Show Tab Header in Development, hide when running the app
XtraTabControl.ShowTabHeader = DefaultBoolean.False
End Sub
@@ -48,8 +78,8 @@ Public Class frmAdmin_Start
For Each oRow As DataRow In oTable.Rows
Dim oItem As New AdminItem With {
.Guid = oRow.Item("GUID"),
.ParentId = oRow.Item("PARENT"),
.Guid = CInt(oRow.Item("GUID")),
.ParentId = CInt(oRow.Item("PARENT")),
.Entity = oRow.Item("ENTITY").ToString,
.Scope = oRow.Item("ENTITY_SCOPE").ToString,
.Title = oRow.Item("NODE_TITLE").ToString,
@@ -98,6 +128,7 @@ Public Class frmAdmin_Start
Private Sub TreeList1_FocusedNodeChanged(sender As Object, e As DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) Handles TreeListMenu.FocusedNodeChanged
Try
If e.Node Is Nothing OrElse e.Node.Tag Is Nothing Then
labelTitle.Text = "Start"
Exit Sub
End If
@@ -105,171 +136,138 @@ Public Class frmAdmin_Start
Select Case e.Node.Tag.ToString
Case IDB_START
labelTitle.Text = "IDB Übersicht"
Display_Tab(XtraTabPage_IDB)
Case IDB_ATTRIBUTES
labelTitle.Text = "IDB Attribute"
Display_Tab(XtraTabPage_IDB)
Display_Tab(XtraTabPageIDB_Attributes_New)
'Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
'Load_Grid(oTable, oSource, GridAttributes)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBAttribute).ToList()
Load_Tree(oItems, TreeListIDBAttributes)
Case IDB_BUSINESS_ENTITY
'DisplayTab(XtraTabPage_Entities)
Case IDB_BUSINESS_ENTITIES
labelTitle.Text = "IDB Entitäten"
Display_Tab(XtraTabPage_IDB)
Display_Tab(XtraTabPageIDB_Entities)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBEntity).ToList()
Load_Tree(oItems, TreeListIDBEntities)
Case GLOBIX_PROFILES
labelTitle.Text = "Global Indexer Profile"
Display_Tab(XtraTabPage_GlobalIndexer)
Display_RibbonPage(RibbonPage_GlobalIndexer)
Dim oCWItems As List(Of AdminItem) = (From Item As AdminItem In AdminItems
Where Item.Entity = "GLOBIX"
Select Item).ToList()
Load_Tree(oCWItems, TreeList2)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsGLOBIXItem).ToList()
Load_Tree(oItems, TreeListGLOBIXProfiles)
Case CW_PROFILES
labelTitle.Text = "Clipboard Watcher Profile"
Display_Tab(XtraTabPage_ClipboardWatcher)
Display_Tab(XtraTabPageCWProfiles)
Display_RibbonPage(RibbonPage_ClipboardWatcher)
Dim oCWItems As List(Of AdminItem) = (From Item As AdminItem In AdminItems
Where Item.Entity = "CW"
Select Item).ToList()
Load_Tree(oCWItems, TreeList1)
Case IDB_SOURCE_SQL
Display_Tab(XtraTabPage_IDB)
Display_Tab(XtraTabPageIDB_SourceSQL)
'Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
'Load_Grid(oTable, oSource, GridSourceSQL)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsCWItem).ToList()
Load_Tree(oItems, TreeListCWProfiles)
End Select
Catch ex As Exception
ShowError(ex)
End Try
End Sub
'Private Sub Load_Children(Source As AdminItem, DataSet As DataSet, DataTable As DataTable)
' Dim oChildren = AdminItems.Where(Function(cmd) cmd.Value.ParentId = Source.Guid).ToList()
' If oChildren.Count > 0 Then
' For Each oChild In oChildren
' Dim oChildSource As AdminItem = oChild.Value
' Dim oChildTable As DataTable = My.Database.GetDatatable(oChildSource.Title)
' oChildTable.TableName = oChildSource.Title
' Dim oRelationName As String = $"{Source.Title}__{oChildSource.Title}"
' DataSet.Tables.Add(oChildTable)
' DataSet.Relations.Add(New DataRelation(oRelationName,
' DataTable.Columns.Item(Source.Entity),
' oChildTable.Columns.Item(oChildSource.Scope)))
' Load_Children(oChildSource, DataSet, oChildTable)
' Next
' End If
'End Sub
Private Sub Load_Tree(Source As List(Of AdminItem), TreeList As TreeList)
Dim oColumns As New List(Of Columns.TreeListColumn) From {
New Columns.TreeListColumn() With {
.Name = "columnTitle",
.Caption = "Titel",
.FieldName = "Title",
.Visible = True,
.VisibleIndex = 0
},
New Columns.TreeListColumn() With {
.Name = "columnScope",
.Caption = "Typ",
.FieldName = "Scope",
.Visible = True,
.VisibleIndex = 1
},
New Columns.TreeListColumn() With {
.Name = "columnSummary",
.Caption = "Beschreibung",
.FieldName = "Summary",
.Visible = True,
.VisibleIndex = 2
}
}
TreeList.Columns.Clear()
TreeList.Columns.AddRange(oColumns.ToArray)
TreeList.HierarchyFieldName = "Title"
TreeList.KeyFieldName = "Guid"
TreeList.ParentFieldName = "ParentId"
'TreeList.PreviewFieldName = "Summary"
'TreeList.PreviewLineCount = 3
'TreeList.OptionsView.ShowPreview = True
TreeList.DataSource = Source
TreeList.ForceInitialize()
With TreeList.Appearance.EvenRow
.BackColor = Color.Snow
.Options.UseBackColor = True
End With
With TreeList.Appearance.FocusedCell
.BackColor = Color.Gold
.Options.UseBackColor = True
End With
With TreeList.OptionsBehavior
.Editable = False
.ReadOnly = True
End With
With TreeList.OptionsView
.ShowAutoFilterRow = True
.EnableAppearanceEvenRow = True
.ShowIndicator = False
End With
With TreeList.OptionsClipboard
.CopyColumnHeaders = DefaultBoolean.False
End With
With TreeList.OptionsFind
.AlwaysVisible = True
End With
AddHandler TreeList.KeyDown, Sub(sender As Object, e As KeyEventArgs)
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
If e.Control AndAlso e.KeyCode = Keys.C And e.Modifiers = Keys.Control Then
Dim oCellValue = oTreeList.GetRowCellValue(oTreeList.FocusedNode, oTreeList.FocusedColumn)
If oCellValue IsNot Nothing AndAlso oCellValue.ToString() <> String.Empty Then
Clipboard.SetText(oCellValue.ToString)
End If
e.Handled = True
End If
End Sub
TreeList.BestFitColumns()
End Sub
Private Sub Load_Grid(DataSource As DataTable, Source As AdminItem, GridControl As GridControl)
Try
PrimaryKey = Source.Entity
Dim oDataSet As New DataSet()
DataSource.TableName = Source.Title
oDataSet.Tables.Add(DataSource)
'Load_Children(Source, oDataSet, DataSource)
'GridControl.DataSource = oDataSet.Tables.Item(Source.Title)
'GridControl.ForceInitialize()
'Dim oGridView = DirectCast(GridControl.DefaultView, GridView)
'With oGridView.Appearance.EvenRow
' .BackColor = Color.Gainsboro
' .Options.UseBackColor = True
'End With
'With oGridView.Appearance.FocusedCell
' .BackColor = Color.Gold
' .Options.UseBackColor = True
'End With
'With oGridView.Appearance.FocusedRow
' .BackColor = Color.Gold
' .Options.UseBackColor = True
'End With
'With oGridView.OptionsBehavior
' .Editable = False
' .ReadOnly = True
'End With
'With oGridView.OptionsClipboard
' .CopyColumnHeaders = DefaultBoolean.False
'End With
'With oGridView.OptionsFind
' .AlwaysVisible = True
'End With
'With oGridView.OptionsView
' .ShowAutoFilterRow = True
' .EnableAppearanceEvenRow = True
' .ShowIndicator = False
'End With
'AddHandler oGridView.KeyDown, Sub(sender As Object, e As KeyEventArgs)
' Dim oView As GridView = DirectCast(sender, GridView)
' If e.Control AndAlso e.KeyCode = Keys.C And e.Modifiers = Keys.Control Then
' Dim oCellValue = oView.GetRowCellValue(oView.FocusedRowHandle, oView.FocusedColumn)
' If oCellValue IsNot Nothing AndAlso oCellValue.ToString() <> String.Empty Then
' Clipboard.SetText(oCellValue.ToString)
' End If
' e.Handled = True
' End If
' End Sub
'oGridView.BestFitColumns()
Catch ex As Exception
ShowError(ex)
End Try
End Sub
Private Sub View_DoubleClick(sender As Object, e As EventArgs) Handles _
ViewAttributes.DoubleClick, ViewSourceSQL.DoubleClick
Dim oView As GridView = TryCast(sender, GridView)
Dim hitInfo As GridHitInfo = oView.CalcHitInfo(TryCast(e, DXMouseEventArgs).Location)
If hitInfo.InDataRow Then
Private Sub TreeList_DoubleClick(sender As Object, e As EventArgs)
Dim oView As TreeList = TryCast(sender, TreeList)
Dim hitInfo As TreeListHitInfo = oView.CalcHitInfo(TryCast(e, DXMouseEventArgs).Location)
If hitInfo.InRow Then
Try
Dim oRow As DataRow = oView.GetFocusedDataRow
If oRow IsNot Nothing Then
Dim oPrimaryKey As Integer = oRow.Item(PrimaryKey)
Dim oItem As AdminItem = oView.GetFocusedRow
If oItem IsNot Nothing Then
Select Case oView.Name
Case ViewAttributes.Name
Load_Attribute(oPrimaryKey)
Case ViewSourceSQL.Name
Load_SourceSql(oPrimaryKey)
Case WinExplorerView1.Name
Load_CWProfile(oPrimaryKey)
Case TreeListIDBAttributes.Name
Load_IDBAttribute(oItem.RealGuid)
Case TreeListIDBEntities.Name
Load_IDBEntity(oItem.RealGuid)
End Select
End If
Catch ex As Exception
ShowError(ex)
@@ -277,30 +275,30 @@ Public Class frmAdmin_Start
End If
End Sub
Private Sub Load_Attribute(PrimaryKey As Integer)
Private Sub Load_IDBAttribute(PrimaryKey As Integer)
Try
Dim oForm As New frmAdmin_IDBAttribute(PrimaryKey)
oForm.ShowDialog()
If oForm.HasChanges Then
Dim oSource As AdminItem = AdminItems.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
Load_Grid(oTable, oSource, GridAttributes)
Load_SQLData()
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBAttribute).ToList
Load_Tree(oItems, TreeListIDBAttributes)
End If
Catch ex As Exception
ShowError(ex)
End Try
End Sub
Private Sub Load_SourceSql(PrimaryKey As Integer)
Private Sub Load_IDBEntity(PrimaryKey As Integer)
Try
Dim oForm As New frmAdmin_SourceSQL(PrimaryKey)
Dim oForm As New frmAdmin_IDBEntity(PrimaryKey)
oForm.ShowDialog()
If oForm.HasChanges Then
Dim oSource As AdminItem = AdminItems.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
Load_Grid(oTable, oSource, GridSourceSQL)
Load_SQLData()
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBEntity).ToList
Load_Tree(oItems, TreeListIDBEntities)
End If
Catch ex As Exception
ShowError(ex)
@@ -313,6 +311,7 @@ Public Class frmAdmin_Start
oForm.ShowDialog()
If oForm.HasChanges Then
Dim oSource As AdminItem = AdminItems.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
'Load_Tree(oTable, oSource, TreeList1)
@@ -324,10 +323,10 @@ Public Class frmAdmin_Start
Private Sub BarButtonItem7_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick
Try
Dim oRow As DataRow = ViewAttributes.GetFocusedDataRow
Dim oRow As DataRow = TreeListIDBAttributes.GetFocusedDataRow
If oRow IsNot Nothing Then
Dim oPrimaryKey As Integer = oRow.Item(PrimaryKey)
Load_Attribute(oPrimaryKey)
Dim oPrimaryKey As Integer = DirectCast(oRow.Item(PrimaryKey), Integer)
Load_IDBAttribute(oPrimaryKey)
End If
Catch ex As Exception
ShowError(ex)
@@ -348,9 +347,11 @@ Public Class frmAdmin_Start
labelStatus.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End Sub
Private Sub TreeList1_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeList1.GetStateImage
Private Sub TreeList1_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeListCWProfiles.GetStateImage
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
Dim oItem As AdminItem = oTreeList.GetRow(e.Node.Id)
Dim oItem As AdminItem = DirectCast(oTreeList.GetRow(e.Node.Id), AdminItem)
Select Case oItem.Scope
Case "PROFILE"
@@ -368,9 +369,9 @@ Public Class frmAdmin_Start
End Sub
Private Sub TreeList2_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeList2.GetStateImage
Private Sub TreeList2_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeListGLOBIXProfiles.GetStateImage
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
Dim oItem As AdminItem = oTreeList.GetRow(e.Node.Id)
Dim oItem As AdminItem = DirectCast(oTreeList.GetRow(e.Node.Id), AdminItem)
Select Case oItem.Scope
Case "PROFILE"
@@ -385,4 +386,12 @@ Public Class frmAdmin_Start
End Select
End Sub
Private Sub TreeListIDBAttributes_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeListIDBAttributes.GetStateImage
e.NodeImageIndex = 1
End Sub
Private Sub TreeListIDBEntities_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeListIDBEntities.GetStateImage
e.NodeImageIndex = 0
End Sub
End Class