This commit is contained in:
2021-01-11 09:35:33 +01:00
parent bc54fc0211
commit 60a5e03a21
5 changed files with 107 additions and 7 deletions

View File

@@ -1,5 +1,8 @@
Imports DigitalData.Modules.Logging
Imports DevExpress.XtraEditors
Imports DigitalData.GUIs.Common
Imports DevExpress.XtraSplashScreen
Public Class frmFlowSearch
Private Logger As Logger
Private FontLargeBold As New Font("Segoe UI", 10, FontStyle.Bold)
@@ -9,6 +12,7 @@ Public Class frmFlowSearch
Dim oLastAttribute As String = ""
Dim oAttributeCount As Integer = 1
Dim BASE_SSEARCHCommand As String
Private LastSearchForm As frmDocumentResultList
Public Sub New(pBaseSearchSql As String)
@@ -37,7 +41,7 @@ Public Class frmFlowSearch
Sub SearchContent(oSearchValue As String)
oLastAttribute = ""
Dim oSQL = BASE_SSEARCHCommand.Replace("@SEARCH_STRING", oSearchValue)
Dim oResultCount As Integer = 0
TileControlMatch.Groups.Clear()
Dim ODT As DataTable = My.DatabaseIDB.GetDatatable(oSQL)
@@ -48,19 +52,20 @@ Public Class frmFlowSearch
Dim oGroups = ODT.AsEnumerable().GroupBy(Function(row) row.Field(Of String)("ATTRIBUTE"))
Dim oNewTable As New DataTable
oNewTable.Columns.Add("ATTRIBUTE")
oNewTable.Columns.Add("COUNT", Type.GetType("System.Int16"))
oNewTable.Columns.Add("COUNT", Type.GetType("System.Int32"))
For Each oGroup In oGroups
oNewTable.Rows.Add(oGroup.Key, oGroup.Sum(Function(row) row.Field(Of Int32)("COUNT_OBJ")))
Next
If Not IsNothing(oNewTable) Then
Dim oAttrCount As Integer = 0
Dim oResultCount As Integer = 0
For Each orow As DataRow In oNewTable.Rows
oAttrCount += 1
oResultCount += orow.Item(1)
Next
lblFoundResult.Text = GetResultString(oResultCount, oAttrCount, oSearchValue)
lblFoundResult.Visible = True
End If
oNewTable.DefaultView.Sort = "COUNT ASC"
oNewTable = oNewTable.DefaultView.ToTable
@@ -77,13 +82,74 @@ Public Class frmFlowSearch
Next
TileControlMatch.Groups.Add(oGroup)
Next
Dim oTESTTABLE As DataTable = My.DatabaseIDB.GetDatatable("EXEC PRSEARCH_RUN1 '3',1,1")
'Wenn weniger als 45 Belege gefunden wurden wird direkt die Suche ausgeführt
If oResultCount > 0 And oResultCount <= 45 Then
StartSearch_Full(oSearchValue)
End If
Else
lblFoundResult.Text = "Result from DB Is Nothing..Check SQL"
lblFoundResult.Visible = True
End If
End Sub
Private Function StartSearch_Full(pSearchValue As String) As Boolean
Dim oHandle As IOverlaySplashScreenHandle = Nothing
Dim oItemsFound As Boolean = False
Try
oHandle = SplashScreenManager.ShowOverlayForm(Me)
Dim oEXECSQL = $"EXEC PRFLOW_SEARCH_GET_RESULT '{pSearchValue}',{My.Application.User.UserId},'{SEARCH_STRING_ATTRID}','{SEARCH_INTEGER_ATTRID}'"
Dim oDTOBJECT_RESULT As DataTable = My.DatabaseIDB.GetDatatable(oEXECSQL)
If Not IsNothing(oDTOBJECT_RESULT) Then
Dim oEnvironment As New Modules.ZooFlow.Environment() With {
.User = My.Application.User,
.Modules = My.Application.Modules,
.Database = My.Database,
.DatabaseIDB = My.DatabaseIDB,
.Settings = My.Application.Settings,
.Service = My.Application.Service
}
Dim oShortGuid = Guid.NewGuid()
Dim oWindowGuid = $"FLOWSEARCH-{My.User.Name}"
Dim oParams = New DocumentResultParams() With {
.WindowGuid = oWindowGuid,
.Results = New List(Of DocumentResult) From {
New DocumentResult() With {
.Title = "FlowSearchResult",
.Datatable = oDTOBJECT_RESULT
}
}
}
Dim oForm As New frmDocumentResultList(My.LogConfig, oEnvironment, oParams)
oForm.Show()
LastSearchForm = oForm
' Position Result Window below this window
LastSearchForm.Location = GetResultFormLocation()
LastSearchForm.Size = GetResultFormSize()
oItemsFound = True
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
Finally
SplashScreenManager.CloseOverlayForm(oHandle)
End Try
Return oItemsFound
End Function
Private Function GetResultFormLocation() As Point
Return Location
End Function
Private Function GetResultFormSize() As Size
Return Size
End Function
Private Function GetResultString(CountObjects, CountAttribute, SearchContent) As String
Dim oResultString = $"wurden {CountObjects} Objekte" ' IIf(CountAttribute = 1, $"wurden {CountObjects} Objekte", $"wurden {CountObjects} Objekte in {CountAttribute} Attributen")
Dim oProfileString = IIf(CountAttribute = 1, "einem Attribut", $"{CountAttribute} Attributen")