ZooFlow: Clean up, faster search
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DigitalData.Modules.Language.Utils
|
||||
Imports DigitalData.Modules.Patterns
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.GUIs.Common
|
||||
Imports DigitalData.Modules.ZooFlow.Params
|
||||
|
||||
Public Class ProfileSearches
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Logger As Logger
|
||||
Inherits BaseClass
|
||||
|
||||
Private _Environment As Environment
|
||||
Private _Client As Client
|
||||
|
||||
@@ -22,10 +26,10 @@ Public Class ProfileSearches
|
||||
Public SQLCommand As String
|
||||
End Class
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Environment As Environment, pClipboardContents As String)
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Environment = Environment
|
||||
Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pClipboardContents As String)
|
||||
MyBase.New(pLogConfig)
|
||||
|
||||
_Environment = pEnvironment
|
||||
_ClipboardContents = pClipboardContents
|
||||
Try
|
||||
If _Environment.Service.IsActive = True Then
|
||||
@@ -36,22 +40,47 @@ Public Class ProfileSearches
|
||||
If oSplit.Length = 2 Then
|
||||
oAppServerPort = oSplit(1)
|
||||
End If
|
||||
_Client = New Client(LogConfig, oAppServerAddress, oAppServerPort)
|
||||
_Client = New Client(pLogConfig, oAppServerAddress, oAppServerPort)
|
||||
If Not IsNothing(_Client) Then
|
||||
If _Client.Connect() Then
|
||||
_Logger.Debug("ProfileSearches: Appserver connected successfully!")
|
||||
Logger.Debug("ProfileSearches: Appserver connected successfully!")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Warn($"Could not initialize the AppServer: {ex.Message}")
|
||||
_Logger.Error(ex)
|
||||
Logger.Warn($"Could not initialize the AppServer: {ex.Message}")
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Async Function GetDocResultForm(pProfile As ProfileData, pFormTitle As String, pOperationMode As Modules.ZooFlow.Constants.OperationMode) As Task(Of frmDocumentResultList)
|
||||
' For now we assume these are document results instead of data results
|
||||
Dim oSearches = Await LoadDocumentSearchesAsync(pProfile.Guid)
|
||||
|
||||
Dim oNameSlug = ConvertTextToSlug(pProfile.Name)
|
||||
Dim oSearchGuids = oSearches.Select(Function(s) s.Guid).ToArray
|
||||
Dim oWindowGuid = $"{pProfile.Guid}-{oNameSlug}-{String.Join("-", oSearchGuids)}"
|
||||
Dim oParams = New DocumentResultList.Params() With {
|
||||
.WindowGuid = oWindowGuid,
|
||||
.WindowTitle = pFormTitle,
|
||||
.OperationModeOverride = pOperationMode,
|
||||
.ProfileGuid = pProfile.Guid
|
||||
}
|
||||
|
||||
For Each oSearch In oSearches
|
||||
oParams.Results.Add(New DocumentResultList.DocumentResult() With {
|
||||
.Title = oSearch.TabCaption,
|
||||
.Datatable = oSearch.DataTable
|
||||
})
|
||||
Next
|
||||
|
||||
Dim oForm As New frmDocumentResultList(LogConfig, _Environment, oParams)
|
||||
Return oForm
|
||||
End Function
|
||||
|
||||
Public Async Function LoadDocumentSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
|
||||
Return Await Task.Run(Function()
|
||||
Return DoLoadDocumentSearches(ProfileId)
|
||||
@@ -65,7 +94,7 @@ Public Class ProfileSearches
|
||||
Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DOC_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX")
|
||||
oSearchesDataTable = oTableResult.Table
|
||||
If oSearchesDataTable Is Nothing Then
|
||||
_Logger.Warn("TBCW_PROF_DOC_SEARCH from AppServer is nothing: Failover started...")
|
||||
Logger.Warn("TBCW_PROF_DOC_SEARCH from AppServer is nothing: Failover started...")
|
||||
oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
|
||||
End If
|
||||
Else
|
||||
@@ -74,7 +103,7 @@ Public Class ProfileSearches
|
||||
Dim oDocSearches As New List(Of Search)
|
||||
If Not IsNothing(oSearchesDataTable) Then
|
||||
Dim oCounter As Integer = 0
|
||||
Dim oPatterns As New ClassPatterns(_LogConfig)
|
||||
Dim oPatterns As New ClassPatterns(LogConfig)
|
||||
|
||||
For Each oRow As DataRow In oSearchesDataTable.Rows
|
||||
Dim oProfileId As Integer = oRow.Item("PROFILE_ID")
|
||||
@@ -92,7 +121,7 @@ Public Class ProfileSearches
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
_Logger.Warn("Error in SQL-Query '{0}'", oSQL)
|
||||
Logger.Warn("Error in SQL-Query '{0}'", oSQL)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
@@ -132,7 +161,7 @@ Public Class ProfileSearches
|
||||
Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DATA_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX")
|
||||
oSearchesDataTable = oTableResult.Table
|
||||
If oSearchesDataTable Is Nothing Then
|
||||
_Logger.Warn("TBCW_PROF_DATA_SEARCH from AppServer is nothing: Failover started...")
|
||||
Logger.Warn("TBCW_PROF_DATA_SEARCH from AppServer is nothing: Failover started...")
|
||||
oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
|
||||
End If
|
||||
Else
|
||||
@@ -140,7 +169,7 @@ Public Class ProfileSearches
|
||||
End If
|
||||
|
||||
Dim oCounter As Integer = 0
|
||||
Dim oPatterns As New ClassPatterns(_LogConfig)
|
||||
Dim oPatterns As New ClassPatterns(LogConfig)
|
||||
|
||||
For Each oRow As DataRow In oSearchesDataTable.Rows
|
||||
Try
|
||||
@@ -158,7 +187,7 @@ Public Class ProfileSearches
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
_Logger.Warn("Error in SQL-Query '{0}'", oSQL)
|
||||
Logger.Warn("Error in SQL-Query '{0}'", oSQL)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
@@ -172,7 +201,7 @@ Public Class ProfileSearches
|
||||
|
||||
oCounter += 1
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
@@ -180,7 +209,7 @@ Public Class ProfileSearches
|
||||
Where(Function(s) Not IsNothing(s.DataTable)).
|
||||
ToList()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Return oDataSearches
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Reference in New Issue
Block a user