388 lines
14 KiB
VB.net
388 lines
14 KiB
VB.net
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
|
|
Inherits frmAdmin_Base
|
|
|
|
Private Const IDB_START = "IDB_START"
|
|
Private Const IDB_ATTRIBUTES = "IDB_ATTRIBUTES"
|
|
Private Const IDB_BUSINESS_ENTITY = "IDB_BUSINESS_ENTITY"
|
|
Private Const IDB_SOURCE_SQL = "IDB_SOURCE_SQL"
|
|
Private Const GLOBIX_PROFILES = "GLOBIX_PROFILES"
|
|
Private Const CW_PROFILES = "CW_PROFILES"
|
|
|
|
Private PrimaryKey As String = Nothing
|
|
Private AdminItems As New List(Of AdminItem)
|
|
Private CurrentPage 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
|
|
Load_SQLData()
|
|
|
|
TreeListMenu.ExpandAll()
|
|
|
|
' Show Tab Header in Development, hide when running the app
|
|
XtraTabControl.ShowTabHeader = DefaultBoolean.False
|
|
End Sub
|
|
|
|
Private Function Load_SQLData() As Boolean
|
|
Try
|
|
Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM VWIDB_ADMINISTRATION_TREEVIEW")
|
|
AdminItems.Clear()
|
|
|
|
For Each oRow As DataRow In oTable.Rows
|
|
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
|
|
}
|
|
|
|
AdminItems.Add(oItem)
|
|
Next
|
|
Return True
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
Sub Display_Tab(pPageToDisplay As XtraTabPage)
|
|
Try
|
|
If pPageToDisplay.TabControl Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
For Each oDocument As XtraTabPage In pPageToDisplay.TabControl.TabPages
|
|
If oDocument.Name = pPageToDisplay.Name Then
|
|
oDocument.PageVisible = True
|
|
Else
|
|
oDocument.PageVisible = False
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Sub Display_RibbonPage(PageToDisplay As RibbonPage)
|
|
Try
|
|
For Each oPage As RibbonPage In RibbonControl1.Pages
|
|
If oPage.Name = PageToDisplay.Name Then
|
|
RibbonControl1.SelectedPage = PageToDisplay
|
|
End If
|
|
Next
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
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
|
|
Exit Sub
|
|
End If
|
|
|
|
CurrentPage = e.Node.Tag.ToString
|
|
|
|
Select Case e.Node.Tag.ToString
|
|
Case IDB_START
|
|
Display_Tab(XtraTabPage_IDB)
|
|
|
|
Case IDB_ATTRIBUTES
|
|
Display_Tab(XtraTabPage_IDB)
|
|
Display_Tab(XtraTabPageIDB_Attributes_New)
|
|
|
|
'Dim oTable As DataTable = My.Database.GetDatatable(oSource.Title)
|
|
'Load_Grid(oTable, oSource, GridAttributes)
|
|
|
|
Case IDB_BUSINESS_ENTITY
|
|
'DisplayTab(XtraTabPage_Entities)
|
|
|
|
Case GLOBIX_PROFILES
|
|
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 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)
|
|
|
|
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)
|
|
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
|
|
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
|
|
Try
|
|
Dim oRow As DataRow = oView.GetFocusedDataRow
|
|
If oRow IsNot Nothing Then
|
|
Dim oPrimaryKey As Integer = oRow.Item(PrimaryKey)
|
|
|
|
Select Case oView.Name
|
|
Case ViewAttributes.Name
|
|
Load_Attribute(oPrimaryKey)
|
|
|
|
Case ViewSourceSQL.Name
|
|
Load_SourceSql(oPrimaryKey)
|
|
|
|
Case WinExplorerView1.Name
|
|
Load_CWProfile(oPrimaryKey)
|
|
|
|
End Select
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Load_Attribute(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)
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Load_SourceSql(PrimaryKey As Integer)
|
|
Try
|
|
Dim oForm As New frmAdmin_SourceSQL(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)
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Load_CWProfile(PrimaryKey As Integer)
|
|
Try
|
|
Dim oForm As New frmAdmin_CWProfile(PrimaryKey)
|
|
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)
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem7_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick
|
|
Try
|
|
Dim oRow As DataRow = ViewAttributes.GetFocusedDataRow
|
|
If oRow IsNot Nothing Then
|
|
Dim oPrimaryKey As Integer = oRow.Item(PrimaryKey)
|
|
Load_Attribute(oPrimaryKey)
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem9_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem9.ItemClick
|
|
Load_SQLData()
|
|
ShowStatus("Source SQL neu geladen")
|
|
End Sub
|
|
|
|
Private Sub ShowStatus(v As String)
|
|
labelStatus.Caption = v
|
|
labelStatus.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
|
End Sub
|
|
|
|
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 |