URL-Links in Tabellen-Views. Umstrukturierung
This commit is contained in:
parent
d4d3933bf6
commit
d841c4b414
@ -4,6 +4,7 @@
|
||||
Public Description As String
|
||||
Public SQLCommand As String
|
||||
Public ReturnType As Constants.ReturnTypeEnum
|
||||
Public ExpectedParameterCount As Integer
|
||||
|
||||
Public Parameters As List(Of SearchParameter)
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Runtime.CompilerServices
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports DevExpress.XtraEditors.Repository
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
@ -19,7 +22,9 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Patterns
|
||||
|
||||
Public Class frmMonitor
|
||||
Private ReadOnly ColumnMarkers As New List(Of String) From {"[HTML]", "[SQL]", "[FILENAME]"}
|
||||
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"}
|
||||
@ -52,8 +57,10 @@ Public Class frmMonitor
|
||||
Private GridControlResults As GridControl
|
||||
Private GridViewResults As GridView
|
||||
|
||||
Private MarkedColumns As New List(Of GridColumn)
|
||||
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
|
||||
@ -73,6 +80,7 @@ Public Class frmMonitor
|
||||
Private Validator As Validator
|
||||
Private GridLoader As GridLoader
|
||||
|
||||
|
||||
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")
|
||||
@ -132,7 +140,6 @@ Public Class frmMonitor
|
||||
|
||||
LoadSearches()
|
||||
|
||||
|
||||
Dim oLicense = LoadGDPicture()
|
||||
|
||||
For Each oGrid In SQLResultGrids
|
||||
@ -186,13 +193,19 @@ Public Class frmMonitor
|
||||
|
||||
Dim oSearch As Search = cmbSearches.EditValue
|
||||
|
||||
MarkedColumns.Clear()
|
||||
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
|
||||
|
||||
@ -264,16 +277,49 @@ Public Class frmMonitor
|
||||
End If
|
||||
Next
|
||||
|
||||
MarkedColumns = GridViewResults.Columns.AsEnumerable.
|
||||
InvisibleMarkedColumns = GridViewResults.Columns.AsEnumerable.
|
||||
Where(Function(column)
|
||||
Dim oCaption = column.FieldName.ToUpper.Trim
|
||||
Return ColumnMarkers.Any(Function(marker) oCaption.EndsWith(marker))
|
||||
Return InvisibleColumnMarkers.Any(Function(marker) oCaption.EndsWith(marker))
|
||||
End Function).ToList()
|
||||
|
||||
For Each oColumn In MarkedColumns
|
||||
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()
|
||||
@ -297,6 +343,61 @@ Public Class frmMonitor
|
||||
SplashScreenManager1.CloseWaitForm()
|
||||
End Try
|
||||
End Function
|
||||
''' <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 = 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 Not TypeOf oColumn.ColumnEdit Is 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
|
||||
@ -758,7 +859,7 @@ Public Class frmMonitor
|
||||
Dim oGridResultIndex As Integer = 0
|
||||
Dim oViewerResultIndex As Integer = 0
|
||||
|
||||
For Each oColumn As GridColumn In MarkedColumns
|
||||
For Each oColumn As GridColumn In InvisibleMarkedColumns
|
||||
|
||||
Dim oValue = oRow.ItemEx(oColumn.FieldName, String.Empty)
|
||||
|
||||
@ -807,7 +908,6 @@ Public Class frmMonitor
|
||||
oViewerResultIndex += 1
|
||||
FillResultViewer(oViewer, oValue, oTitle)
|
||||
SplitContainerFileHTML.Collapsed = False
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
@ -1,4 +1,5 @@
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports DevExpress.XtraEditors.Repository
|
||||
Imports DevExpress.XtraGrid
|
||||
@ -75,8 +76,8 @@ Public Class GridLoader
|
||||
|
||||
GridBuilder.SetDefaults(oView)
|
||||
GridBuilder.SetClipboardHandler(oView)
|
||||
GridBuilder.SetReadOnlyOptions(oView)
|
||||
|
||||
' GridBuilder.SetReadOnlyOptions(oView)
|
||||
' TODO Spalten die nicht HyperLinks sind readonly machen
|
||||
Return oGrid
|
||||
End Function
|
||||
|
||||
@ -176,4 +177,5 @@ Public Class GridLoader
|
||||
|
||||
Return oStateEdit
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@ -33,14 +33,31 @@ Public Class SearchLoader
|
||||
OrderBy(Function(param) param.Sequence).
|
||||
ToList()
|
||||
|
||||
Searches.Add(New Search With {
|
||||
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)
|
||||
@ -135,33 +135,33 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApplicationEvents.vb" />
|
||||
<Compile Include="Config.vb" />
|
||||
<Compile Include="Data\Config.vb" />
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="frmMonitor.Designer.vb">
|
||||
<Compile Include="Forms\frmMonitor.Designer.vb">
|
||||
<DependentUpon>frmMonitor.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmMonitor.vb">
|
||||
<Compile Include="Forms\frmMonitor.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GridLoader.vb" />
|
||||
<Compile Include="Helper\GridLoader.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="ParameterLoader.vb" />
|
||||
<Compile Include="Search.vb" />
|
||||
<Compile Include="SearchLoader.vb" />
|
||||
<Compile Include="SearchParameter.vb" />
|
||||
<Compile Include="frmLoading.Designer.vb">
|
||||
<Compile Include="Helper\ParameterLoader.vb" />
|
||||
<Compile Include="Data\Search.vb" />
|
||||
<Compile Include="Helper\SearchLoader.vb" />
|
||||
<Compile Include="Data\SearchParameter.vb" />
|
||||
<Compile Include="Forms\frmLoading.Designer.vb">
|
||||
<DependentUpon>frmLoading.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmLoading.vb">
|
||||
<Compile Include="Forms\frmLoading.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Validator.vb" />
|
||||
<EmbeddedResource Include="frmMonitor.resx">
|
||||
<Compile Include="Helper\Validator.vb" />
|
||||
<EmbeddedResource Include="Forms\frmMonitor.resx">
|
||||
<DependentUpon>frmMonitor.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\licenses.licx" />
|
||||
@ -176,7 +176,7 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="frmLoading.resx">
|
||||
<EmbeddedResource Include="Forms\frmLoading.resx">
|
||||
<DependentUpon>frmLoading.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
@ -230,6 +230,7 @@
|
||||
<None Include="Resources\deletetable.svg" />
|
||||
<None Include="Resources\actions_reload.svg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user