420 lines
14 KiB
VB.net
420 lines
14 KiB
VB.net
Imports System.ComponentModel
|
|
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
|
|
|
|
Public Class frmAdmin_Start
|
|
Inherits frmAdmin_Base
|
|
|
|
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 IsIDBAttributes(Item As AdminItem) As Boolean
|
|
Return Item.Entity = PAGE_IDB_ATTRIBUTES
|
|
End Function
|
|
|
|
Private Function IsIDBEntities(Item As AdminItem) As Boolean
|
|
Return Item.Entity = PAGE_IDB_BUSINESS_ENTITIES
|
|
End Function
|
|
|
|
Private Function IsCWPRofiles(Item As AdminItem) As Boolean
|
|
Return Item.Entity = PAGE_CW_PROFILES
|
|
End Function
|
|
|
|
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 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 Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Load_SQLData()
|
|
|
|
TreeListMenu.ExpandAll()
|
|
|
|
AddHandler GridControl1.DoubleClick, AddressOf GridControl_DoubleClick
|
|
End Sub
|
|
|
|
Private Function Load_SQLData() As Boolean
|
|
Try
|
|
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_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
|
|
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 PAGE_IDB_START
|
|
CurrentModule = MODULE_IDB
|
|
labelTitle.Text = "IDB Übersicht"
|
|
|
|
Case PAGE_IDB_ATTRIBUTES
|
|
CurrentModule = MODULE_IDB
|
|
labelTitle.Text = "IDB Attribute"
|
|
|
|
CurrentItem = AdminItems.Where(AddressOf IsIDBAttributes).FirstOrDefault()
|
|
Load_Tree(CurrentItem)
|
|
|
|
Case PAGE_IDB_BUSINESS_ENTITIES
|
|
CurrentModule = MODULE_IDB
|
|
labelTitle.Text = "IDB Entitäten"
|
|
|
|
CurrentItem = AdminItems.Where(AddressOf IsIDBEntities).FirstOrDefault()
|
|
Load_Tree(CurrentItem)
|
|
|
|
Case PAGE_GLOBIX_PROFILES
|
|
CurrentModule = MODULE_GLOBIX
|
|
labelTitle.Text = "Global Indexer Profile"
|
|
|
|
CurrentItem = AdminItems.Where(AddressOf IsGLOBIXProfiles).FirstOrDefault()
|
|
Load_Tree(CurrentItem)
|
|
|
|
Case PAGE_CW_PROFILES
|
|
CurrentModule = MODULE_CW
|
|
labelTitle.Text = "Clipboard Watcher Profile"
|
|
|
|
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
|
|
ShowError(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Style_ActiveColumn(ActiveColumn)
|
|
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)
|
|
})
|
|
|
|
With ActiveColumn
|
|
.Caption = " "
|
|
.Name = "columnActive"
|
|
.Visible = True
|
|
.VisibleIndex = 0
|
|
.ColumnEdit = oActiveEditor
|
|
.MaxWidth = 30
|
|
.MinWidth = 30
|
|
.Image = ActiveImages.GetImage(0)
|
|
.OptionsColumn.AllowEdit = False
|
|
End With
|
|
End Sub
|
|
|
|
Private Sub Load_Tree(Source As AdminItem)
|
|
If Source Is Nothing OrElse Source.SQLResult Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
GridControl1.DataSource = Source.SQLResult
|
|
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)
|
|
Style_ActiveColumn(oActiveColumn)
|
|
Else
|
|
Style_ActiveColumn(GridView1.Columns.Item(COLUMN_NAME_ACTIVE))
|
|
End If
|
|
|
|
With GridView1.Appearance.EvenRow
|
|
.BackColor = Color.Snow
|
|
.Options.UseBackColor = True
|
|
End With
|
|
|
|
With GridView1.Appearance.FocusedCell
|
|
.BackColor = Color.Gold
|
|
.Options.UseBackColor = True
|
|
End With
|
|
|
|
With GridView1.OptionsBehavior
|
|
.Editable = False
|
|
.ReadOnly = True
|
|
End With
|
|
|
|
With GridView1.OptionsView
|
|
.ShowAutoFilterRow = True
|
|
.EnableAppearanceEvenRow = True
|
|
.ShowIndicator = False
|
|
.ShowHorizontalLines = DefaultBoolean.True
|
|
.ShowVerticalLines = DefaultBoolean.True
|
|
End With
|
|
|
|
With GridView1.OptionsClipboard
|
|
.CopyColumnHeaders = DefaultBoolean.False
|
|
End With
|
|
|
|
With GridView1.OptionsFind
|
|
.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
|
|
|
|
GridView1.BestFitColumns()
|
|
End Sub
|
|
|
|
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 oRowView As DataRowView = oView.GetFocusedRow
|
|
Dim oItem As AdminItem = CurrentItem
|
|
Dim oGuid = oRowView.Row.Item(oItem.PrimaryKey)
|
|
|
|
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)
|
|
End Select
|
|
End If
|
|
Catch ex As Exception
|
|
ShowError(ex)
|
|
End Try
|
|
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)
|
|
oForm.ShowDialog()
|
|
|
|
If oForm.HasChanges Then
|
|
Load_SQLData()
|
|
Dim oItem As AdminItem = AdminItems.Where(AddressOf IsIDBAttributes).FirstOrDefault
|
|
Load_Tree(oItem)
|
|
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 oItem As AdminItem = AdminItems.Where(AddressOf IsIDBAttributes).FirstOrDefault
|
|
Load_Tree(oItem)
|
|
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 oItem As AdminItem = AdminItems.Where(AddressOf IsCWPRofiles).FirstOrDefault
|
|
Load_Tree(oItem)
|
|
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 oItem As AdminItem = AdminItems.Where(AddressOf IsCWPRofiles).FirstOrDefault
|
|
Load_Tree(oItem)
|
|
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
|
|
|
|
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 |