Improve Search, clean up
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports System.Threading.Tasks
|
||||
|
||||
Public Class SearchRunner
|
||||
Inherits BaseClass
|
||||
@@ -30,7 +31,7 @@ Public Class SearchRunner
|
||||
|
||||
Public Event NeedsRefresh As EventHandler(Of Integer)
|
||||
|
||||
Private _ActiveDateConstraint As String = String.Empty
|
||||
Private Property _ActiveDateConstraint As String = String.Empty
|
||||
Public ReadOnly Property ActiveDateConstraint As String
|
||||
Get
|
||||
Return _ActiveDateConstraint
|
||||
@@ -47,8 +48,8 @@ Public Class SearchRunner
|
||||
Public Property BaseSearchSQL As String
|
||||
Public Property ExplicitDate As Boolean = False
|
||||
|
||||
Private Environment As Environment
|
||||
Private SearchTitle As String
|
||||
Private ReadOnly Environment As Environment
|
||||
Private ReadOnly SearchTitle As String
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pSearchTitle As String)
|
||||
MyBase.New(pLogConfig)
|
||||
@@ -56,28 +57,46 @@ Public Class SearchRunner
|
||||
SearchTitle = pSearchTitle
|
||||
End Sub
|
||||
|
||||
Public Async Function Run(pSearchTerm As String) As Threading.Tasks.Task(Of SearchResult)
|
||||
Public Function Run(pDatatable As DataTable) As SearchResult
|
||||
Return Run(pDatatable, "Suche")
|
||||
End Function
|
||||
|
||||
Public Function Run(pDatatable As DataTable, pTitle As String) As SearchResult
|
||||
Dim oParams = GetParams(pTitle)
|
||||
oParams.Results.Add(New DocumentResultList.DocumentResult() With {
|
||||
.Title = pTitle,
|
||||
.Datatable = pDatatable
|
||||
})
|
||||
|
||||
If pDatatable.Rows.Count = 1 Then
|
||||
oParams.ShowFileList = False
|
||||
End If
|
||||
|
||||
Dim oForm As New frmDocumentResultList(My.LogConfig, Environment, oParams)
|
||||
|
||||
' TODO: Implement, not needed right now
|
||||
'AddHandler oForm.NeedsRefresh, AddressOf Form_NeedsRefresh
|
||||
|
||||
oForm.Show()
|
||||
|
||||
Return New SearchResult()
|
||||
End Function
|
||||
|
||||
Public Async Function Run(pSearchTerm As String) As Task(Of SearchResult)
|
||||
Dim oWindowTitle = GetResultWindowString(pSearchTerm)
|
||||
Return Await Run(pSearchTerm, Nothing, Nothing)
|
||||
End Function
|
||||
|
||||
|
||||
Public Async Function Run(pSearchTerm As String, pDateFrom As Date, pDateTo As Date) As Threading.Tasks.Task(Of SearchResult)
|
||||
If pDateFrom.Equals(Date.MinValue) = False Then
|
||||
ExplicitDate = True
|
||||
End If
|
||||
|
||||
Dim oSearchTerm = pSearchTerm
|
||||
Dim oParams = New DocumentResultList.Params() With {
|
||||
.WindowGuid = SearchTitle,
|
||||
.WindowTitle = GetResultWindowString(oSearchTerm),
|
||||
.OperationModeOverride = Modules.ZooFlow.Constants.OperationMode.ZooFlow,
|
||||
.ProfileGuid = 35452,
|
||||
.ColumnNames = New DocumentResultList.ColumnNames With {
|
||||
.ObjectIdColumn = "DocID"
|
||||
},
|
||||
.ShowBackNavigation = False
|
||||
}
|
||||
|
||||
Dim oP3 = $"{_ActiveDateAttribute}~{_ActiveDateConstraint}"
|
||||
Dim oWindowTitle = GetResultWindowString(pSearchTerm)
|
||||
Dim oParams = GetParams(oWindowTitle)
|
||||
Dim oDateConstraint = $"{_ActiveDateAttribute}~{_ActiveDateConstraint}"
|
||||
|
||||
If ExplicitDate Then
|
||||
Dim oDate2 As Date
|
||||
@@ -88,11 +107,11 @@ Public Class SearchRunner
|
||||
End If
|
||||
Dim oProc = $"EXEC PRIDB_SEARCH_ADD_USR_DATE {My.Application.User.UserId},'{pDateFrom}','{oDate2}'"
|
||||
If Await My.Database.ExecuteNonQueryIDBAsync(oProc) = True Then
|
||||
oP3 = $"{_ActiveDateAttribute}~DATEPART"
|
||||
oDateConstraint = $"{_ActiveDateAttribute}~DATEPART"
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim oSQL = $"EXEC PRIDB_SEARCH_TEXT_GET_RESULTS {My.Application.User.UserId},'{oSearchTerm}','{oP3}'"
|
||||
Dim oSQL = $"EXEC PRIDB_SEARCH_TEXT_GET_RESULTS {My.Application.User.UserId},'{oSearchTerm}','{oDateConstraint}'"
|
||||
|
||||
If Await My.Database.ExecuteNonQueryIDBAsync(oSQL) = True Then
|
||||
Dim oDTDocResult = Await My.Database.GetDatatableIDBAsync(BaseSearchSQL)
|
||||
@@ -113,26 +132,30 @@ Public Class SearchRunner
|
||||
|
||||
oForm.Show()
|
||||
|
||||
Return New SearchResult With {
|
||||
.OK = True
|
||||
}
|
||||
Return New SearchResult()
|
||||
Else
|
||||
'bsiStatus.Caption = "No Results"
|
||||
Return New SearchResult With {
|
||||
.OK = False,
|
||||
.ErrorMessage = "No Results"
|
||||
}
|
||||
Return New SearchResult("No Results")
|
||||
|
||||
End If
|
||||
Else
|
||||
'bsiStatus.Caption = "Error in FlowSearch - Check Your log"
|
||||
Return New SearchResult With {
|
||||
.OK = False,
|
||||
.ErrorMessage = "Error in FlowSearch - Check Your log"
|
||||
}
|
||||
Return New SearchResult("Error in FlowSearch - Check Your log")
|
||||
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
Private Function GetParams(pWindowTitle As String) As DocumentResultList.Params
|
||||
Dim oParams = New DocumentResultList.Params() With {
|
||||
.WindowGuid = SearchTitle,
|
||||
.WindowTitle = pWindowTitle,
|
||||
.OperationModeOverride = Modules.ZooFlow.Constants.OperationMode.ZooFlow,
|
||||
.ProfileGuid = 35452,
|
||||
.ColumnNames = New DocumentResultList.ColumnNames With {
|
||||
.ObjectIdColumn = "DocID"
|
||||
},
|
||||
.ShowBackNavigation = False
|
||||
}
|
||||
Return oParams
|
||||
End Function
|
||||
|
||||
Private Function GetResultWindowString(SearchContent As String) As String
|
||||
If SearchContent <> String.Empty Then
|
||||
@@ -201,6 +224,22 @@ Public Class SearchRunner
|
||||
|
||||
Public Class SearchResult
|
||||
Public OK As Boolean
|
||||
Public ErrorMessage As String
|
||||
Public ErrorMessage As String = String.Empty
|
||||
|
||||
''' <summary>
|
||||
''' Returns a positive Search Result
|
||||
''' </summary>
|
||||
Public Sub New()
|
||||
OK = True
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Returns a failed search result with an error message
|
||||
''' </summary>
|
||||
''' <param name="pMessage"></param>
|
||||
Public Sub New(pMessage As String)
|
||||
OK = False
|
||||
ErrorMessage = pMessage
|
||||
End Sub
|
||||
End Class
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user