1534 lines
58 KiB
VB.net
1534 lines
58 KiB
VB.net
Imports System.Drawing.Imaging
|
|
Imports System.IO
|
|
Imports System.Text.RegularExpressions
|
|
Imports DevExpress.LookAndFeel
|
|
Imports DevExpress.Utils
|
|
Imports DevExpress.XtraBars
|
|
Imports DevExpress.XtraCharts
|
|
Imports DevExpress.XtraEditors
|
|
Imports DevExpress.XtraEditors.Controls
|
|
Imports DevExpress.XtraEditors.Repository
|
|
Imports DevExpress.XtraGrid
|
|
Imports DevExpress.XtraGrid.Columns
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
Imports DevExpress.XtraRichEdit
|
|
Imports DevExpress.XtraTab
|
|
Imports DevExpress.XtraTreeList
|
|
Imports DevExpress.XtraTreeList.Columns
|
|
Imports DevExpress.XtraTreeList.Nodes
|
|
Imports DigitalData.Controls.DocumentViewer
|
|
Imports DigitalData.GUIs.Common
|
|
Imports DigitalData.GUIs.Monitor.Constants
|
|
Imports DigitalData.Modules.Base
|
|
Imports DigitalData.Modules.Config
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.Modules.Language.Utils
|
|
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Patterns
|
|
|
|
|
|
Public Class frmMonitor
|
|
Private ReadOnly InvisibleColumnMarkers As New List(Of String) From {"[HTML]", "[SQL]", "[FILENAME]"}
|
|
Private ReadOnly VisibleColumnMarkers As New List(Of String) From {"[SEARCH|"}
|
|
|
|
Private ReadOnly SQLColumns As New List(Of String) From {"SELECT1", "SELECT2", "SELECT3", "SELECT4"}
|
|
Private ReadOnly DocViewColumns As New List(Of String) From {"DOCVIEW1", "DOCVIEW2"}
|
|
Private ReadOnly Property HtmlViewColumns As New List(Of String) From {"HTML1", "HTML2"}
|
|
Private ReadOnly Property DataColumns As List(Of String) = SQLColumns.
|
|
Concat(DocViewColumns).
|
|
Concat(HtmlViewColumns).
|
|
ToList
|
|
|
|
Private Enum TristateBoolean
|
|
[False]
|
|
[True]
|
|
Indeterminate
|
|
End Enum
|
|
|
|
Private ReadOnly DisplayColumns As New List(Of String) From {"COLUMN1", "COLUMN2", "COLUMN3", "ADDED_WHEN", "STATE", "ICON"}
|
|
|
|
Private SQLResultGrids As List(Of GridControl)
|
|
Private SQLResultTabs As List(Of XtraTabPage)
|
|
'Private SQLResultGridIndex As Integer = 0
|
|
Private ActiveSQLResultGrid As GridControl
|
|
|
|
Private FileResultViewers As List(Of DocumentViewer)
|
|
Private FileResultTabs As List(Of XtraTabPage)
|
|
'Private FileResultViewerIndex As Integer = 0
|
|
|
|
Private HtmlResultViewers As List(Of RichEditControl)
|
|
Private HtmlResultTabs As List(Of XtraTabPage)
|
|
|
|
Private TreeListResults As TreeList
|
|
Private GridControlResults As GridControl
|
|
Private GridViewResults As GridView
|
|
|
|
Private ChartViewResultContainer As SplitContainerControl
|
|
|
|
Private InvisibleMarkedColumns As New List(Of GridColumn)
|
|
Private VisibleMarkedColumns As New List(Of GridColumn)
|
|
Private ActiveSearch As Search = Nothing
|
|
Private HyperLinkColumnSearchIds As New Dictionary(Of String, Integer)
|
|
|
|
Private GridBuilder As GridBuilder
|
|
Private ControlHelper As Common.ControlHelper
|
|
Private SearchLoader As SearchLoader
|
|
Private ParamLoader As ParameterLoader
|
|
Private LogConfig As LogConfig
|
|
Private Logger As Logger
|
|
Private ConfigManager As ConfigManager(Of Config)
|
|
Private Database As MSSQLServer
|
|
Private FormHelper As FormHelper
|
|
Private Patterns As Patterns2
|
|
Private Workspace As Common.DocumentResultList.Workspace(Of Config)
|
|
|
|
Private SplitContainerBuilderHTML As SplitContainerBuilder
|
|
Private SplitContainerBuilderSQL As SplitContainerBuilder
|
|
|
|
Private Validator As Validator
|
|
Private GridLoader As GridLoader
|
|
|
|
Private SelectedChart As ChartControl
|
|
|
|
Private SkinMode As SkinModeEnum
|
|
|
|
Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Try
|
|
|
|
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "Monitor")
|
|
Logger = LogConfig.GetLogger()
|
|
|
|
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath, Application.StartupPath)
|
|
ConfigManager.Config.Debug = LogConfig.Debug
|
|
|
|
Patterns = New Patterns2(LogConfig)
|
|
FormHelper = New FormHelper(LogConfig, Me)
|
|
ControlHelper = New Common.ControlHelper(LogConfig)
|
|
Workspace = New DocumentResultList.Workspace(Of Config)(LogConfig, ConfigManager, WorkspaceManager1)
|
|
|
|
SplitContainerBuilderHTML = New SplitContainerBuilder(LogConfig, Me, SplitContainerFileHTML)
|
|
SplitContainerBuilderHTML.InitAutoResize()
|
|
|
|
SplitContainerBuilderSQL = New SplitContainerBuilder(LogConfig, Me, SplitContainerSQL)
|
|
SplitContainerBuilderSQL.InitAutoResize()
|
|
|
|
If ConfigManager.Config.ConnectionString = String.Empty Then
|
|
Dim oSQLConfig As New frmSQLConfig(LogConfig)
|
|
If oSQLConfig.ShowDialog() = DialogResult.OK Then
|
|
ConfigManager.Config.ConnectionString = oSQLConfig.ConnectionString
|
|
ConfigManager.Save()
|
|
Application.Restart()
|
|
Else
|
|
FormHelper.ShowErrorMessage(New ApplicationException("No Database configured. Application will close!"), "Form Load")
|
|
Application.Exit()
|
|
|
|
End If
|
|
End If
|
|
|
|
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
|
Database = New MSSQLServer(LogConfig, oConnectionString)
|
|
SearchLoader = New SearchLoader(LogConfig, ConfigManager.Config, Database)
|
|
ParamLoader = New ParameterLoader(LogConfig, Database, LayoutControl1)
|
|
GridBuilder = New GridBuilder()
|
|
Validator = New Validator(LogConfig, LayoutControl1, AdornerUIManager2, ControlHelper)
|
|
GridLoader = New GridLoader(LogConfig, SvgImageCollection1)
|
|
|
|
btnDarkMode.Visibility = BarItemVisibility.Never ' DarkMode ist erstmal aus
|
|
ribbonGroupEinstellungen.Visible = False
|
|
'If ConfigManager.Config.DarkMode = False Then
|
|
SkinMode = SkinModeEnum.LightMode
|
|
'Else
|
|
'SkinMode = SkinModeEnum.DarkMode
|
|
'End If
|
|
'SetDarkMode()
|
|
|
|
AddHandler GridLoader.ChartControlClicked, AddressOf ChartControl_Click
|
|
|
|
InitGrid()
|
|
InitTreeList()
|
|
InitChartContainer()
|
|
InitBarItems()
|
|
|
|
Dim oGrids As GridView() = New List(Of GridView) From {GridView1, GridView2, GridView3, GridView4}.ToArray
|
|
GridBuilder.SetDefaults(oGrids)
|
|
GridBuilder.SetClipboardHandler(oGrids)
|
|
GridBuilder.SetReadOnlyOptions(oGrids)
|
|
|
|
SQLResultGrids = New List(Of GridControl) From {GridControl1, GridControl2, GridControl3, GridControl4}
|
|
SQLResultTabs = New List(Of XtraTabPage) From {XtraTabPageSQL1, XtraTabPageSQL2, XtraTabPageSQL3, XtraTabPageSQL4}
|
|
|
|
FileResultViewers = New List(Of DocumentViewer) From {DocumentViewer1, DocumentViewer2}
|
|
FileResultTabs = New List(Of XtraTabPage) From {XtraTabPageFile1, XtraTabPageFile2}
|
|
|
|
HtmlResultViewers = New List(Of RichEditControl) From {RichEditControl1, RichEditControl2}
|
|
HtmlResultTabs = New List(Of XtraTabPage) From {XtraTabPageHtml1, XtraTabPageHtml2}
|
|
|
|
LoadSearches()
|
|
|
|
Dim oLicense = LoadGDPicture()
|
|
|
|
For Each oGrid In SQLResultGrids
|
|
AddHandler oGrid.Enter, Sub()
|
|
ActiveSQLResultGrid = oGrid
|
|
btnExportDetails.Enabled = True
|
|
End Sub
|
|
|
|
AddHandler oGrid.Leave, Sub()
|
|
ActiveSQLResultGrid = Nothing
|
|
btnExportDetails.Enabled = False
|
|
End Sub
|
|
Next
|
|
|
|
For Each oViewer As DocumentViewer In FileResultViewers
|
|
oViewer.Init(LogConfig, oLicense)
|
|
Next
|
|
SplitContainerSQL.Collapsed = True
|
|
SplitContainerFileHTML.Collapsed = True
|
|
|
|
SetResultCount(0)
|
|
SetSearchTimeValue("")
|
|
SetVersion()
|
|
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "frmStart_Load")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Function LoadGDPicture() As String
|
|
Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
|
|
Return CStr(Database.GetScalarValue(oSQL))
|
|
End Function
|
|
|
|
|
|
Private Async Sub buttonSearch_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonSearch.ItemClick
|
|
Await LoadData()
|
|
End Sub
|
|
|
|
Private Async Function LoadData() As Threading.Tasks.Task(Of Boolean)
|
|
Try
|
|
SplashScreenManager1.ShowWaitForm()
|
|
|
|
TreeListResults.DataSource = Nothing
|
|
GridControlResults.DataSource = Nothing
|
|
|
|
If cmbSearches.EditValue Is Nothing Then
|
|
Return False
|
|
End If
|
|
|
|
Dim oSearch As Search = CType(cmbSearches.EditValue, Search)
|
|
|
|
InvisibleMarkedColumns.Clear()
|
|
VisibleMarkedColumns.Clear()
|
|
HyperLinkColumnSearchIds.Clear()
|
|
HideAllTabs()
|
|
|
|
Dim oMissingParams = Validator.Validate(oSearch)
|
|
If oMissingParams = True Then
|
|
Return False
|
|
End If
|
|
|
|
If oSearch.ExpectedParameterCount > 0 And oSearch.Parameters.Count <> oSearch.ExpectedParameterCount Then
|
|
Logger.Error($"[{0}] parameter were defined, but [{1}] parameter were expected!", oSearch.Parameters.Count, oSearch.ExpectedParameterCount)
|
|
FormHelper.ShowErrorMessage("Die Suche erwartet mehr Parameter als definiert wurden!", "LoadSearches")
|
|
Return False
|
|
End If
|
|
|
|
Dim oControls As List(Of Control) = LayoutControl1.Controls.Cast(Of Control).ToList()
|
|
Dim oSQL As String
|
|
Dim oTable As DataTable = Nothing
|
|
|
|
If oSearch.SQLCommand.Length > 0 Then
|
|
oSQL = Patterns.ReplaceControlValues(oSearch.SQLCommand, oControls)
|
|
Logger.Debug($"SQL after replacing placeholder: [{0}]", oSQL)
|
|
oTable = Await Database.GetDatatableAsync(oSQL)
|
|
End If
|
|
|
|
Dim oStartTime = Now
|
|
|
|
If oSearch.ReturnType = ReturnTypeEnum.TreeView Then
|
|
|
|
' Baum
|
|
SetResultVisbility(ReturnTypeEnum.TreeView)
|
|
|
|
If oTable Is Nothing Then
|
|
Return False
|
|
End If
|
|
|
|
TreeListResults.DataSource = oTable
|
|
|
|
Dim oMaxLength = 0
|
|
For Each oRow As DataRow In oTable.Rows
|
|
Dim oProcess = oRow.Item("COLUMN1")
|
|
Dim oLength = oProcess.ToString.Length
|
|
If oLength > oMaxLength Then
|
|
oMaxLength = oLength
|
|
End If
|
|
Next
|
|
|
|
GridLoader.InitTreeListColumns(TreeListResults, oMaxLength)
|
|
|
|
' Show all columns in DisplayColumns List
|
|
For Each oColumn In TreeListResults.Columns
|
|
oColumn.Visible = DisplayColumns.Contains(oColumn.FieldName)
|
|
Next
|
|
GridBuilder.SetDateTimeColumns(TreeListResults)
|
|
|
|
Dim oStateColumn As TreeListColumn = TreeListResults.Columns.Item("STATE")
|
|
For Each oNode As TreeListNode In TreeListResults.Nodes
|
|
ExpandNodes(oNode, Function(n)
|
|
Dim oObjectValue = n.GetValue(oStateColumn)
|
|
Dim oValue As String = NotNull(oObjectValue.ToString, String.Empty)
|
|
Return oValue IsNot Nothing AndAlso (oValue = State.STATE_WARNING Or oValue = State.STATE_FAILURE)
|
|
End Function)
|
|
Next
|
|
|
|
For Each oNode As TreeListNode In TreeListResults.Nodes
|
|
SetExpandedForChildNodes(oNode)
|
|
Next
|
|
|
|
SetResultCount(TreeListResults.AllNodesCount)
|
|
|
|
TreeListResults.Focus()
|
|
ElseIf oSearch.ReturnType = Constants.ReturnTypeEnum.ChartView Then
|
|
' Charts
|
|
SetResultVisbility(ReturnTypeEnum.ChartView)
|
|
|
|
' Oberer SplitContainer
|
|
Dim splitContainer1 As SplitContainerControl = CType(ChartViewResultContainer.Panel1.Controls(0), SplitContainerControl)
|
|
' Unterer SplitContainer
|
|
Dim splitContainer2 As SplitContainerControl = CType(ChartViewResultContainer.Panel2.Controls(0), SplitContainerControl)
|
|
|
|
ChartViewResultContainer.PanelVisibility = SplitPanelVisibility.Both
|
|
splitContainer1.PanelVisibility = SplitPanelVisibility.Both
|
|
splitContainer2.PanelVisibility = SplitPanelVisibility.Both
|
|
|
|
Dim chartArray(4) As ChartControl
|
|
' TopLeft
|
|
chartArray(0) = CType(splitContainer1.Panel1.Controls(0), ChartControl)
|
|
' TopRight
|
|
chartArray(1) = CType(splitContainer1.Panel2.Controls(0), ChartControl)
|
|
' BottomLeft
|
|
chartArray(2) = CType(splitContainer2.Panel1.Controls(0), ChartControl)
|
|
' BottomRight
|
|
chartArray(3) = CType(splitContainer2.Panel2.Controls(0), ChartControl)
|
|
|
|
For i As Integer = 0 To 3
|
|
chartArray(i).Titles.Clear()
|
|
chartArray(i).Series.Clear()
|
|
Next
|
|
ResizeCharContainer()
|
|
|
|
Dim oChartParameters As List(Of ChartParameter)
|
|
oChartParameters = SearchLoader.ChartParameters.Where(Function(p) p.SearchId = oSearch.Id And p.ChartType <> ChartTypeEnum.Undefined).ToList()
|
|
|
|
For Each oChartParameterSet In oChartParameters
|
|
Dim ChartViewResults As ChartControl
|
|
|
|
Select Case oChartParameterSet.ChartPos
|
|
Case ChartPosEnum.TopLeft
|
|
ChartViewResults = chartArray(0)
|
|
Case ChartPosEnum.TopRight
|
|
ChartViewResults = chartArray(1)
|
|
Case ChartPosEnum.BottomLeft
|
|
ChartViewResults = chartArray(2)
|
|
Case ChartPosEnum.BottomRight
|
|
ChartViewResults = chartArray(3)
|
|
Case Else
|
|
ChartViewResults = chartArray(0)
|
|
End Select
|
|
|
|
SetChartTitle(ChartViewResults, oChartParameterSet.Title)
|
|
SetChartDesign(ChartViewResults, oChartParameterSet.DesignType, oChartParameterSet.DesignBaseColor)
|
|
Dim oSerie As Series = Await GetChartSerie(oChartParameterSet, oControls)
|
|
ChartViewResults.Series.Add(oSerie)
|
|
Next
|
|
|
|
SetPanelVisibility(chartArray)
|
|
|
|
ChartViewResultContainer.Focus()
|
|
|
|
Else
|
|
' Tabelle
|
|
SetResultVisbility(ReturnTypeEnum.Table)
|
|
|
|
If oTable Is Nothing Then
|
|
Return False
|
|
End If
|
|
|
|
GridControlResults.DataSource = oTable
|
|
GridViewResults.PopulateColumns()
|
|
GridBuilder.SetDateTimeColumns(GridViewResults)
|
|
|
|
For Each oColumn As GridColumn In GridViewResults.Columns
|
|
If oColumn.ColumnType = GetType(Integer) Then
|
|
oColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center
|
|
End If
|
|
Next
|
|
|
|
InvisibleMarkedColumns = GridViewResults.Columns.AsEnumerable.
|
|
Where(Function(column)
|
|
Dim oCaption = column.FieldName.ToUpper.Trim
|
|
Return InvisibleColumnMarkers.Any(Function(marker) oCaption.EndsWith(marker))
|
|
End Function).ToList()
|
|
|
|
For Each oColumn In InvisibleMarkedColumns
|
|
oColumn.VisibleIndex = -1
|
|
Next
|
|
|
|
VisibleMarkedColumns = GridViewResults.Columns.AsEnumerable.
|
|
Where(Function(column)
|
|
Dim oCaption = column.FieldName.ToUpper.Trim
|
|
Return VisibleColumnMarkers.Any(Function(marker) oCaption.Contains(marker))
|
|
End Function).ToList()
|
|
|
|
For Each oColumn In VisibleMarkedColumns
|
|
If oColumn.FieldName.Contains("[SEARCH|") Then
|
|
Dim oUrlEdit As New RepositoryItemHyperLinkEdit() With
|
|
{
|
|
.SingleClick = True
|
|
}
|
|
|
|
GridControlResults.RepositoryItems.Add(oUrlEdit)
|
|
|
|
For index = 0 To GridViewResults.Columns.Count - 1
|
|
If GridViewResults.Columns.Item(index).FieldName = oColumn.FieldName Then
|
|
GridViewResults.Columns.Item(index).ColumnEdit = oUrlEdit
|
|
|
|
' Column Caption setzen
|
|
Dim colTitle As String = oColumn.FieldName.Substring(0, oColumn.FieldName.IndexOf("["))
|
|
GridViewResults.Columns.Item(index).Caption = colTitle
|
|
|
|
' Add SearchId in Dictionary
|
|
HyperLinkColumnSearchIds.Add(oColumn.FieldName, GetSearchIdFromColumnFieldName(oColumn.FieldName))
|
|
End If
|
|
Next
|
|
|
|
AddHandler oUrlEdit.OpenLink, AddressOf HyperLinkEdit_OpenLinkAsync
|
|
End If
|
|
Next
|
|
|
|
SetColumnsToDisAllowEditInGridViewResults()
|
|
SetResultCount(GridViewResults.RowCount)
|
|
|
|
GridControlResults.Focus()
|
|
End If
|
|
|
|
GridViewResults.FocusInvalidRow()
|
|
GridViewResults.BestFitColumns()
|
|
|
|
Workspace.LoadWorkspace(oSearch.Id.ToString)
|
|
|
|
ActivateMenuBarButtons(oSearch.ReturnType)
|
|
|
|
Dim oTotalTime = Now.Subtract(oStartTime)
|
|
SetSearchTimeValue(oTotalTime.ToString("mm':'ss"))
|
|
|
|
Return True
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "LoadData")
|
|
Return False
|
|
Finally
|
|
SplashScreenManager1.CloseWaitForm()
|
|
End Try
|
|
End Function
|
|
|
|
Private Sub SetChartDesign(pChartView As ChartControl, pDesignType As DesignTypeEnum, pDesignBaseColor As Integer)
|
|
|
|
Select Case pDesignType
|
|
Case DesignTypeEnum.Aspect
|
|
pChartView.PaletteName = "Aspect"
|
|
Case DesignTypeEnum.Mixed
|
|
pChartView.PaletteName = "Mixed"
|
|
Case DesignTypeEnum.Office2013
|
|
pChartView.PaletteName = "Office 2013"
|
|
Case DesignTypeEnum.Solstice
|
|
pChartView.PaletteName = "Solstice"
|
|
Case DesignTypeEnum.DDDefault
|
|
pChartView.PaletteName = "DDDefault Palette"
|
|
Case Else
|
|
pChartView.PaletteName = "Office"
|
|
End Select
|
|
|
|
pChartView.PaletteBaseColorNumber = pDesignBaseColor
|
|
End Sub
|
|
|
|
Private Sub ActivateMenuBarButtons(pSearchType As ReturnTypeEnum)
|
|
Select Case pSearchType
|
|
Case ReturnTypeEnum.ChartView
|
|
btnExportMain.Enabled = False
|
|
BarButtonItem2.Enabled = False
|
|
btnResetLayout.Enabled = False
|
|
Case Else
|
|
btnExportMain.Enabled = True
|
|
BarButtonItem2.Enabled = True
|
|
btnResetLayout.Enabled = True
|
|
End Select
|
|
End Sub
|
|
|
|
Private Async Function GetChartSerie(pChartParameters As ChartParameter, pControls As List(Of Control)) As Threading.Tasks.Task(Of Series)
|
|
Dim oSerie As Series
|
|
|
|
Dim serieTitle As String
|
|
|
|
If String.IsNullOrEmpty(pChartParameters.SerieTitle) = False Then
|
|
serieTitle = pChartParameters.SerieTitle
|
|
Else
|
|
serieTitle = pChartParameters.Title
|
|
End If
|
|
|
|
Select Case pChartParameters.ChartType
|
|
Case ChartTypeEnum.Bar
|
|
oSerie = New Series(serieTitle, ViewType.Bar)
|
|
Case ChartTypeEnum.Line
|
|
oSerie = New Series(serieTitle, ViewType.Line)
|
|
Case ChartTypeEnum.Area
|
|
oSerie = New Series(serieTitle, ViewType.Area)
|
|
Case ChartTypeEnum.Pie
|
|
oSerie = New Series(serieTitle, ViewType.Pie) With {
|
|
.LegendTextPattern = "{A}"
|
|
}
|
|
Case ChartTypeEnum.StackedBar
|
|
oSerie = New Series(serieTitle, ViewType.StackedBar)
|
|
Case Else
|
|
Return Nothing
|
|
End Select
|
|
|
|
SetSerieLabels(oSerie, pChartParameters.ChartType, pChartParameters.LabelType)
|
|
|
|
Dim oSQL As String = Patterns.ReplaceControlValues(pChartParameters.SQLCommand, pControls)
|
|
Logger.Debug($"SQL after replacing placeholder: [{0}]", oSQL)
|
|
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSQL)
|
|
|
|
Dim xAxisTitle As String = pChartParameters.Argument
|
|
Dim yAxisTitle As String = pChartParameters.Value
|
|
|
|
For Each oRow In oTable.Rows
|
|
Dim value1 As String = CStr(oRow.Item(xAxisTitle))
|
|
Dim value2 As String = CStr(oRow.Item(yAxisTitle))
|
|
oSerie.Points.Add(New SeriesPoint(value1, value2))
|
|
Next
|
|
|
|
oSerie.ArgumentScaleType = ScaleType.Qualitative
|
|
|
|
Return oSerie
|
|
|
|
End Function
|
|
|
|
Private Sub SetSerieLabels(pSerie As Series, pChartType As ChartTypeEnum, pLabelType As LabelTypeEnum)
|
|
|
|
If (pLabelType = LabelTypeEnum.NoLabels) Then
|
|
pSerie.LabelsVisibility = DefaultBoolean.False
|
|
Exit Sub
|
|
End If
|
|
|
|
pSerie.LabelsVisibility = DefaultBoolean.True
|
|
pSerie.Label.TextPattern = "{V}"
|
|
|
|
Select Case pChartType
|
|
Case ChartTypeEnum.Bar
|
|
Dim barLabel As SideBySideBarSeriesLabel = TryCast(pSerie.Label, SideBySideBarSeriesLabel)
|
|
If barLabel IsNot Nothing Then
|
|
barLabel.Position = BarSeriesLabelPosition.Top
|
|
End If
|
|
Case ChartTypeEnum.Line
|
|
Dim lineLabel As PointSeriesLabel = TryCast(pSerie.Label, PointSeriesLabel)
|
|
If lineLabel IsNot Nothing Then
|
|
lineLabel.Position = PointLabelPosition.Outside
|
|
End If
|
|
Case ChartTypeEnum.Area
|
|
Dim areaLabel As PointSeriesLabel = TryCast(pSerie.Label, PointSeriesLabel)
|
|
If areaLabel IsNot Nothing Then
|
|
areaLabel.Position = PointLabelPosition.Outside
|
|
End If
|
|
Case ChartTypeEnum.Pie
|
|
Dim pieLabel As PieSeriesLabel = TryCast(pSerie.Label, PieSeriesLabel)
|
|
If pieLabel IsNot Nothing Then
|
|
pieLabel.Position = PieSeriesLabelPosition.Outside
|
|
End If
|
|
Case ChartTypeEnum.StackedBar
|
|
Dim stackedBarLabel As StackedBarSeriesLabel = TryCast(pSerie.Label, StackedBarSeriesLabel)
|
|
If stackedBarLabel IsNot Nothing Then
|
|
stackedBarLabel.Position = BarSeriesLabelPosition.Auto
|
|
End If
|
|
Case Else
|
|
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
Private Sub SetChartTitle(pChartView As ChartControl, pTitle As String)
|
|
' Wenn bereits ein Titel vorhanden ist, wird kein neuer ergänzt
|
|
' relevant bei mehrere Charts in einem ChartControl
|
|
If pChartView.Titles.Count = 0 Then
|
|
Dim oTitle As New ChartTitle With {
|
|
.Text = pTitle
|
|
}
|
|
pChartView.Titles.Add(oTitle)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetPanelVisibility(chartArray() As ChartControl)
|
|
If chartArray.Length < 4 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim showTop As Boolean = True
|
|
Dim showBottom As Boolean = True
|
|
|
|
If chartArray(0).Titles.Count = 0 And chartArray(1).Titles.Count = 0 Then
|
|
showTop = False
|
|
End If
|
|
|
|
If chartArray(2).Titles.Count = 0 And chartArray(3).Titles.Count = 0 Then
|
|
showBottom = False
|
|
End If
|
|
|
|
If showBottom = False Then
|
|
ChartViewResultContainer.PanelVisibility = SplitPanelVisibility.Panel1
|
|
ElseIf showTop = False Then
|
|
ChartViewResultContainer.PanelVisibility = SplitPanelVisibility.Panel2
|
|
End If
|
|
|
|
If showTop = True Then
|
|
Dim showLeft As Boolean = chartArray(0).Titles.Count > 0
|
|
Dim showRight As Boolean = chartArray(1).Titles.Count > 0
|
|
|
|
Dim splitContainer1 As SplitContainerControl = CType(ChartViewResultContainer.Panel1.Controls(0), SplitContainerControl)
|
|
|
|
If showRight = False Then
|
|
splitContainer1.PanelVisibility = SplitPanelVisibility.Panel1
|
|
ElseIf showLeft = False Then
|
|
splitContainer1.PanelVisibility = SplitPanelVisibility.Panel2
|
|
End If
|
|
End If
|
|
|
|
If showBottom = True Then
|
|
Dim showLeft As Boolean = chartArray(2).Titles.Count > 0
|
|
Dim showRight As Boolean = chartArray(3).Titles.Count > 0
|
|
|
|
Dim splitContainer2 As SplitContainerControl = CType(ChartViewResultContainer.Panel2.Controls(0), SplitContainerControl)
|
|
|
|
If showRight = False Then
|
|
splitContainer2.PanelVisibility = SplitPanelVisibility.Panel1
|
|
ElseIf showLeft = False Then
|
|
splitContainer2.PanelVisibility = SplitPanelVisibility.Panel2
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub SetResultVisbility(pSearchMode As ReturnTypeEnum)
|
|
Select Case pSearchMode
|
|
Case ReturnTypeEnum.TreeView
|
|
GridControlResults.Visible = False
|
|
GridControlResults.Dock = DockStyle.None
|
|
TreeListResults.Visible = True
|
|
TreeListResults.Dock = DockStyle.Fill
|
|
ChartViewResultContainer.Visible = False
|
|
ChartViewResultContainer.Dock = DockStyle.None
|
|
|
|
lbResultCount.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
|
|
|
EnableButtons(btnExportMain)
|
|
EnableButtons(btnExportDetails)
|
|
DisableButtons(btnExportChart2PDF)
|
|
DisableButtons(btnExportChart2PNG)
|
|
|
|
Case ReturnTypeEnum.ChartView
|
|
GridControlResults.Visible = False
|
|
GridControlResults.Dock = DockStyle.None
|
|
TreeListResults.Visible = False
|
|
TreeListResults.Dock = DockStyle.None
|
|
ChartViewResultContainer.Visible = True
|
|
ChartViewResultContainer.Dock = DockStyle.Fill
|
|
|
|
lbResultCount.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
|
|
|
|
DisableButtons(btnExportMain)
|
|
DisableButtons(btnExportDetails)
|
|
EnableButtons(btnExportChart2PDF)
|
|
EnableButtons(btnExportChart2PNG)
|
|
|
|
Case ReturnTypeEnum.Table
|
|
GridControlResults.Visible = True
|
|
GridControlResults.Dock = DockStyle.Fill
|
|
TreeListResults.Visible = False
|
|
TreeListResults.Dock = DockStyle.None
|
|
ChartViewResultContainer.Visible = False
|
|
ChartViewResultContainer.Dock = DockStyle.None
|
|
|
|
lbResultCount.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
|
|
|
|
EnableButtons(btnExportMain)
|
|
EnableButtons(btnExportDetails)
|
|
DisableButtons(btnExportChart2PDF)
|
|
DisableButtons(btnExportChart2PNG)
|
|
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
Private Sub DisableButtons(pBarButtonItem As BarButtonItem)
|
|
pBarButtonItem.Enabled = False
|
|
pBarButtonItem.Visibility = BarItemVisibility.Never
|
|
End Sub
|
|
|
|
Private Sub EnableButtons(pBarButtonItem As BarButtonItem)
|
|
pBarButtonItem.Enabled = True
|
|
pBarButtonItem.Visibility = BarItemVisibility.Always
|
|
End Sub
|
|
|
|
Private Sub InitBarItems()
|
|
btnExportMain.Visibility = BarItemVisibility.Always
|
|
btnExportMain.Enabled = False
|
|
btnExportDetails.Visibility = BarItemVisibility.Always
|
|
btnExportDetails.Enabled = False
|
|
DisableButtons(btnExportChart2PDF)
|
|
DisableButtons(btnExportChart2PNG)
|
|
|
|
lbResultCount.Visibility = BarItemVisibility.Never
|
|
lbSearchTime.Visibility = BarItemVisibility.Never
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Linklogik für Hyperlink-Spalten
|
|
''' </summary>
|
|
Private Async Function HyperLinkEdit_OpenLinkAsync(sender As Object, e As OpenLinkEventArgs) As Threading.Tasks.Task
|
|
Dim searchId As Integer = HyperLinkColumnSearchIds(GridViewResults.FocusedColumn.FieldName)
|
|
|
|
Dim oSearch As Search = SearchLoader.Searches.Where(Function(search) search.Id = searchId).SingleOrDefault()
|
|
cmbSearches.EditValue = oSearch ' Es wird jetzt erwartet, dass das ChangeValue-Event der ComboBox ausgelöst wird!
|
|
|
|
Dim oSearchParameter As SearchParameter = oSearch.Parameters.Where(Function(param) param.Required = True).FirstOrDefault()
|
|
|
|
If oSearchParameter Is Nothing And oSearch.ExpectedParameterCount > 0 Then
|
|
Logger.Error($"[{0}] parameter were defined, but [{1}] parameter were expected!", oSearch.Parameters.Count, oSearch.ExpectedParameterCount)
|
|
FormHelper.ShowErrorMessage("Die Suche erwartet 1 Parameter, aber es wurde kein Parameter gefunden!", "LoadSearches")
|
|
Return
|
|
Else
|
|
Dim oControl As Control = LayoutControl1.Controls.Find(oSearchParameter.PatternTitle, True).FirstOrDefault()
|
|
oControl.Text = CStr(e.EditValue)
|
|
End If
|
|
|
|
Await LoadData()
|
|
' e.EditValue = "www.google.de"
|
|
e.Handled = True
|
|
|
|
End Function
|
|
|
|
Private Function GetSearchIdFromColumnFieldName(pFieldName As String) As Integer
|
|
If String.IsNullOrEmpty(pFieldName) = True Then
|
|
Return 0
|
|
End If
|
|
|
|
Dim startIndex = pFieldName.IndexOf("|") + 1
|
|
Dim endIndex = pFieldName.IndexOf("]")
|
|
Dim length = endIndex - startIndex
|
|
Dim searchIdText = pFieldName.Substring(startIndex, length)
|
|
|
|
Dim retValue As Integer
|
|
|
|
If (Integer.TryParse(searchIdText, retValue) = False) Then
|
|
retValue = 0
|
|
End If
|
|
|
|
Return retValue
|
|
End Function
|
|
|
|
Private Sub SetColumnsToDisAllowEditInGridViewResults()
|
|
For Each oColumn As GridColumn In GridViewResults.Columns
|
|
|
|
If TypeOf oColumn.ColumnEdit IsNot RepositoryItemHyperLinkEdit Then
|
|
' Verbietet Spaltenweise die Bearbeitung
|
|
oColumn.OptionsColumn.AllowEdit = False
|
|
End If
|
|
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub SetExpandedForChildNodes(pRootNode As TreeListNode, Optional pDepth As Integer = 0)
|
|
If pDepth > 10 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
If CType(pRootNode.Item("PARENT_ID"), Int32) = 0 Then
|
|
' Auswertung für Parent-Knoten
|
|
ExpandCollapseNode(pRootNode)
|
|
End If
|
|
|
|
For Each oNode As TreeListNode In pRootNode.Nodes
|
|
Try
|
|
ExpandCollapseNode(oNode)
|
|
|
|
' Und rein in die Rekursion
|
|
SetExpandedForChildNodes(oNode, pDepth + 1)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
End Try
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub LoadSearches()
|
|
Try
|
|
SearchLoader.LoadSearchParameters()
|
|
SearchLoader.LoadChartParameters()
|
|
SearchLoader.LoadSearches()
|
|
|
|
cmbSearches.Properties.Items.Clear()
|
|
cmbSearches.Properties.Items.AddRange(SearchLoader.Searches)
|
|
|
|
If cmbSearches.EditValue IsNot Nothing Then
|
|
Dim oOldSearch As Search = DirectCast(cmbSearches.EditValue, Search)
|
|
Dim oNewSearch As Search = SearchLoader.Searches.Where(Function(search) search.Id = oOldSearch.Id).SingleOrDefault()
|
|
|
|
If oNewSearch IsNot Nothing Then
|
|
cmbSearches.EditValue = oNewSearch
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "LoadSearches")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub cmbSearches_SelectedValueChanged(sender As Object, e As EventArgs) Handles cmbSearches.SelectedValueChanged
|
|
DisposeTreeList()
|
|
InitTreeList()
|
|
|
|
DisposeGrid()
|
|
InitGrid()
|
|
|
|
DisposeCharts()
|
|
InitChartContainer()
|
|
|
|
SplitContainerSQL.Collapsed = True
|
|
SplitContainerFileHTML.Collapsed = True
|
|
|
|
btnExportMain.Enabled = False
|
|
btnExportDetails.Enabled = False
|
|
|
|
SetResultCount(0)
|
|
InitBarItems()
|
|
|
|
LoadSearch()
|
|
HideAllTabs()
|
|
End Sub
|
|
|
|
Private Sub LoadSearch()
|
|
Try
|
|
If TypeOf cmbSearches.SelectedItem IsNot Search Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oSearch As Search = CType(cmbSearches.SelectedItem, Search)
|
|
|
|
ActiveSearch = oSearch
|
|
|
|
AdornerUIManager2.Hide()
|
|
AdornerUIManager2.Elements.Clear()
|
|
|
|
' TODO - Hier passt etwas noch nicht
|
|
Root.Clear(disposeItemAndControls:=False)
|
|
LayoutControl1.Clear(True, True)
|
|
|
|
TreeListResults.DataSource = Nothing
|
|
GridControlResults.DataSource = Nothing
|
|
|
|
If oSearch.Parameters.Count = 0 Then
|
|
lbParams.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never
|
|
|
|
Else
|
|
lbParams.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always
|
|
|
|
End If
|
|
|
|
ParamLoader.LoadParameters(oSearch)
|
|
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Function GetParameterItems(pParam As SearchParameter) As Object
|
|
Select Case pParam.ItemType
|
|
Case Constants.ItemTypeEnum.List
|
|
Return pParam.ItemString.Split(";"c).ToList()
|
|
|
|
Case Constants.ItemTypeEnum.SQL
|
|
Dim oSQL = pParam.ItemString
|
|
Dim oTable = Database.GetDatatable(oSQL)
|
|
Return oTable
|
|
|
|
Case Else
|
|
Return Nothing
|
|
End Select
|
|
End Function
|
|
|
|
Private Sub TreeListResults_FocusedNodeChanged(sender As Object, e As DevExpress.XtraTreeList.FocusedNodeChangedEventArgs)
|
|
If e.Node Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Try
|
|
Dim oValues As Dictionary(Of String, String) = GetValuesFromNode(e.Node, DataColumns)
|
|
|
|
Dim oSQLCommands = oValues.
|
|
Where(Function(v) v.Key.StartsWith("SELECT")).
|
|
Where(Function(v) v.Value IsNot Nothing).
|
|
ToDictionary(Function(v) v.Key, Function(v) v.Value)
|
|
|
|
Dim oFilePaths = oValues.
|
|
Where(Function(v) v.Key.StartsWith("DOCVIEW")).
|
|
Where(Function(v) v.Value IsNot Nothing).
|
|
ToDictionary(Function(v) v.Key, Function(v) v.Value)
|
|
|
|
Dim oHtmlDocuments = oValues.
|
|
Where(Function(v) v.Key.StartsWith("HTML")).
|
|
Where(Function(v) v.Value IsNot Nothing).
|
|
ToDictionary(Function(v) v.Key, Function(v) v.Value)
|
|
|
|
Dim oAllTabs = SQLResultTabs.
|
|
Concat(FileResultTabs).
|
|
Concat(HtmlResultTabs)
|
|
For Each oTabPage In oAllTabs
|
|
oTabPage.PageVisible = False
|
|
Next
|
|
|
|
SplitContainerSQL.Collapsed = True
|
|
SplitContainerFileHTML.Collapsed = True
|
|
|
|
For Each oSQLCommand As KeyValuePair(Of String, String) In oSQLCommands
|
|
Try
|
|
Dim oExtracted = ExtractTitle(oSQLCommand.Value)
|
|
Dim oCommand = oExtracted.Item1
|
|
Dim oTitle = NotNull(oExtracted.Item2, oSQLCommand.Key)
|
|
|
|
Dim oTable As DataTable = Database.GetDatatable(oCommand)
|
|
|
|
If oTable Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim oGridIndex = Integer.Parse(oSQLCommand.Key.Last()) - 1
|
|
Dim oGridControl As GridControl = SQLResultGrids.Item(oGridIndex)
|
|
|
|
If oGridIndex = 0 Then
|
|
ActiveSQLResultGrid = oGridControl
|
|
End If
|
|
|
|
FillResultGrid(oGridControl, oTable, oTitle)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Continue For
|
|
End Try
|
|
Next
|
|
|
|
For Each oFile As KeyValuePair(Of String, String) In oFilePaths
|
|
Try
|
|
Dim oExtracted = ExtractTitle(oFile.Value)
|
|
Dim oPath = oExtracted.Item1
|
|
Dim oTitle = oExtracted.Item2
|
|
|
|
If oPath Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
If Not IO.File.Exists(oPath) Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim oViewerIndex = Integer.Parse(oFile.Key.Last()) - 1
|
|
Dim oViewer As DocumentViewer = FileResultViewers.Item(oViewerIndex)
|
|
|
|
FillResultViewer(oViewer, oPath, oTitle)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Continue For
|
|
End Try
|
|
Next
|
|
|
|
For Each oFile As KeyValuePair(Of String, String) In oHtmlDocuments
|
|
Try
|
|
Dim oExtracted = ExtractTitle(oFile.Value)
|
|
Dim oHtml = oExtracted.Item1
|
|
Dim oTitle = oExtracted.Item2
|
|
|
|
If oHtml Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim oViewerIndex = Integer.Parse(oFile.Key.Last()) - 1
|
|
Dim oViewer As RichEditControl = HtmlResultViewers.Item(oViewerIndex)
|
|
|
|
FillResultHtmlViewer(oViewer, oHtml, oTitle)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Continue For
|
|
End Try
|
|
Next
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "TreeListResults_FocusedNodeChanged")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Function ExtractTitle(pValue As String) As Tuple(Of String, String)
|
|
Dim oTitleRegex As New Regex("([\s\S]*)#&#([\s\S]*)#&#$")
|
|
|
|
If oTitleRegex.IsMatch(pValue) Then
|
|
Dim oMatch = oTitleRegex.Match(pValue)
|
|
|
|
Dim oValue = oMatch.Groups.Item(1).Value
|
|
Dim oTitle = oMatch.Groups.Item(2).Value
|
|
|
|
Return New Tuple(Of String, String)(oValue, oTitle)
|
|
Else
|
|
Return New Tuple(Of String, String)(pValue, Nothing)
|
|
End If
|
|
End Function
|
|
|
|
Private Sub ExpandNodes(RootNode As TreeListNode, Condition As Predicate(Of TreeListNode))
|
|
For Each oNode As TreeListNode In RootNode.Nodes
|
|
ExpandNodes(oNode, Condition)
|
|
|
|
If Condition(oNode) = True Then
|
|
oNode.Expand()
|
|
ExpandParentNode(oNode)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub ExpandParentNode(ChildNode As TreeListNode)
|
|
If ChildNode.ParentNode IsNot Nothing Then
|
|
ChildNode.ParentNode.Expand()
|
|
ExpandParentNode(ChildNode.ParentNode)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ExpandCollapseNode(pNode As TreeListNode)
|
|
Dim oExpanded As TristateBoolean = NotNull(pNode.Item("EXPANDED"), TristateBoolean.Indeterminate)
|
|
Select Case oExpanded
|
|
Case TristateBoolean.False
|
|
pNode.Collapse()
|
|
Case TristateBoolean.True
|
|
pNode.Expand()
|
|
Case Else
|
|
'noop
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub FillResultHtmlViewer(RichEditControl As RichEditControl, Html As String, Title As String)
|
|
RichEditControl.HtmlText = Html
|
|
|
|
Dim oTabPage = DirectCast(RichEditControl.Parent, XtraTabPage)
|
|
oTabPage.PageVisible = True
|
|
oTabPage.Text = NotNull(Title, oTabPage.Text)
|
|
|
|
XtraTabControlFileHTML.SelectedTabPage = oTabPage
|
|
End Sub
|
|
|
|
Private Sub FillResultViewer(DocumentViewer As DocumentViewer, Path As String, Title As String)
|
|
DocumentViewer.LoadFile(Path)
|
|
|
|
Dim oTabPage = DirectCast(DocumentViewer.Parent, XtraTabPage)
|
|
oTabPage.PageVisible = True
|
|
oTabPage.Text = NotNull(Title, oTabPage.Text)
|
|
|
|
XtraTabControlFileHTML.SelectedTabPage = oTabPage
|
|
End Sub
|
|
|
|
Private Sub FillResultGrid(GridControl As GridControl, Table As DataTable, Title As String)
|
|
|
|
|
|
GridControl.DataSource = Table
|
|
GridControl.DefaultView.PopulateColumns()
|
|
|
|
Dim oTabPage = DirectCast(GridControl.Parent, XtraTabPage)
|
|
oTabPage.PageVisible = True
|
|
oTabPage.Text = $"{NotNull(Title, oTabPage.Text)} ({Table.Rows.Count})"
|
|
|
|
XtraTabControlSQL.SelectedTabPage = oTabPage
|
|
End Sub
|
|
|
|
Private Function GetValuesFromNode(Node As TreeListNode, ColumnNames As List(Of String)) As Dictionary(Of String, String)
|
|
Dim oValues As New Dictionary(Of String, String)
|
|
|
|
For Each oColumnName In ColumnNames
|
|
Dim oValue = MaybeGetValueForColumn(Node, oColumnName)
|
|
oValues.Add(oColumnName, oValue)
|
|
Next
|
|
|
|
Return oValues
|
|
End Function
|
|
|
|
Private Function MaybeGetValueForColumn(Node As TreeListNode, FieldName As String) As String
|
|
Dim oColumn = TreeListResults.Columns.Item(FieldName)
|
|
|
|
If oColumn Is Nothing Then
|
|
Return Nothing
|
|
End If
|
|
|
|
Dim oValue = Node.GetValue(oColumn)?.ToString
|
|
|
|
If oValue Is String.Empty Then
|
|
Return Nothing
|
|
Else
|
|
Return oValue
|
|
End If
|
|
End Function
|
|
|
|
Private Sub TreeListResults_CustomDrawNodeCell(sender As Object, e As DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs)
|
|
Dim oColumn = TreeListResults.Columns.Item("STATE")
|
|
Dim oState = NotNull(e.Node.GetValue(oColumn), Nothing)
|
|
|
|
If oState Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oColor As Color = Nothing
|
|
|
|
Select Case oState.ToString
|
|
Case State.STATE_SUCCESS
|
|
oColor = Color.LightGreen
|
|
Case State.STATE_FAILURE
|
|
oColor = Color.LightCoral
|
|
Case State.STATE_WARNING
|
|
oColor = Color.Yellow
|
|
Case State.STATE_WAITING
|
|
oColor = Color.LightSkyBlue
|
|
End Select
|
|
|
|
e.Appearance.ForeColor = GraphicsEx.GetContrastedColor(oColor)
|
|
e.Appearance.BackColor = oColor
|
|
e.Appearance.Options.UseBackColor = True
|
|
e.Handled = False
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
|
Dim oSQLConfig As New frmSQLConfig(LogConfig) With {
|
|
.ConnectionString = ConfigManager.Config.ConnectionString
|
|
}
|
|
|
|
If oSQLConfig.ShowDialog() = DialogResult.OK Then
|
|
ConfigManager.Config.ConnectionString = oSQLConfig.ConnectionString
|
|
ConfigManager.Save()
|
|
|
|
Database = New MSSQLServer(LogConfig, oSQLConfig.ConnectionString)
|
|
|
|
LoadSearches()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExportDetails.ItemClick
|
|
If ActiveSQLResultGrid Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
XtraSaveFileDialog1.Filter = "Excel Files (*.xlsx)|*.xlsx"
|
|
XtraSaveFileDialog1.FileName = $"{ActiveSearch.Title}_Detail.xlsx"
|
|
|
|
If XtraSaveFileDialog1.ShowDialog() = DialogResult.OK Then
|
|
ActiveSQLResultGrid.ExportToXlsx(XtraSaveFileDialog1.FileName)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExportMain.ItemClick
|
|
If ActiveSearch Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
XtraSaveFileDialog1.Filter = "Excel Files (*.xlsx)|*.xlsx"
|
|
XtraSaveFileDialog1.FileName = $"{ActiveSearch.Title}.xlsx"
|
|
|
|
If XtraSaveFileDialog1.ShowDialog() = DialogResult.OK Then
|
|
If ActiveSearch.ReturnType = ReturnTypeEnum.TreeView Then
|
|
TreeListResults.ExportToXlsx(XtraSaveFileDialog1.FileName)
|
|
Else
|
|
GridControlResults.ExportToXlsx(XtraSaveFileDialog1.FileName)
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Async Sub frmMonitor_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
|
|
If e.KeyCode = Keys.F5 Then
|
|
Debug.Write("Debug.Write")
|
|
Console.WriteLine("Console.WriteLine")
|
|
Debug.Print("Debug.Print")
|
|
Await LoadData()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub TreeListResults_MouseClick(sender As Object, e As MouseEventArgs)
|
|
Dim oInfo As TreeListHitInfo = TreeListResults.CalcHitInfo(New Point(e.X, e.Y))
|
|
|
|
If oInfo.InRowCell Then
|
|
Dim oNode = oInfo.Node
|
|
Dim oValues As Dictionary(Of String, String) = GetValuesFromNode(oNode, DataColumns)
|
|
Console.WriteLine()
|
|
|
|
Dim oShouldToggleSQL = False
|
|
Dim oShouldToggleFile = False
|
|
|
|
For Each oValue As KeyValuePair(Of String, String) In oValues
|
|
If oValue.Key.Contains("SELECT") AndAlso oValue.Value IsNot Nothing Then
|
|
oShouldToggleSQL = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
For Each oValue As KeyValuePair(Of String, String) In oValues
|
|
If oValue.Key.Contains("DOCVIEW") AndAlso oValue.Value IsNot Nothing Then
|
|
oShouldToggleFile = True
|
|
Exit For
|
|
End If
|
|
|
|
If oValue.Key.Contains("HTML") AndAlso oValue.Value IsNot Nothing Then
|
|
oShouldToggleFile = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If oShouldToggleSQL Then
|
|
SplitContainerSQL.Collapsed = Not SplitContainerSQL.Collapsed
|
|
End If
|
|
|
|
If oShouldToggleFile Then
|
|
SplitContainerFileHTML.Collapsed = Not SplitContainerFileHTML.Collapsed
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadSearches.ItemClick
|
|
Try
|
|
LoadSearches()
|
|
|
|
TreeListResults.DataSource = Nothing
|
|
GridControlResults.DataSource = Nothing
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "Suchen neu laden")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub GridViewResults_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs)
|
|
If GridViewResults.FocusedRowHandle < 0 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
HideAllTabs()
|
|
ActiveSQLResultGrid = Nothing
|
|
|
|
Try
|
|
Dim oRow As DataRow = GridViewResults.GetDataRow(GridViewResults.FocusedRowHandle)
|
|
Dim oHtmlResultViewerIndex As Integer = 0
|
|
Dim oGridResultIndex As Integer = 0
|
|
Dim oViewerResultIndex As Integer = 0
|
|
|
|
For Each oColumn As GridColumn In InvisibleMarkedColumns
|
|
|
|
Dim oValue = oRow.ItemEx(oColumn.FieldName, String.Empty)
|
|
|
|
If oValue.Length > 0 Then
|
|
|
|
If oColumn.FieldName.EndsWith("[HTML]") Then
|
|
|
|
Dim oViewer As RichEditControl = HtmlResultViewers.Item(oHtmlResultViewerIndex)
|
|
Dim oTitle = oColumn.FieldName.Replace("[HTML]", "").Trim()
|
|
oHtmlResultViewerIndex += 1
|
|
FillResultHtmlViewer(oViewer, oValue, oTitle)
|
|
SplitContainerFileHTML.Collapsed = False
|
|
|
|
ElseIf oColumn.FieldName.EndsWith("[SQL]") Then
|
|
|
|
Dim oTable As DataTable = Database.GetDatatable(oValue)
|
|
If oTable Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim oTitle = oColumn.FieldName.Replace("[SQL]", "").Trim()
|
|
Dim oGridControl As GridControl = SQLResultGrids.Item(oGridResultIndex)
|
|
|
|
If oGridResultIndex = 0 Then
|
|
ActiveSQLResultGrid = oGridControl
|
|
End If
|
|
|
|
oGridResultIndex += 1
|
|
|
|
FillResultGrid(oGridControl, oTable, oTitle)
|
|
SplitContainerSQL.Collapsed = False
|
|
|
|
ElseIf oColumn.FieldName.EndsWith("[FILENAME]") Then
|
|
|
|
If oValue Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
If Not IO.File.Exists(oValue) Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim oViewer As DocumentViewer = FileResultViewers.Item(oViewerResultIndex)
|
|
Dim oTitle = oColumn.FieldName.Replace("[FILENAME]", "").Trim()
|
|
|
|
oViewerResultIndex += 1
|
|
FillResultViewer(oViewer, oValue, oTitle)
|
|
SplitContainerFileHTML.Collapsed = False
|
|
End If
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
If ActiveSQLResultGrid Is Nothing Then
|
|
btnExportDetails.Enabled = False
|
|
Else
|
|
btnExportDetails.Enabled = True
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub GridViewResults_ColumnFilterChanged(sender As Object, e As EventArgs)
|
|
Dim oView As GridView = CType(sender, GridView)
|
|
SetResultCount(oView.DataRowCount)
|
|
End Sub
|
|
|
|
Private Sub HideAllTabs()
|
|
Dim oAllTabs = SQLResultTabs.
|
|
Concat(FileResultTabs).
|
|
Concat(HtmlResultTabs)
|
|
For Each oTabPage In oAllTabs
|
|
oTabPage.PageVisible = False
|
|
Next
|
|
|
|
SplitContainerSQL.Collapsed = True
|
|
SplitContainerFileHTML.Collapsed = True
|
|
End Sub
|
|
|
|
Private Async Sub btnResetLayout_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnResetLayout.ItemClick
|
|
If ActiveSearch IsNot Nothing Then
|
|
Workspace.ResetWorkspace(ActiveSearch.Id.ToString)
|
|
|
|
DisposeTreeList()
|
|
InitTreeList()
|
|
|
|
DisposeGrid()
|
|
InitGrid()
|
|
|
|
DisposeCharts()
|
|
InitChartContainer()
|
|
|
|
HideAllTabs()
|
|
Await LoadData()
|
|
|
|
SetResultCount(0)
|
|
InitBarItems()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DisposeGrid()
|
|
GridViewResults.Dispose()
|
|
GridViewResults = Nothing
|
|
GridControlResults.Dispose()
|
|
GridControlResults = Nothing
|
|
End Sub
|
|
|
|
Private Sub DisposeCharts()
|
|
ChartViewResultContainer.Dispose()
|
|
ChartViewResultContainer = Nothing
|
|
End Sub
|
|
|
|
Private Sub SetResultCount(pResults As Integer)
|
|
lbResultCount.Caption = String.Format(CStr(lbResultCount.Tag), pResults)
|
|
End Sub
|
|
|
|
Private Sub SetSearchTimeValue(pValue As String)
|
|
If pValue.Equals("00:00") Then
|
|
lbSearchTime.Caption = ""
|
|
Else
|
|
lbSearchTime.Caption = pValue
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetVersion()
|
|
lbVersion.Caption = String.Format(CStr(lbVersion.Tag), System.Reflection.Assembly.GetEntryAssembly().GetName().Version)
|
|
End Sub
|
|
|
|
Private Sub InitGrid()
|
|
GridControlResults = GridLoader.InitGrid()
|
|
GridViewResults = DirectCast(GridControlResults.DefaultView, GridView)
|
|
|
|
AddHandler GridViewResults.FocusedRowChanged, AddressOf GridViewResults_FocusedRowChanged
|
|
AddHandler GridViewResults.ColumnFilterChanged, AddressOf GridViewResults_ColumnFilterChanged
|
|
|
|
SplitContainerSQL.Panel1.Controls.Add(GridControlResults)
|
|
End Sub
|
|
|
|
Private Sub DisposeTreeList()
|
|
TreeListResults.Dispose()
|
|
TreeListResults = Nothing
|
|
End Sub
|
|
|
|
Private Sub InitTreeList()
|
|
TreeListResults = GridLoader.InitTreeList()
|
|
|
|
AddHandler TreeListResults.FocusedNodeChanged, AddressOf TreeListResults_FocusedNodeChanged
|
|
AddHandler TreeListResults.MouseClick, AddressOf TreeListResults_MouseClick
|
|
AddHandler TreeListResults.CustomDrawNodeCell, AddressOf TreeListResults_CustomDrawNodeCell
|
|
|
|
SplitContainerSQL.Panel1.Controls.Add(TreeListResults)
|
|
End Sub
|
|
|
|
Private Sub InitChartContainer()
|
|
ChartViewResultContainer = GridLoader.InitChartViewResultContainer()
|
|
SplitContainerSQL.Panel1.Controls.Add(ChartViewResultContainer)
|
|
SelectedChart = Nothing
|
|
End Sub
|
|
|
|
Private Sub ResizeCharContainer()
|
|
If ChartViewResultContainer.Visible = True Then
|
|
Dim splitContainer1 As SplitContainerControl = CType(ChartViewResultContainer.Panel1.Controls(0), SplitContainerControl)
|
|
Dim splitContainer2 As SplitContainerControl = CType(ChartViewResultContainer.Panel2.Controls(0), SplitContainerControl)
|
|
|
|
ChartViewResultContainer.SplitterPosition = CInt(ChartViewResultContainer.Height / 2)
|
|
splitContainer1.SplitterPosition = CInt(splitContainer1.Width / 2)
|
|
splitContainer2.SplitterPosition = CInt(splitContainer2.Width / 2)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem2_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
|
If ActiveSearch Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Workspace.SaveWorkspace(ActiveSearch.Id.ToString)
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem3_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
|
Try
|
|
Process.Start(LogConfig.LogDirectory)
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "Log Verzeichnis öffnen")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub ChartControl_Click(sender As Object, e As EventArgs)
|
|
SelectedChart = CType(sender, ChartControl)
|
|
End Sub
|
|
|
|
Private Sub btnExportChart2PDF_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExportChart2PDF.ItemClick
|
|
Try
|
|
If Not IsNothing(SelectedChart) Then
|
|
XtraSaveFileDialog1.Filter = "PDF Files (*.pdf*)|*.pdf"
|
|
XtraSaveFileDialog1.FileName = SelectedChart.Titles(0).ToString()
|
|
If XtraSaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
|
|
ExportChart2Pdf(SelectedChart, XtraSaveFileDialog1.FileName)
|
|
End If
|
|
Else
|
|
FormHelper.ShowInfoMessage("Bitte einen Chart auswählen", "Chart Export per PDF")
|
|
End If
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "Chart Export nach PDF")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnExportChart2PNG_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExportChart2PNG.ItemClick
|
|
Try
|
|
If Not IsNothing(SelectedChart) Then
|
|
XtraSaveFileDialog1.Filter = "PNG Files (*.png*)|*.png"
|
|
XtraSaveFileDialog1.FileName = SelectedChart.Titles(0).ToString()
|
|
If XtraSaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
|
|
ExportChartToImage(SelectedChart, XtraSaveFileDialog1.FileName)
|
|
End If
|
|
Else
|
|
FormHelper.ShowInfoMessage("Bitte einen Chart auswählen", "Chart Export per PNG")
|
|
End If
|
|
Catch ex As Exception
|
|
FormHelper.ShowErrorMessage(ex, "Chart Export nach PNG")
|
|
End Try
|
|
End Sub
|
|
|
|
Sub ExportChart2Pdf(pMyChart As ChartControl, pFilePath As String)
|
|
Try
|
|
pMyChart.OptionsPrint.ImageFormat = DevExpress.XtraCharts.Printing.PrintImageFormat.Metafile
|
|
pMyChart.ExportToPdf(pFilePath, New DevExpress.XtraPrinting.PdfExportOptions With {
|
|
.ConvertImagesToJpeg = False
|
|
})
|
|
' Exports to a stream as PDF.
|
|
Dim pdfStream As FileStream = New FileStream(pFilePath, FileMode.Create)
|
|
pMyChart.ExportToPdf(pdfStream)
|
|
' ...
|
|
pdfStream.Close()
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Sub ExportChartToImage(pMyChart As ChartControl, pFilePath As String)
|
|
Try
|
|
SaveChartImageToFile(pMyChart, ImageFormat.Png, pFilePath)
|
|
Dim image As Image = GetChartImage(pMyChart, ImageFormat.Png)
|
|
image.Save(pFilePath)
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub SaveChartImageToFile(ByVal chart As ChartControl, ByVal format As ImageFormat, ByVal fileName As String)
|
|
' Create an image in the specified format from the chart
|
|
' and save it to the specified path.
|
|
chart.ExportToImage(fileName, format)
|
|
End Sub
|
|
|
|
Private Function GetChartImage(ByVal chart As ChartControl, ByVal format As ImageFormat) As Image
|
|
' Create an image.
|
|
Dim image As Image = Nothing
|
|
|
|
' Create an image of the chart.
|
|
Using s As New MemoryStream()
|
|
chart.ExportToImage(s, format)
|
|
image = System.Drawing.Image.FromStream(s)
|
|
End Using
|
|
|
|
' Return the image.
|
|
Return image
|
|
End Function
|
|
|
|
Private Sub btnDarkMode_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnDarkMode.ItemClick
|
|
SwitchDarkMode()
|
|
End Sub
|
|
|
|
Private Sub frmMonitor_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
If SkinMode = SkinModeEnum.LightMode Then
|
|
ConfigManager.Config.DarkMode = False
|
|
Else
|
|
ConfigManager.Config.DarkMode = True
|
|
End If
|
|
ConfigManager.Save()
|
|
|
|
End Sub
|
|
|
|
Private Sub SwitchDarkMode()
|
|
If SkinMode = SkinModeEnum.LightMode Then
|
|
WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinSvgPalette.DefaultSkin.BlueDark)
|
|
SkinMode = SkinModeEnum.DarkMode
|
|
|
|
Else
|
|
WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinSvgPalette.DefaultSkin.Default)
|
|
SkinMode = SkinModeEnum.LightMode
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetDarkMode()
|
|
If SkinMode = SkinModeEnum.LightMode Then
|
|
WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinSvgPalette.DefaultSkin.Default)
|
|
Else
|
|
WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinSvgPalette.DefaultSkin.BlueDark)
|
|
End If
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
|