URL-Links in Tabellen-Views. Umstrukturierung
This commit is contained in:
132
GUIs.Monitor/Helper/SearchLoader.vb
Normal file
132
GUIs.Monitor/Helper/SearchLoader.vb
Normal 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
|
||||
Reference in New Issue
Block a user