397 lines
14 KiB
VB.net
397 lines
14 KiB
VB.net
Imports System.ComponentModel
|
|
Imports DevExpress.Utils
|
|
Imports DevExpress.XtraBars.Ribbon
|
|
Imports DevExpress.XtraTab
|
|
Imports DevExpress.XtraTreeList
|
|
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 PrimaryKey As String = Nothing
|
|
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
|
|
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
|
|
|
|
''' <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
|
|
Load_SQLData()
|
|
|
|
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
|
|
|
|
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 = 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
|
|
}
|
|
|
|
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
|
|
labelTitle.Text = "Start"
|
|
Exit Sub
|
|
End If
|
|
|
|
CurrentPage = e.Node.Tag.ToString
|
|
|
|
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 oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsIDBAttribute).ToList()
|
|
Load_Tree(oItems, TreeListIDBAttributes)
|
|
|
|
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 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 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_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.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 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 oItem As AdminItem = oView.GetFocusedRow
|
|
If oItem IsNot Nothing Then
|
|
Select Case oView.Name
|
|
Case TreeListIDBAttributes.Name
|
|
Load_IDBAttribute(oItem.RealGuid)
|
|
|
|
Case TreeListIDBEntities.Name
|
|
Load_IDBEntity(oItem.RealGuid)
|
|
End Select
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Load_IDBAttribute(PrimaryKey As Integer)
|
|
Try
|
|
Dim oForm As New frmAdmin_IDBAttribute(PrimaryKey)
|
|
oForm.ShowDialog()
|
|
|
|
If oForm.HasChanges Then
|
|
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_IDBEntity(PrimaryKey As Integer)
|
|
Try
|
|
Dim oForm As New frmAdmin_IDBEntity(PrimaryKey)
|
|
oForm.ShowDialog()
|
|
|
|
If oForm.HasChanges Then
|
|
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)
|
|
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 = TreeListIDBAttributes.GetFocusedDataRow
|
|
If oRow IsNot Nothing Then
|
|
Dim oPrimaryKey As Integer = DirectCast(oRow.Item(PrimaryKey), Integer)
|
|
Load_IDBAttribute(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 TreeListCWProfiles.GetStateImage
|
|
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
|
|
Dim oItem As AdminItem = DirectCast(oTreeList.GetRow(e.Node.Id), AdminItem)
|
|
|
|
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 TreeListGLOBIXProfiles.GetStateImage
|
|
Dim oTreeList As TreeList = DirectCast(sender, TreeList)
|
|
Dim oItem As AdminItem = DirectCast(oTreeList.GetRow(e.Node.Id), AdminItem)
|
|
|
|
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
|
|
|
|
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 |