ZooFlow: WIP Administration

This commit is contained in:
Jonathan Jenne
2021-02-24 16:41:43 +01:00
parent 905333640b
commit d4c4a4412a
3 changed files with 403 additions and 160 deletions

View File

@@ -1,10 +1,11 @@
Imports DevExpress.Utils
Imports DevExpress.XtraBars.Docking2010.Views
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
@@ -18,14 +19,17 @@ Public Class frmAdmin_Start
Private Const CW_PROFILES = "CW_PROFILES"
Private PrimaryKey As String = Nothing
Private SourceCommands As New Dictionary(Of String, SourceSql)
Private AdminItems As New List(Of AdminItem)
Private CurrentPage As String
Private Class SourceSql
Public Title As String
Public SQL As String
Public PrimaryKey As String
Private Class AdminItem
Public Property Guid As Integer
Public Property ParentId As Integer
Public Property Title As String
Public Property Entity As String
Public Property Scope As String
Public Property Summary As String
End Class
Private Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -39,17 +43,20 @@ Public Class frmAdmin_Start
Private Function Load_SQLData() As Boolean
Try
Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM TBZF_ADMIN_SOURCE_SQL")
SourceCommands.Clear()
Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM VWIDB_ADMINISTRATION_TREEVIEW")
AdminItems.Clear()
For Each oRow As DataRow In oTable.Rows
Dim oSource As New SourceSql With {
.PrimaryKey = oRow.Item("PK_COLUMN").ToString,
.SQL = oRow.Item("SQL_COMMAND").ToString,
.Title = oRow.Item("ENTITY_TITLE").ToString
Dim oItem As New AdminItem With {
.Guid = oRow.Item("GUID"),
.ParentId = oRow.Item("PARENT"),
.Entity = oRow.Item("ENTITY").ToString,
.Scope = oRow.Item("ENTITY_SCOPE").ToString,
.Title = oRow.Item("NODE_TITLE").ToString,
.Summary = oRow.Item("SUMMARY").ToString
}
SourceCommands.Add(oRow.Item("ENTITY_TITLE").ToString, oSource)
AdminItems.Add(oItem)
Next
Return True
Catch ex As Exception
@@ -96,11 +103,6 @@ Public Class frmAdmin_Start
CurrentPage = e.Node.Tag.ToString
Dim oSource As SourceSql
If SourceCommands.ContainsKey(CurrentPage) Then
oSource = SourceCommands.Item(CurrentPage)
End If
Select Case e.Node.Tag.ToString
Case IDB_START
Display_Tab(XtraTabPage_IDB)
@@ -109,8 +111,8 @@ Public Class frmAdmin_Start
Display_Tab(XtraTabPage_IDB)
Display_Tab(XtraTabPageIDB_Attributes_New)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL)
Load_Grid(oTable, oSource.PrimaryKey, GridAttributes)
'Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
'Load_Grid(oTable, oSource, GridAttributes)
Case IDB_BUSINESS_ENTITY
'DisplayTab(XtraTabPage_Entities)
@@ -119,20 +121,27 @@ Public Class frmAdmin_Start
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)
Case CW_PROFILES
Display_Tab(XtraTabPage_ClipboardWatcher)
Display_Tab(XtraTabPageCWProfiles)
Display_RibbonPage(RibbonPage_ClipboardWatcher)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL)
Load_Grid(oTable, oSource.PrimaryKey, GridCWProfiles)
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.SQL)
Load_Grid(oTable, oSource.PrimaryKey, GridSourceSQL)
'Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
'Load_Grid(oTable, oSource, GridSourceSQL)
End Select
Catch ex As Exception
@@ -141,61 +150,98 @@ Public Class frmAdmin_Start
End Sub
Private Sub Load_Grid(DataSource As DataTable, PrimaryKey As String, GridControl As GridControl)
'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)
TreeList.HierarchyFieldName = "Title"
TreeList.KeyFieldName = "Guid"
TreeList.ParentFieldName = "ParentId"
'TreeList.PreviewFieldName = "Summary"
'TreeList.PreviewLineCount = 3
'TreeList.OptionsView.ShowPreview = True
TreeList.DataSource = Source
TreeList.ForceInitialize()
End Sub
Private Sub Load_Grid(DataSource As DataTable, Source As AdminItem, GridControl As GridControl)
Try
Me.PrimaryKey = PrimaryKey
PrimaryKey = Source.Entity
GridControl.DataSource = DataSource
GridControl.ForceInitialize()
Dim oDataSet As New DataSet()
DataSource.TableName = Source.Title
oDataSet.Tables.Add(DataSource)
Dim oGridView = DirectCast(GridControl.DefaultView, GridView)
'Load_Children(Source, oDataSet, DataSource)
With oGridView.Appearance.EvenRow
.BackColor = Color.Gainsboro
.Options.UseBackColor = True
End With
'GridControl.DataSource = oDataSet.Tables.Item(Source.Title)
'GridControl.ForceInitialize()
With oGridView.Appearance.FocusedCell
.BackColor = Color.Gold
.Options.UseBackColor = True
End With
'Dim oGridView = DirectCast(GridControl.DefaultView, GridView)
With oGridView.Appearance.FocusedRow
.BackColor = Color.Gold
.Options.UseBackColor = True
End With
'With oGridView.Appearance.EvenRow
' .BackColor = Color.Gainsboro
' .Options.UseBackColor = True
'End With
With oGridView.OptionsBehavior
.Editable = False
.ReadOnly = True
End With
'With oGridView.Appearance.FocusedCell
' .BackColor = Color.Gold
' .Options.UseBackColor = True
'End With
With oGridView.OptionsClipboard
.CopyColumnHeaders = DefaultBoolean.False
End With
'With oGridView.Appearance.FocusedRow
' .BackColor = Color.Gold
' .Options.UseBackColor = True
'End With
With oGridView.OptionsFind
.AlwaysVisible = True
End With
'With oGridView.OptionsBehavior
' .Editable = False
' .ReadOnly = True
'End With
With oGridView.OptionsView
.ShowAutoFilterRow = True
.EnableAppearanceEvenRow = True
.ShowIndicator = False
End With
'With oGridView.OptionsClipboard
' .CopyColumnHeaders = DefaultBoolean.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
'With oGridView.OptionsFind
' .AlwaysVisible = True
'End With
oGridView.BestFitColumns()
'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)
@@ -203,7 +249,7 @@ Public Class frmAdmin_Start
End Sub
Private Sub View_DoubleClick(sender As Object, e As EventArgs) Handles _
ViewAttributes.DoubleClick, ViewSourceSQL.DoubleClick, ViewCWProfiles.DoubleClick
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
@@ -219,7 +265,7 @@ Public Class frmAdmin_Start
Case ViewSourceSQL.Name
Load_SourceSql(oPrimaryKey)
Case ViewCWProfiles.Name
Case WinExplorerView1.Name
Load_CWProfile(oPrimaryKey)
End Select
@@ -237,9 +283,9 @@ Public Class frmAdmin_Start
oForm.ShowDialog()
If oForm.HasChanges Then
Dim oSource As SourceSql = SourceCommands.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL)
Load_Grid(oTable, oSource.PrimaryKey, GridAttributes)
Dim oSource As AdminItem = AdminItems.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
Load_Grid(oTable, oSource, GridAttributes)
End If
Catch ex As Exception
ShowError(ex)
@@ -252,9 +298,9 @@ Public Class frmAdmin_Start
oForm.ShowDialog()
If oForm.HasChanges Then
Dim oSource As SourceSql = SourceCommands.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL)
Load_Grid(oTable, oSource.PrimaryKey, GridSourceSQL)
Dim oSource As AdminItem = AdminItems.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
Load_Grid(oTable, oSource, GridSourceSQL)
End If
Catch ex As Exception
ShowError(ex)
@@ -267,9 +313,9 @@ Public Class frmAdmin_Start
oForm.ShowDialog()
If oForm.HasChanges Then
Dim oSource As SourceSql = SourceCommands.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL)
Load_Grid(oTable, oSource.PrimaryKey, GridCWProfiles)
Dim oSource As AdminItem = AdminItems.Item(CurrentPage)
Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
'Load_Tree(oTable, oSource, TreeList1)
End If
Catch ex As Exception
ShowError(ex)
@@ -301,4 +347,42 @@ Public Class frmAdmin_Start
Private Sub ResetStatus()
labelStatus.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End Sub
Private Sub TreeList1_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeList1.GetStateImage
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
Dim oItem As AdminItem = oTreeList.GetRow(e.Node.Id)
Select Case oItem.Scope
Case "PROFILE"
e.NodeImageIndex = 0
Case "PROCESS"
e.NodeImageIndex = 1
Case "WINDOW"
e.NodeImageIndex = 2
Case "CONTROL"
e.NodeImageIndex = 3
End Select
End Sub
Private Sub TreeList2_GetStateImage(sender As Object, e As GetStateImageEventArgs) Handles TreeList2.GetStateImage
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
Dim oItem As AdminItem = oTreeList.GetRow(e.Node.Id)
Select Case oItem.Scope
Case "PROFILE"
e.NodeImageIndex = 0
Case "INDEX_MAN"
e.NodeImageIndex = 1
Case "INDEX_AUTO"
e.NodeImageIndex = 2
End Select
End Sub
End Class