ZooFlow: Administration
This commit is contained in:
@@ -1,109 +1,68 @@
|
||||
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 DigitalData.Modules.Logging
|
||||
Imports DigitalData.GUIs.ZooFlow.Administration.ClassConstants
|
||||
Imports DevExpress.XtraGrid
|
||||
|
||||
Public Class frmAdmin_Start
|
||||
Inherits frmAdmin_Base
|
||||
|
||||
Private Const COLUMN_NAME_ACTIVE = "ACTIVE"
|
||||
|
||||
Private Const MODULE_IDB = "IDB"
|
||||
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 Dictionary(Of String, AdminItem)
|
||||
Private AdminNodes As New Dictionary(Of String, AdminNode) From {
|
||||
{PAGE_IDB_ATTRIBUTES,
|
||||
New AdminNode With {
|
||||
.Title = "IDB Attribute",
|
||||
.[Module] = MODULE_IDB,
|
||||
.Entity = PAGE_IDB_ATTRIBUTES,
|
||||
.NewRecordTitle = "Neues Attribut"
|
||||
}},
|
||||
{PAGE_IDB_BUSINESS_ENTITIES,
|
||||
New AdminNode With {
|
||||
.Title = "IDB Entitäten",
|
||||
.[Module] = MODULE_IDB,
|
||||
.Entity = PAGE_IDB_BUSINESS_ENTITIES,
|
||||
.NewRecordTitle = "Neue Entität"
|
||||
}},
|
||||
{PAGE_META_SOURCE_SQL,
|
||||
New AdminNode With {
|
||||
.Title = "Source SQL",
|
||||
.[Module] = MODULE_META,
|
||||
.Entity = PAGE_META_SOURCE_SQL,
|
||||
.NewRecordTitle = "Neuer Source SQL"
|
||||
}},
|
||||
{PAGE_GLOBIX_PROFILES,
|
||||
New AdminNode With {
|
||||
.Title = "Global Indexer Profile",
|
||||
.[Module] = MODULE_GLOBIX,
|
||||
.Entity = PAGE_GLOBIX_PROFILES,
|
||||
.NewRecordTitle = "Neues GLOBIX Profil"
|
||||
}},
|
||||
{PAGE_CW_PROFILES,
|
||||
New AdminNode With {
|
||||
.Title = "Clipboard Watcher Profile",
|
||||
.[Module] = MODULE_CW,
|
||||
.Entity = PAGE_CW_PROFILES,
|
||||
.NewRecordTitle = "Neues CW Profil"
|
||||
}}
|
||||
}
|
||||
|
||||
Private CurrentModule As String
|
||||
Private CurrentPage As String
|
||||
Private CurrentItem As AdminItem
|
||||
Private CurrentItem As ClassDetailForm.DetailData
|
||||
|
||||
Private Class AdminNode
|
||||
Public Property Title As String
|
||||
Public Property [Module] As String
|
||||
Public Property Entity As String
|
||||
Public Property NewRecordTitle As String
|
||||
End Class
|
||||
|
||||
Private Class AdminItem
|
||||
Public Property Guid As Integer
|
||||
Public Property ParentId As Integer
|
||||
Public Property Entity As String
|
||||
Public Property Scope As String
|
||||
Public Property PrimaryKey As String
|
||||
Public Property ForeignKey As String
|
||||
Public Property SQLCommand As String
|
||||
Public Property SQLResult As DataTable
|
||||
End Class
|
||||
Private DetailForm As ClassDetailForm
|
||||
|
||||
Private Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Load_SQLData()
|
||||
DetailForm = New ClassDetailForm(My.LogConfig)
|
||||
AddHandler DetailForm.DetailFormClosed, AddressOf DetailForm_Closed
|
||||
|
||||
Load_SQLData()
|
||||
TreeListMenu.ExpandAll()
|
||||
End Sub
|
||||
|
||||
Private Sub DetailForm_Closed(sender As Object, e As frmAdmin_Interface)
|
||||
If e.HasChanges Then
|
||||
Load_SQLData()
|
||||
Load_GridData(DetailForm.DetailDataList.Item(CurrentPage))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function Handle_LoadPage(Page As String) As Boolean
|
||||
If DetailForm.DetailSettingsList.ContainsKey(Page) Then
|
||||
Dim oNode = DetailForm.DetailSettingsList.Item(Page)
|
||||
CurrentModule = oNode.Module
|
||||
labelTitle.Text = oNode.GridTitle
|
||||
btnAddRecord.Caption = oNode.NewRecordTitle
|
||||
Else
|
||||
MsgBox($"Page [{Page}] not found in AdminNodes! Exiting." & vbNewLine &
|
||||
"Check your definitions in the TreeList NodeEditor and in SourceSQL", MsgBoxStyle.Critical, Text)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If DetailForm.DetailDataList.ContainsKey(Page) Then
|
||||
Dim oItem = DetailForm.DetailDataList.Item(Page)
|
||||
Load_GridData(oItem)
|
||||
CurrentItem = oItem
|
||||
Else
|
||||
MsgBox($"Page [{Page}] not found in AdminItems! Exiting." & vbNewLine &
|
||||
"Check your definitions in the TreeList NodeEditor and in SourceSQL", MsgBoxStyle.Critical, Text)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function Load_SQLData() As Boolean
|
||||
Try
|
||||
Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM TBZF_ADMIN_SOURCE_SQL")
|
||||
AdminItems.Clear()
|
||||
DetailForm.DetailDataList.Clear()
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oItem As New AdminItem With {
|
||||
Dim oItem As New ClassDetailForm.DetailData With {
|
||||
.Guid = CInt(oRow.Item("GUID")),
|
||||
.ParentId = CInt(oRow.Item("PARENT_ID")),
|
||||
.Entity = oRow.Item("ENTITY_TITLE").ToString,
|
||||
@@ -120,8 +79,9 @@ Public Class frmAdmin_Start
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
AdminItems.Add(oItem.Entity, oItem)
|
||||
DetailForm.DetailDataList.Add(oItem.Entity, oItem)
|
||||
Next
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -132,37 +92,21 @@ Public Class frmAdmin_Start
|
||||
Private Sub TreeListMenu_FocusedNodeChanged(sender As Object, e As DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) Handles TreeListMenu.FocusedNodeChanged
|
||||
Try
|
||||
If e.Node Is Nothing OrElse e.Node.Tag Is Nothing OrElse e.Node.Tag = String.Empty Then
|
||||
RibbonPageGroup1.Enabled = False
|
||||
labelTitle.Text = "Start"
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
CurrentPage = e.Node.Tag.ToString
|
||||
|
||||
If AdminNodes.ContainsKey(CurrentPage) Then
|
||||
Dim oNode = AdminNodes.Item(CurrentPage)
|
||||
CurrentModule = oNode.Module
|
||||
labelTitle.Text = oNode.Title
|
||||
btnAddRecord.Caption = oNode.NewRecordTitle
|
||||
Else
|
||||
MsgBox($"Page [{CurrentPage}] not found in AdminNodes! Exiting." & vbNewLine &
|
||||
"Check your definitions in the TreeList NodeEditor and in SourceSQL", MsgBoxStyle.Critical, Text)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If AdminItems.ContainsKey(CurrentPage) Then
|
||||
CurrentItem = AdminItems.Item(CurrentPage)
|
||||
Load_GridData(CurrentItem)
|
||||
Else
|
||||
MsgBox($"Page [{CurrentPage}] not found in AdminItems! Exiting." & vbNewLine &
|
||||
"Check your definitions in the TreeList NodeEditor and in SourceSQL", MsgBoxStyle.Critical, Text)
|
||||
Exit Sub
|
||||
If Handle_LoadPage(e.Node.Tag.ToString) Then
|
||||
RibbonPageGroup1.Enabled = True
|
||||
CurrentPage = e.Node.Tag.ToString
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ShowError(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Style_ActiveColumn(ActiveColumn)
|
||||
Private Sub Style_ActiveColumn(ActiveColumn As GridColumn)
|
||||
Dim oActiveEditor As New RepositoryItemImageComboBox With {
|
||||
.SmallImages = ActiveImages,
|
||||
.GlyphAlignment = HorzAlignment.Center
|
||||
@@ -186,7 +130,7 @@ Public Class frmAdmin_Start
|
||||
End With
|
||||
End Sub
|
||||
|
||||
Private Sub Load_GridData(Source As AdminItem)
|
||||
Private Sub Load_GridData(Source As ClassDetailForm.DetailData)
|
||||
If Source Is Nothing OrElse Source.SQLResult Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
@@ -195,7 +139,6 @@ Public Class frmAdmin_Start
|
||||
GridControl1.ForceInitialize()
|
||||
GridView1.PopulateColumns()
|
||||
|
||||
|
||||
If GridView1.Columns.Item(COLUMN_NAME_ACTIVE) Is Nothing Then
|
||||
Dim oActiveColumn = New GridColumn() With {.FieldName = COLUMN_NAME_ACTIVE}
|
||||
GridView1.Columns.Add(oActiveColumn)
|
||||
@@ -235,50 +178,30 @@ Public Class frmAdmin_Start
|
||||
.AlwaysVisible = True
|
||||
End With
|
||||
|
||||
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
|
||||
AddHandler GridView1.KeyDown, AddressOf GridView1_KeyDown
|
||||
|
||||
GridView1.BestFitColumns()
|
||||
End Sub
|
||||
|
||||
Public Sub GridView1_KeyDown(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
|
||||
|
||||
|
||||
Private Sub GridView1_RowClick(sender As Object, e As RowClickEventArgs) Handles GridView1.RowClick
|
||||
Try
|
||||
If e.Clicks = 2 And e.Button = MouseButtons.Left Then
|
||||
Dim oView As GridView = TryCast(sender, GridView)
|
||||
Dim oRowView As DataRowView = oView.GetRow(e.RowHandle)
|
||||
Dim oItem As AdminItem = CurrentItem
|
||||
Dim oGuid = oRowView.Row.Item(oItem.PrimaryKey)
|
||||
Dim oPrimaryKey = Get_PrimaryKey(e.RowHandle)
|
||||
|
||||
If oRowView IsNot Nothing Then
|
||||
Select Case CurrentPage
|
||||
Case PAGE_IDB_ATTRIBUTES
|
||||
Load_IDBAttribute(oGuid)
|
||||
|
||||
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)
|
||||
|
||||
Case Else
|
||||
MsgBox($"The Form for the Tag [{CurrentPage}] has no Form assigned. Maybe you have a typo in your definitions (Database, NodeEditor)?", MsgBoxStyle.Exclamation, Text)
|
||||
End Select
|
||||
If oPrimaryKey IsNot Nothing Then
|
||||
DetailForm.Handle_OpenDetail(oPrimaryKey, CurrentPage, False)
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
@@ -286,86 +209,19 @@ Public Class frmAdmin_Start
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Load_SourceSQL(PrimaryKey As Integer)
|
||||
Private Function Get_PrimaryKey(RowHandle As Integer)
|
||||
Try
|
||||
Dim oForm As New frmAdmin_SourceSQL(PrimaryKey)
|
||||
oForm.ShowDialog()
|
||||
Dim oView As GridView = GridView1
|
||||
Dim oRowView As DataRowView = oView.GetRow(RowHandle)
|
||||
Dim oItem As ClassDetailForm.DetailData = CurrentItem
|
||||
Dim oGuid = oRowView.Row.Item(oItem.PrimaryKey)
|
||||
|
||||
If oForm.HasChanges Then
|
||||
Load_SQLData()
|
||||
Load_GridData(AdminItems.Item(CurrentPage))
|
||||
End If
|
||||
Return oGuid
|
||||
Catch ex As Exception
|
||||
ShowError(ex)
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
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()
|
||||
Load_GridData(AdminItems.Item(CurrentPage))
|
||||
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()
|
||||
Load_GridData(AdminItems.Item(CurrentPage))
|
||||
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()
|
||||
Load_GridData(AdminItems.Item(CurrentPage))
|
||||
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()
|
||||
Load_GridData(AdminItems.Item(CurrentPage))
|
||||
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 = GridView1.GetFocusedRow
|
||||
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
|
||||
End Function
|
||||
|
||||
Private Sub BarButtonItem9_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem9.ItemClick
|
||||
Load_SQLData()
|
||||
@@ -380,4 +236,28 @@ Public Class frmAdmin_Start
|
||||
Private Sub ResetStatus()
|
||||
labelStatus.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
||||
End Sub
|
||||
|
||||
Private Sub btnAddRecord_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnAddRecord.ItemClick
|
||||
Try
|
||||
DetailForm.Handle_OpenDetail(Nothing, CurrentPage, True)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub btnEditRecord_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditRecord.ItemClick
|
||||
Try
|
||||
If GridView1.FocusedRowHandle = GridControl.InvalidRowHandle Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oPrimaryKey = Get_PrimaryKey(GridView1.FocusedRowHandle)
|
||||
|
||||
If oPrimaryKey IsNot Nothing Then
|
||||
DetailForm.Handle_OpenDetail(oPrimaryKey, CurrentPage, False)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user