434 lines
16 KiB
VB.net
434 lines
16 KiB
VB.net
Imports System.ComponentModel
|
|
Imports DevExpress.Utils
|
|
Imports DevExpress.XtraBars.Ribbon
|
|
Imports DevExpress.XtraEditors.Controls
|
|
Imports DevExpress.XtraEditors.Repository
|
|
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
|
|
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
|
|
End Class
|
|
|
|
Private Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Load_SQLData()
|
|
|
|
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
|
|
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,
|
|
.Active = oRow.Item("ACTIVE")
|
|
}
|
|
|
|
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, TreeList_IDBAttributes)
|
|
|
|
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, TreeList_IDBEntities)
|
|
|
|
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, TreeList_GLOBIXProfiles)
|
|
|
|
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, TreeList_CWProfiles)
|
|
|
|
End Select
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Load_Tree(Source As List(Of AdminItem), TreeList As TreeList)
|
|
' === ACTIVE COLUMN
|
|
Dim oActiveEditor As New RepositoryItemImageComboBox With {
|
|
.SmallImages = ActiveImages,
|
|
.GlyphAlignment = HorzAlignment.Center
|
|
}
|
|
oActiveEditor.Buttons.Clear()
|
|
oActiveEditor.Items.AddRange(New List(Of ImageComboBoxItem) From {
|
|
New ImageComboBoxItem("Active", True, 0),
|
|
New ImageComboBoxItem("Inactive", False, 1)
|
|
})
|
|
Dim oActiveColumn = New Columns.TreeListColumn() With {
|
|
.Name = "columnActive",
|
|
.Caption = " ",
|
|
.FieldName = "Active",
|
|
.Visible = True,
|
|
.VisibleIndex = 1,
|
|
.ColumnEdit = oActiveEditor,
|
|
.MaxWidth = 30,
|
|
.MinWidth = 30,
|
|
.Image = ActiveImages.GetImage(0)
|
|
}
|
|
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
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
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
|
|
.ShowHorzLines = True
|
|
.ShowVertLines = True
|
|
.ShowTreeLines = True
|
|
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 TreeList_IDBAttributes.Name
|
|
Load_IDBAttribute(oItem.RealGuid)
|
|
|
|
Case TreeList_IDBEntities.Name
|
|
Load_IDBEntity(oItem.RealGuid)
|
|
|
|
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)
|
|
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, TreeList_IDBAttributes)
|
|
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, TreeList_IDBEntities)
|
|
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
|
|
Load_SQLData()
|
|
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsCWItem).ToList
|
|
|
|
Load_Tree(oItems, TreeList_CWProfiles)
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
Private Sub Load_GLOBIXProfile(PrimaryKey As Integer)
|
|
Try
|
|
Dim oForm As New frmGlobixAdministration(PrimaryKey)
|
|
oForm.ShowDialog()
|
|
|
|
If oForm.HasChanges Then
|
|
Load_SQLData()
|
|
Dim oItems As List(Of AdminItem) = AdminItems.Where(AddressOf IsCWItem).ToList
|
|
|
|
Load_Tree(oItems, TreeList_CWProfiles)
|
|
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 = TreeList_IDBAttributes.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
|
|
End Class |