Monitor: first prototype

This commit is contained in:
Jonathan Jenne
2021-05-26 14:45:14 +02:00
parent 826b1c41ec
commit 402f393e35
7 changed files with 143 additions and 29 deletions

View File

@@ -38,6 +38,7 @@ Public Class frmMonitor
Private SQLResultGrids As List(Of GridControl)
Private SQLResultTabs As List(Of XtraTabPage)
Private ActiveSQLResultGrid As GridControl
Private FileResultViewers As List(Of DocumentViewer)
Private FileResultTabs As List(Of XtraTabPage)
@@ -108,6 +109,19 @@ Public Class frmMonitor
Dim oLicense = LoadGDPicture()
For Each oGrid In SQLResultGrids
AddHandler oGrid.Enter, Sub()
ActiveSQLResultGrid = oGrid
BarButtonItem2.Enabled = True
End Sub
AddHandler oGrid.Leave, Sub()
ActiveSQLResultGrid = Nothing
BarButtonItem2.Enabled = False
End Sub
Next
For Each oViewer As DocumentViewer In FileResultViewers
oViewer.Init(LogConfig, oLicense)
Next
@@ -284,7 +298,11 @@ Public Class frmMonitor
For Each oSQLCommand As KeyValuePair(Of String, String) In oSQLCommands
Try
Dim oTable As DataTable = Database.GetDatatable(oSQLCommand.Value)
Dim oExtracted = ExtractTitle(oSQLCommand.Value)
Dim oCommand = oExtracted.Item1
Dim oTitle = oExtracted.Item2
Dim oTable As DataTable = Database.GetDatatable(oCommand)
If oTable Is Nothing Then
Continue For
@@ -293,7 +311,7 @@ Public Class frmMonitor
Dim oGridIndex = Integer.Parse(oSQLCommand.Key.Last()) - 1
Dim oGridControl As GridControl = SQLResultGrids.Item(oGridIndex)
FillResultGrid(oGridControl, oTable)
FillResultGrid(oGridControl, oTable, oTitle)
Catch ex As Exception
Logger.Error(ex)
Continue For
@@ -302,7 +320,9 @@ Public Class frmMonitor
For Each oFile As KeyValuePair(Of String, String) In oFilePaths
Try
Dim oPath = oFile.Value
Dim oExtracted = ExtractTitle(oFile.Value)
Dim oPath = oExtracted.Item1
Dim oTitle = oExtracted.Item2
If oPath Is Nothing Then
Continue For
@@ -315,7 +335,7 @@ Public Class frmMonitor
Dim oViewerIndex = Integer.Parse(oFile.Key.Last()) - 1
Dim oViewer As DocumentViewer = FileResultViewers.Item(oViewerIndex)
FillResultViewer(oViewer, oPath)
FillResultViewer(oViewer, oPath, oTitle)
Catch ex As Exception
Logger.Error(ex)
Continue For
@@ -324,7 +344,9 @@ Public Class frmMonitor
For Each oFile As KeyValuePair(Of String, String) In oHtmlDocuments
Try
Dim oHtml = oFile.Value
Dim oExtracted = ExtractTitle(oFile.Value)
Dim oHtml = oExtracted.Item1
Dim oTitle = oExtracted.Item2
If oHtml Is Nothing Then
Continue For
@@ -333,7 +355,7 @@ Public Class frmMonitor
Dim oViewerIndex = Integer.Parse(oFile.Key.Last()) - 1
Dim oViewer As RichEditControl = HtmlResultViewers.Item(oViewerIndex)
FillResultHtmlViewer(oViewer, oHtml)
FillResultHtmlViewer(oViewer, oHtml, oTitle)
Catch ex As Exception
Logger.Error(ex)
Continue For
@@ -341,6 +363,18 @@ Public Class frmMonitor
Next
End Sub
Private Function ExtractTitle(Value As String) As Tuple(Of String, String)
If Value.Contains("|"c) Then
Dim oSplit = Value.Split("|"c).ToList
Dim oValue = oSplit.First()
Dim oTitle = oSplit.Item(1)
Return New Tuple(Of String, String)(oValue, oTitle)
End If
Return New Tuple(Of String, String)(Value, Nothing)
End Function
Private Sub ExpandNodes(RootNode As TreeListNode, Condition As Predicate(Of TreeListNode))
For Each oNode As TreeListNode In RootNode.Nodes
ExpandNodes(oNode, Condition)
@@ -359,27 +393,33 @@ Public Class frmMonitor
End If
End Sub
Private Sub FillResultHtmlViewer(RichEditControl As RichEditControl, Html As String)
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)
XtraTabControl1.SelectedTabPage = oTabPage
End Sub
Private Sub FillResultViewer(DocumentViewer As DocumentViewer, Path As String)
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)
XtraTabControl1.SelectedTabPage = oTabPage
End Sub
Private Sub FillResultGrid(GridControl As GridControl, Table As DataTable)
Private Sub FillResultGrid(GridControl As GridControl, Table As DataTable, Title As String)
GridControl.DataSource = Table
Dim oTabPage = DirectCast(GridControl.Parent, XtraTabPage)
oTabPage.PageVisible = True
oTabPage.Text = NotNull(Title, oTabPage.Text)
XtraTabControl3.SelectedTabPage = oTabPage
End Sub
@@ -485,6 +525,16 @@ Public Class frmMonitor
LoadSearchKeys()
End If
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
If ActiveSQLResultGrid IsNot Nothing Then
XtraSaveFileDialog1.Filter = "Excel Files (*.xlsx)|*.xlsx"
If XtraSaveFileDialog1.ShowDialog() = DialogResult.OK Then
ActiveSQLResultGrid.ExportToXlsx(XtraSaveFileDialog1.FileName)
End If
End If
End Sub
End Class
Friend Class SearchKey