URL-Links in Tabellen-Views. Umstrukturierung

This commit is contained in:
2023-02-20 13:52:21 +01:00
parent d4d3933bf6
commit d841c4b414
14 changed files with 149 additions and 28 deletions

View File

@@ -0,0 +1,181 @@
Imports DevExpress.Utils
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraTreeList
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
Public Class GridLoader
Inherits BaseClass
Public Const STATE_SUCCESS As String = "SUCCESS"
Public Const STATE_FAILURE As String = "FAILURE"
Public Const STATE_WARNING As String = "WARNING"
Public Const STATE_WAITING As String = "WAITING"
Public Const STATE_HIGHLIGHT As String = "HIGHLIGHT"
Public ReadOnly Property SvgImageCollection As SvgImageCollection
Public ReadOnly Property GridBuilder As GridBuilder
Private ReadOnly StateIcons As New Dictionary(Of String, NodeImage) From {
{STATE_SUCCESS, NodeImage.Success},
{STATE_FAILURE, NodeImage.Failure}
}
Private Enum NodeImage
[Default] = 0
SQL = 1
File = 2
Mail = 3
Success = 4
Failure = 5
Warning = 6
Waiting = 7
User = 8
Highlight = 9
DateTime = 10
Key = 11
Money = 12
Text = 13
End Enum
Public Sub New(pLogConfig As LogConfig, pSvgImageCollection As SvgImageCollection)
MyBase.New(pLogConfig)
Me.SvgImageCollection = pSvgImageCollection
Me.GridBuilder = New GridBuilder()
End Sub
Public Function InitTreeList() As TreeList
Dim oTreeList = New TreeList() With {
.Name = "TreeListResults",
.Visible = False
}
oTreeList.ForceInitialize()
oTreeList.KeyFieldName = "GUID"
oTreeList.ParentFieldName = "PARENT_ID"
GridBuilder.SetDefaults(oTreeList)
GridBuilder.SetClipboardHandler(oTreeList)
GridBuilder.SetReadOnlyOptions(oTreeList)
Return oTreeList
End Function
Public Function InitGrid() As GridControl
Dim oGrid = New GridControl() With {
.Name = "GridViewResults",
.Visible = False
}
oGrid.ForceInitialize()
Dim oView = DirectCast(oGrid.DefaultView, GridView)
GridBuilder.SetDefaults(oView)
GridBuilder.SetClipboardHandler(oView)
' GridBuilder.SetReadOnlyOptions(oView)
' TODO Spalten die nicht HyperLinks sind readonly machen
Return oGrid
End Function
Public Sub InitTreeListColumns(pTreeList As TreeList, pMaxLength As Integer)
Dim oColumn1 = pTreeList.Columns.Item("COLUMN1")
Dim oColumn2 = pTreeList.Columns.Item("COLUMN2")
Dim oColumn3 = pTreeList.Columns.Item("COLUMN3")
Dim oAddedWhenColumn = pTreeList.Columns.Item("ADDED_WHEN")
Dim oStateColumn = pTreeList.Columns.Item("STATE")
Dim oIconColumn = pTreeList.Columns.Item("ICON")
Dim oStateEdit As RepositoryItemImageComboBox = GetStateEdit()
Dim oIconEdit As RepositoryItemImageComboBox = GetIconEdit()
oColumn1.VisibleIndex = 0
oStateColumn.VisibleIndex = 1
oIconColumn.VisibleIndex = 2
Dim oColumnLength = pMaxLength * 5
With oColumn1
.Caption = "Titel"
.MinWidth = oColumnLength
.MaxWidth = oColumnLength
.Width = oColumnLength
.OptionsColumn.AllowSize = False
.OptionsColumn.AllowSort = False
End With
With oColumn2
.Caption = "Wert 1"
End With
With oColumn3
.Caption = "Wert 2"
End With
With oAddedWhenColumn
.Caption = "Datum"
End With
With oStateColumn
.ColumnEdit = oStateEdit
.MaxWidth = 25
.MinWidth = 25
.Width = 25
.Caption = " "
.OptionsColumn.AllowSize = False
.OptionsColumn.AllowSort = False
.ImageOptions.Image = Nothing
End With
With oIconColumn
.ColumnEdit = oIconEdit
.MaxWidth = 25
.MinWidth = 25
.Width = 25
.Caption = " "
.OptionsColumn.AllowSize = False
.OptionsColumn.AllowSort = False
.ImageOptions.Image = Nothing
End With
End Sub
Private Function GetIconEdit() As RepositoryItemImageComboBox
Dim oIconEdit As New RepositoryItemImageComboBox With {
.SmallImages = SvgImageCollection,
.GlyphAlignment = HorzAlignment.Near
}
oIconEdit.Buttons.Clear()
oIconEdit.Items.AddRange(New List(Of ImageComboBoxItem) From {
New ImageComboBoxItem("Email", "MAIL", NodeImage.Mail),
New ImageComboBoxItem("SQL", "SQL", NodeImage.SQL),
New ImageComboBoxItem("File", "FILE", NodeImage.File),
New ImageComboBoxItem("User", "USER", NodeImage.User),
New ImageComboBoxItem("DateTime", "DATETIME", NodeImage.DateTime),
New ImageComboBoxItem("KeyValue", "KEYVALUE", NodeImage.Key),
New ImageComboBoxItem("Money", "MONEY", NodeImage.Money),
New ImageComboBoxItem("Text", "TEXT", NodeImage.Text)
})
Return oIconEdit
End Function
Private Function GetStateEdit() As RepositoryItemImageComboBox
Dim oStateEdit As New RepositoryItemImageComboBox With {
.SmallImages = SvgImageCollection,
.GlyphAlignment = HorzAlignment.Near
}
oStateEdit.Buttons.Clear()
oStateEdit.Items.AddRange(New List(Of ImageComboBoxItem) From {
New ImageComboBoxItem("Success", "SUCCESS", NodeImage.Success),
New ImageComboBoxItem("Failure", "FAILURE", NodeImage.Failure),
New ImageComboBoxItem("Warning", "WARNING", NodeImage.Warning),
New ImageComboBoxItem("Waiting", "WAITING", NodeImage.Waiting),
New ImageComboBoxItem("Default", "DEFAULT", NodeImage.Default),
New ImageComboBoxItem("Highlight", "HIGHLIGHT", NodeImage.Highlight)
})
Return oStateEdit
End Function
End Class

View File

@@ -0,0 +1,160 @@
Imports DevExpress.Utils
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraLayout
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Public Class ParameterLoader
Inherits BaseClass
Private Const LIST_CONTROL_NULL_TEXT As String = "Kein Wert ausgewählt"
Private Database As MSSQLServer
Private LayoutControl As LayoutControl
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pLayoutControl As LayoutControl)
MyBase.New(pLogConfig)
Database = pDatabase
LayoutControl = pLayoutControl
End Sub
Private Function GetDefaultValue(pParam As SearchParameter) As Object
Dim oResult As Object = Nothing
Select Case pParam.DataType
Case Constants.DataTypeEnum.Boolean
Boolean.TryParse(pParam.DefaultValue, oResult)
Case Constants.DataTypeEnum.Date
Date.TryParse(pParam.DefaultValue, oResult)
Case Constants.DataTypeEnum.Integer
Integer.TryParse(pParam.DefaultValue, oResult)
Case Else
oResult = pParam.DefaultValue
End Select
Return oResult
End Function
Public Sub LoadParameters(pSearch As Search)
For Each oParam As SearchParameter In pSearch.Parameters
Dim oControl As Control
Select Case oParam.DataType
Case Constants.DataTypeEnum.Boolean
Dim oDefaultValue As Boolean = GetDefaultValue(oParam)
Dim oCheckbox = New CheckEdit With {
.Text = oParam.Title,
.Checked = oDefaultValue
}
oControl = oCheckbox
Case Constants.DataTypeEnum.Date
Dim oDefaultValue As Date = GetDefaultValue(oParam)
If oDefaultValue = Date.MinValue Then
oDefaultValue = Now
End If
Dim oDateEdit As New DateEdit() With {
.EditValue = oDefaultValue
}
oDateEdit.Properties.ShowClear = False
oControl = oDateEdit
Case Constants.DataTypeEnum.String
Dim oDefaultValue As String = GetDefaultValue(oParam)
Select Case oParam.ItemType
Case Constants.ItemTypeEnum.List
Dim oCombobox = New ComboBoxEdit() With {
.Name = oParam.PatternTitle,
.Tag = oParam.PatternTitle,
.EditValue = oDefaultValue
}
Dim oClearButton = GetClearButtonForControl(oCombobox)
Dim oItems = oParam.ItemString.Split(";"c).ToList()
oCombobox.Properties.Items.AddRange(oItems)
oCombobox.Properties.NullText = LIST_CONTROL_NULL_TEXT
oCombobox.Properties.Buttons.Add(oClearButton)
oControl = oCombobox
Case Constants.ItemTypeEnum.SQL
Dim oGridCombobox = New LookUpEdit() With {
.Name = oParam.PatternTitle,
.Tag = oParam.PatternTitle,
.EditValue = oDefaultValue
}
Dim oClearButton = GetClearButtonForControl(oGridCombobox)
Dim oSQL = oParam.ItemString
Dim oTable = Database.GetDatatable(oSQL)
oGridCombobox.Properties.DataSource = oTable
oGridCombobox.Properties.DisplayMember = oTable.Columns.Item(0).ColumnName
oGridCombobox.Properties.ValueMember = oTable.Columns.Item(0).ColumnName
oGridCombobox.Properties.NullText = LIST_CONTROL_NULL_TEXT
oGridCombobox.Properties.Buttons.Add(oClearButton)
oControl = oGridCombobox
Case Else
oControl = New TextEdit() With {
.EditValue = oDefaultValue
}
End Select
Case Else
Dim oDefaultValue As Object = GetDefaultValue(oParam)
oControl = New TextEdit() With {
.EditValue = oDefaultValue
}
End Select
oControl.Name = oParam.PatternTitle
oControl.Tag = oParam.PatternTitle
Dim oItem As LayoutControlItem = LayoutControl.AddItem()
oItem.Text = oParam.Title
oItem.Control = oControl
oItem.TextLocation = Locations.Top
oItem.TextToControlDistance = 3
oItem.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 10, 0)
Next
End Sub
Private Function GetClearButtonForControl(pControl As Control) As EditorButton
Dim oClearButton As New EditorButton() With {
.Kind = ButtonPredefines.Clear,
.Tag = pControl.Name
}
AddHandler oClearButton.Click, AddressOf ClearButton_Click
Return oClearButton
End Function
Private Sub ClearButton_Click(sender As Object, e As EventArgs)
Dim oButton As EditorButton = sender
Dim oControlName As String = oButton.Tag.ToString
Dim oControl = LayoutControl.Controls.Find(oControlName, True).SingleOrDefault()
Select Case oControl.GetType
Case GetType(LookUpEdit)
DirectCast(oControl, LookUpEdit).EditValue = Nothing
Case GetType(ComboBoxEdit)
DirectCast(oControl, ComboBoxEdit).EditValue = Nothing
End Select
End Sub
End Class

View File

@@ -0,0 +1,132 @@
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language
Imports DigitalData.GUIs.Monitor.Constants
Public Class SearchLoader
Inherits BaseClass
Private ReadOnly Config As Config
Private ReadOnly Database As MSSQLServer
Public Searches As New List(Of Search)
Public Parameters As New List(Of SearchParameter)
Public Sub New(pLogConfig As LogConfig, pConfig As Config, pDatabase As MSSQLServer)
MyBase.New(pLogConfig)
Config = pConfig
Database = pDatabase
End Sub
Public Sub LoadSearches()
Try
Searches.Clear()
Dim oSQL = $"SELECT * FROM TBMON_PROFILE WHERE ACTIVE = 1 ORDER BY SEQUENCE"
Dim oTable = Database.GetDatatable(oSQL)
For Each oRow As DataRow In oTable.Rows
Dim oSearchId = oRow.ItemEx("GUID", 0)
Dim oParams = Parameters.
Where(Function(param) param.SearchId = oSearchId).
OrderBy(Function(param) param.Sequence).
ToList()
Dim oSearch = New Search With {
.Id = oSearchId,
.Title = oRow.ItemEx("TITLE", String.Empty),
.Description = oRow.ItemEx("CAPTION", String.Empty),
.ReturnType = GetReturnType(oRow.ItemEx("RETURN_TYPE", String.Empty)),
.SQLCommand = oRow.ItemEx("EXEC_SQL", String.Empty),
.Parameters = oParams
}
' Erzeuge einen Titel, falls der leer ist
If oSearch.Title.Length <= 0 Then
Logger.Warn($"For searchId [{0}] an empty title were defined!", oSearch.Id)
oSearch.Title = "Suche " + oSearch.Id.ToString
End If
' Es wurde kein SQL Command definiert, ohne geht nix
If oSearch.SQLCommand Is Nothing Or oSearch.SQLCommand.Length = 0 Then
Logger.Error($"For searchId [{0}] is NO SQLCommand defined!", oSearch.Id)
Continue For
End If
' Anzahl der erwarteten Parameter
oSearch.ExpectedParameterCount = oSearch.SQLCommand.Split({"#CTRL#"}, StringSplitOptions.None).Length - 1
Searches.Add(oSearch)
Next
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
End Sub
Public Sub LoadSearchParameters()
Dim oSQL As String = $"SELECT * FROM TBMON_PROFILE_PARAM WHERE ACTIVE = 1"
Dim oTable As DataTable = Database.GetDatatable(oSQL)
Dim oParameters As New List(Of SearchParameter)
For Each oRow As DataRow In oTable.Rows
oParameters.Add(New SearchParameter With {
.Id = oRow.ItemEx("GUID", 0),
.Title = oRow.ItemEx("CAPTION", String.Empty),
.Description = oRow.ItemEx("DESCRIPTION", String.Empty),
.DataType = GetDataType(oRow.ItemEx("DATA_TYPE", "VARCHAR")),
.ItemString = oRow.ItemEx("ITEMS", String.Empty),
.ItemType = GetItemType(oRow.ItemEx("ITEM_TYPE", String.Empty)),
.Required = oRow.ItemEx("REQUIRED", True),
.PatternTitle = oRow.ItemEx("PATTERN", String.Empty),
.SearchId = oRow.ItemEx("PROFILE_ID", 0),
.DefaultValue = oRow.ItemEx("DEFAULT_VALUE", String.Empty),
.Sequence = oRow.ItemEx("SEQUENCE", 0)
})
Next
Parameters = oParameters
End Sub
Private Function GetItemType(pTypeString As String) As ItemTypeEnum
Select Case pTypeString
Case "LIST"
Return ItemTypeEnum.List
Case "SQL"
Return ItemTypeEnum.SQL
Case Else
Return ItemTypeEnum.Undefined
End Select
End Function
Private Function GetReturnType(pTypeString As String) As ReturnTypeEnum
Select Case pTypeString
Case "Table"
Return ReturnTypeEnum.Table
Case "TreeView"
Return ReturnTypeEnum.TreeView
Case Else
Return ReturnTypeEnum.Undefined
End Select
End Function
Private Function GetDataType(pTypeString As String) As DataTypeEnum
Select Case pTypeString
Case "BIT"
Return DataTypeEnum.Boolean
Case "VARCHAR"
Return DataTypeEnum.String
Case "INT"
Return DataTypeEnum.Integer
Case "DATE"
Return DataTypeEnum.Date
Case Else
Return DataTypeEnum.Undefined
End Select
End Function
End Class

View File

@@ -0,0 +1,79 @@
Imports DevExpress.Utils
Imports DevExpress.Utils.VisualEffects
Imports DevExpress.XtraLayout
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
Public Class Validator
Inherits BaseClass
Public Sub New(pLogConfig As LogConfig, pLayoutControl As LayoutControl, pAdornerUIManager As AdornerUIManager, pControlHelper As ControlHelper)
MyBase.New(pLogConfig)
Me.LayoutControl = pLayoutControl
Me.AdornerUIManager = pAdornerUIManager
Me.ControlHelper = pControlHelper
End Sub
Public ReadOnly Property LayoutControl As LayoutControl
Public ReadOnly Property AdornerUIManager As AdornerUIManager
Public ReadOnly Property ControlHelper As ControlHelper
Public Function Validate(pSearch As Search) As Boolean
With AdornerUIManager.ValidationHintProperties
.State = ValidationHintState.Invalid
.InvalidState.ShowBorder = True
.InvalidState.ShowBackgroundMode = ValidationHintBackgroundMode.Target
End With
AdornerUIManager.Hide()
AdornerUIManager.Elements.Clear()
Dim oMissingParams As Boolean = False
Dim oControls As New List(Of Control)
For Each oItem As Control In LayoutControl.Controls
Dim oParam = pSearch.Parameters.
Where(Function(param) param.PatternTitle = oItem.Name).
FirstOrDefault()
If oParam Is Nothing Then
Continue For
End If
oControls.Add(oItem)
If oParam.Required And Not ControlHelper.HasValue(oItem) Then
AdornerUIManager.Elements.Add(New ValidationHint With {
.TargetElement = oItem,
.Visible = True
})
oMissingParams = True
End If
Next
AdornerUIManager.Show()
Return oMissingParams
End Function
Public Function GetControlsWithParams(pSearch As Search) As List(Of Control)
Dim oControls As New List(Of Control)
For Each oItem As Control In LayoutControl.Controls
Dim oParam = pSearch.Parameters.
Where(Function(param) param.PatternTitle = oItem.Name).
FirstOrDefault()
If oParam Is Nothing Then
Continue For
End If
oControls.Add(oItem)
Next
Return oControls
End Function
End Class