ZooFlow: Administration

This commit is contained in:
Jonathan Jenne
2021-04-01 12:07:40 +02:00
parent 20de7e5a11
commit a756c51f34
17 changed files with 2759 additions and 496 deletions

View File

@@ -3,6 +3,10 @@ Imports DevExpress.Utils
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraTab
Imports DevExpress.XtraTreeList
Imports DigitalData.Modules.Logging
@@ -10,54 +14,59 @@ Imports DigitalData.Modules.Logging
Public Class frmAdmin_Start
Inherits frmAdmin_Base
Private Const IDB_START = "IDB_START"
Private Const IDB_ATTRIBUTES = "IDB_ATTRIBUTES"
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"
Private Const COLUMN_NAME_ACTIVE = "ACTIVE"
Private Const MODULE_IDB = "IDB"
Private Const PAGE_IDB_START = "IDB_START"
Private Const PAGE_IDB_ATTRIBUTES = "IDB_ATTRIBUTES"
Private Const PAGE_IDB_BUSINESS_ENTITIES = "IDB_BUSINESS_ENTITIES"
Private Const PAGE_IDB_SOURCE_SQL = "IDB_SOURCE_SQL"
Private Const MODULE_GLOBIX = "GLOBIX"
Private Const PAGE_GLOBIX_PROFILES = "GLOBIX_PROFILES"
Private Const MODULE_CW = "CW"
Private Const PAGE_CW_PROFILES = "CW_PROFILES"
Private Const MODULE_META = "META"
Private Const PAGE_META_SOURCE_SQL = "META_SOURCE_SQL"
Private PrimaryKey As String = Nothing
Private AdminItems As New List(Of AdminItem)
Private CurrentModule As String
Private CurrentPage As String
Private CurrentItem As AdminItem
Private Function IsIDBAttribute(Item As AdminItem) As Boolean
Return Item.Entity = "IDB" And Item.Scope = "ATTRIBUTE"
Private Function IsIDBAttributes(Item As AdminItem) As Boolean
Return Item.Entity = PAGE_IDB_ATTRIBUTES
End Function
Private Function IsIDBEntity(Item As AdminItem) As Boolean
Return Item.Entity = "IDB" And Item.Scope = "ENTITY"
Private Function IsIDBEntities(Item As AdminItem) As Boolean
Return Item.Entity = PAGE_IDB_BUSINESS_ENTITIES
End Function
Private Function IsCWItem(Item As AdminItem) As Boolean
Return Item.Entity = "CW"
Private Function IsCWPRofiles(Item As AdminItem) As Boolean
Return Item.Entity = PAGE_CW_PROFILES
End Function
Private Function IsGLOBIXItem(Item As AdminItem) As Boolean
Return Item.Entity = "GLOBIX"
Private Function IsGLOBIXProfiles(Item As AdminItem) As Boolean
Return Item.Entity = PAGE_GLOBIX_PROFILES
End Function
Private Function IsSourceSQL(Item As AdminItem) As Boolean
Return Item.Entity = PAGE_META_SOURCE_SQL
End Function
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
Public Property Active As Boolean
''' <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
Public Property PrimaryKey As String
Public Property ForeignKey As String
Public Property SQLCommand As String
Public Property SQLResult As DataTable
End Class
Private Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -65,31 +74,32 @@ Public Class frmAdmin_Start
TreeListMenu.ExpandAll()
AddHandler TreeList_IDBAttributes.DoubleClick, AddressOf TreeList_DoubleClick
AddHandler TreeList_IDBEntities.DoubleClick, AddressOf TreeList_DoubleClick
AddHandler TreeList_CWProfiles.DoubleClick, AddressOf TreeList_DoubleClick
AddHandler TreeList_GLOBIXProfiles.DoubleClick, AddressOf TreeList_DoubleClick
' Show Tab Header in Development, hide when running the app
XtraTabControl.ShowTabHeader = DefaultBoolean.False
AddHandler GridControl1.DoubleClick, AddressOf GridControl_DoubleClick
End Sub
Private Function Load_SQLData() As Boolean
Try
Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM VWIDB_ADMINISTRATION_TREEVIEW")
Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM TBZF_ADMIN_SOURCE_SQL")
AdminItems.Clear()
For Each oRow As DataRow In oTable.Rows
Dim oItem As New AdminItem With {
.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,
.Summary = oRow.Item("SUMMARY").ToString,
.Active = oRow.Item("ACTIVE")
.ParentId = CInt(oRow.Item("PARENT_ID")),
.Entity = oRow.Item("ENTITY_TITLE").ToString,
.Scope = oRow.Item("SCOPE").ToString,
.SQLCommand = oRow.Item("SQL_COMMAND").ToString,
.PrimaryKey = NotNull(oRow.Item("PK_COLUMN"), String.Empty),
.ForeignKey = NotNull(oRow.Item("FK_COLUMN"), String.Empty)
}
Try
oItem.SQLResult = My.Database.GetDatatable(oItem.SQLCommand)
Catch ex As Exception
oItem.SQLResult = Nothing
Logger.Error(ex)
End Try
AdminItems.Add(oItem)
Next
Return True
@@ -139,42 +149,44 @@ Public Class frmAdmin_Start
CurrentPage = e.Node.Tag.ToString
Select Case e.Node.Tag.ToString
Case IDB_START
Case PAGE_IDB_START
CurrentModule = MODULE_IDB
labelTitle.Text = "IDB Übersicht"
Display_Tab(XtraTabPage_IDB)
Case IDB_ATTRIBUTES
Case PAGE_IDB_ATTRIBUTES
CurrentModule = MODULE_IDB
labelTitle.Text = "IDB Attribute"
Display_Tab(XtraTabPage_IDB)
Display_Tab(XtraTabPageIDB_Attributes_New)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBAttribute).ToList()
Load_Tree(oItems, TreeList_IDBAttributes)
CurrentItem = AdminItems.Where(AddressOf IsIDBAttributes).FirstOrDefault()
Load_Tree(CurrentItem)
Case IDB_BUSINESS_ENTITIES
Case PAGE_IDB_BUSINESS_ENTITIES
CurrentModule = MODULE_IDB
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, TreeList_IDBEntities)
CurrentItem = AdminItems.Where(AddressOf IsIDBEntities).FirstOrDefault()
Load_Tree(CurrentItem)
Case GLOBIX_PROFILES
Case PAGE_GLOBIX_PROFILES
CurrentModule = MODULE_GLOBIX
labelTitle.Text = "Global Indexer Profile"
Display_Tab(XtraTabPage_GlobalIndexer)
Display_RibbonPage(RibbonPage_GlobalIndexer)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsGLOBIXItem).ToList()
Load_Tree(oItems, TreeList_GLOBIXProfiles)
CurrentItem = AdminItems.Where(AddressOf IsGLOBIXProfiles).FirstOrDefault()
Load_Tree(CurrentItem)
Case CW_PROFILES
Case PAGE_CW_PROFILES
CurrentModule = MODULE_CW
labelTitle.Text = "Clipboard Watcher Profile"
Display_Tab(XtraTabPage_ClipboardWatcher)
Display_Tab(XtraTabPageCWProfiles)
Display_RibbonPage(RibbonPage_ClipboardWatcher)
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsCWItem).ToList()
Load_Tree(oItems, TreeList_CWProfiles)
CurrentItem = AdminItems.Where(AddressOf IsCWPRofiles).FirstOrDefault()
Load_Tree(CurrentItem)
Case PAGE_META_SOURCE_SQL
CurrentModule = MODULE_META
labelTitle.Text = "Source SQL"
CurrentItem = AdminItems.Where(AddressOf IsSourceSQL).FirstOrDefault()
Load_Tree(CurrentItem)
End Select
Catch ex As Exception
@@ -182,8 +194,7 @@ Public Class frmAdmin_Start
End Try
End Sub
Private Sub Load_Tree(Source As List(Of AdminItem), TreeList As TreeList)
' === ACTIVE COLUMN
Private Function Get_ActiveColumn() As GridColumn
Dim oActiveEditor As New RepositoryItemImageComboBox With {
.SmallImages = ActiveImages,
.GlyphAlignment = HorzAlignment.Center
@@ -193,12 +204,12 @@ Public Class frmAdmin_Start
New ImageComboBoxItem("Active", True, 0),
New ImageComboBoxItem("Inactive", False, 1)
})
Dim oActiveColumn = New Columns.TreeListColumn() With {
Dim oActiveColumn = New GridColumn() With {
.Name = "columnActive",
.Caption = " ",
.FieldName = "Active",
.FieldName = COLUMN_NAME_ACTIVE,
.Visible = True,
.VisibleIndex = 1,
.VisibleIndex = 0,
.ColumnEdit = oActiveEditor,
.MaxWidth = 30,
.MinWidth = 30,
@@ -206,137 +217,96 @@ Public Class frmAdmin_Start
}
oActiveColumn.OptionsColumn.AllowEdit = False
' === TYPE/SCOPE COLUMN
Dim oTypeEditor As New RepositoryItemImageComboBox With {
.SmallImages = TypeImages,
.GlyphAlignment = HorzAlignment.Center
}
oTypeEditor.Buttons.Clear()
oTypeEditor.Items.AddRange(New List(Of ImageComboBoxItem) From {
New ImageComboBoxItem("Profil", "PROFILE", 0),
New ImageComboBoxItem("Prozess", "PROCESS", 1),
New ImageComboBoxItem("Fenster", "WINDOW", 2),
New ImageComboBoxItem("Feld", "CONTROL", 3),
New ImageComboBoxItem("Attribut", "ATTRIBUTE", 4),
New ImageComboBoxItem("Entität", "ENTITY", 5)
})
Dim oTypeColumn = New Columns.TreeListColumn() With {
.Name = "columnType",
.Caption = " ",
.FieldName = "Scope",
.Visible = True,
.VisibleIndex = 2,
.ColumnEdit = oTypeEditor,
.MaxWidth = 30,
.MinWidth = 30,
.Image = TypeImages.GetImage(6)
}
oTypeColumn.OptionsColumn.AllowEdit = False
Return oActiveColumn
End Function
Dim oColumns As New List(Of Columns.TreeListColumn) From {
oActiveColumn,
oTypeColumn,
New Columns.TreeListColumn() With {
.Name = "columnTitle",
.Caption = "Titel",
.FieldName = "Title",
.Visible = True,
.VisibleIndex = 5
},
New Columns.TreeListColumn() With {
.Name = "columnScope",
.Caption = "Typ",
.FieldName = "Scope",
.Visible = True,
.VisibleIndex = 6
},
New Columns.TreeListColumn() With {
.Name = "columnSummary",
.Caption = "Beschreibung",
.FieldName = "Summary",
.Visible = True,
.VisibleIndex = 7
}
}
Private Sub Load_Tree(Source As AdminItem)
If Source Is Nothing OrElse Source.SQLResult Is Nothing Then
Exit Sub
End If
TreeList.Columns.Clear()
TreeList.Columns.AddRange(oColumns.ToArray)
TreeList.HierarchyFieldName = "Title"
TreeList.KeyFieldName = "Guid"
TreeList.ParentFieldName = "ParentId"
TreeList.DataSource = Source
TreeList.ForceInitialize()
Dim oActiveColumn = Get_ActiveColumn()
With TreeList.Appearance.EvenRow
GridControl1.DataSource = Source.SQLResult
GridControl1.ForceInitialize()
GridView1.PopulateColumns()
If GridView1.Columns.Item(COLUMN_NAME_ACTIVE) Is Nothing Then
GridView1.Columns.Add(oActiveColumn)
End If
With GridView1.Appearance.EvenRow
.BackColor = Color.Snow
.Options.UseBackColor = True
End With
With TreeList.Appearance.FocusedCell
With GridView1.Appearance.FocusedCell
.BackColor = Color.Gold
.Options.UseBackColor = True
End With
With TreeList.OptionsBehavior
With GridView1.OptionsBehavior
.Editable = False
.ReadOnly = True
End With
With TreeList.OptionsView
With GridView1.OptionsView
.ShowAutoFilterRow = True
.EnableAppearanceEvenRow = True
.ShowIndicator = False
.ShowHorzLines = True
.ShowVertLines = True
.ShowTreeLines = True
.ShowHorizontalLines = DefaultBoolean.True
.ShowVerticalLines = DefaultBoolean.True
End With
With TreeList.OptionsClipboard
With GridView1.OptionsClipboard
.CopyColumnHeaders = DefaultBoolean.False
End With
With TreeList.OptionsFind
With GridView1.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
AddHandler GridView1.KeyDown, Sub(sender As GridView, e As KeyEventArgs)
Dim oView As GridView = sender
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
TreeList.BestFitColumns()
GridView1.BestFitColumns()
End Sub
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)
Private Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick
Dim oGrid As GridControl = TryCast(sender, GridControl)
Dim oView As GridView = oGrid.MainView
Dim hitInfo As GridHitInfo = oView.CalcHitInfo(TryCast(e, DXMouseEventArgs).Location)
If hitInfo.InRow Then
Try
Dim oItem As AdminItem = oView.GetFocusedRow
If oItem IsNot Nothing Then
Select Case oView.Name
Case TreeList_IDBAttributes.Name
Load_IDBAttribute(oItem.RealGuid)
Dim oRowView As DataRowView = oView.GetFocusedRow
Dim oItem As AdminItem = CurrentItem
Dim oGuid = oRowView.Row.Item(oItem.PrimaryKey)
Case TreeList_IDBEntities.Name
Load_IDBEntity(oItem.RealGuid)
If oRowView IsNot Nothing Then
Select Case CurrentPage
Case PAGE_IDB_ATTRIBUTES
Load_IDBAttribute(oGuid)
Case TreeList_CWProfiles.Name
Select Case oItem.Scope
Case "PROFILE"
Load_CWProfile(oItem.RealGuid)
Case Else
ShowError($"Scope {oItem.Scope} is not implemented!")
End Select
Case TreeList_GLOBIXProfiles.Name
GLOBIX_JUMP_DOCTYPE_ID = oItem.RealGuid
Load_GLOBIXProfile(oItem.RealGuid)
Case PAGE_IDB_BUSINESS_ENTITIES
Load_IDBEntity(oGuid)
Case PAGE_CW_PROFILES
Load_CWProfile(oGuid)
Case PAGE_GLOBIX_PROFILES
GLOBIX_JUMP_DOCTYPE_ID = oGuid
Load_GLOBIXProfile(oGuid)
Case PAGE_META_SOURCE_SQL
Load_SourceSQL(oGuid)
End Select
End If
Catch ex As Exception
@@ -345,6 +315,21 @@ Public Class frmAdmin_Start
End If
End Sub
Private Sub Load_SourceSQL(PrimaryKey As Integer)
Try
Dim oForm As New frmAdmin_SourceSQL(PrimaryKey)
oForm.ShowDialog()
If oForm.HasChanges Then
Load_SQLData()
Dim oItem As AdminItem = AdminItems.Where(AddressOf IsSourceSQL).FirstOrDefault
Load_Tree(oItem)
End If
Catch ex As Exception
ShowError(ex)
End Try
End Sub
Private Sub Load_IDBAttribute(PrimaryKey As Integer)
Try
Dim oForm As New frmAdmin_IDBAttribute(PrimaryKey)
@@ -352,8 +337,8 @@ Public Class frmAdmin_Start
If oForm.HasChanges Then
Load_SQLData()
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBAttribute).ToList
Load_Tree(oItems, TreeList_IDBAttributes)
Dim oItem As AdminItem = AdminItems.Where(AddressOf IsIDBAttributes).FirstOrDefault
Load_Tree(oItem)
End If
Catch ex As Exception
ShowError(ex)
@@ -367,8 +352,8 @@ Public Class frmAdmin_Start
If oForm.HasChanges Then
Load_SQLData()
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBEntity).ToList
Load_Tree(oItems, TreeList_IDBEntities)
Dim oItem As AdminItem = AdminItems.Where(AddressOf IsIDBAttributes).FirstOrDefault
Load_Tree(oItem)
End If
Catch ex As Exception
ShowError(ex)
@@ -382,9 +367,9 @@ Public Class frmAdmin_Start
If oForm.HasChanges Then
Load_SQLData()
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsCWItem).ToList
Load_Tree(oItems, TreeList_CWProfiles)
Dim oItem As AdminItem = AdminItems.Where(AddressOf IsCWPRofiles).FirstOrDefault
Load_Tree(oItem)
End If
Catch ex As Exception
ShowError(ex)
@@ -397,9 +382,9 @@ Public Class frmAdmin_Start
If oForm.HasChanges Then
Load_SQLData()
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsCWItem).ToList
Load_Tree(oItems, TreeList_CWProfiles)
Dim oItem As AdminItem = AdminItems.Where(AddressOf IsCWPRofiles).FirstOrDefault
Load_Tree(oItem)
End If
Catch ex As Exception
ShowError(ex)
@@ -408,7 +393,7 @@ Public Class frmAdmin_Start
Private Sub BarButtonItem7_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick
Try
Dim oRow As DataRow = TreeList_IDBAttributes.GetFocusedDataRow
Dim oRow As DataRow = GridView1.GetFocusedRow
If oRow IsNot Nothing Then
Dim oPrimaryKey As Integer = DirectCast(oRow.Item(PrimaryKey), Integer)
Load_IDBAttribute(oPrimaryKey)