Zooflow: Search
This commit is contained in:
@@ -58,14 +58,14 @@ Public Class SearchRunner
|
||||
Public Property ExplicitDate As Boolean = False
|
||||
|
||||
Private ReadOnly Environment As Environment
|
||||
Private ReadOnly SearchTitle As String
|
||||
Private ReadOnly SearchId As String
|
||||
Private ReadOnly UserId As Integer
|
||||
Private ReadOnly UserLanguage As String
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pSearchTitle As String)
|
||||
Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pSearchId As String)
|
||||
MyBase.New(pLogConfig)
|
||||
Environment = pEnvironment
|
||||
SearchTitle = pSearchTitle
|
||||
SearchId = pSearchId
|
||||
UserId = My.Application.User.UserId
|
||||
UserLanguage = My.Application.User.Language
|
||||
End Sub
|
||||
@@ -96,28 +96,42 @@ Public Class SearchRunner
|
||||
Return New SearchResult(pDatatable.Rows.Count)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Only search for Term. Used for sidebar quicksearch.
|
||||
''' </summary>
|
||||
Public Async Function RunWithSearchTerm(pSearchTerm As String) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing, Nothing)
|
||||
Return Await RunWithSearchTerm(New SearchOptions With {.SearchString = pSearchTerm})
|
||||
End Function
|
||||
|
||||
Public Async Function RunWithSearchTerm(pSearchTerm As String, pSearchTitle As String) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing, pSearchTitle)
|
||||
Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date, pSearchTitle As String) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(New SearchOptions With {.SearchString = pSearchTerm, .SearchTitle = pSearchTitle})
|
||||
End Function
|
||||
|
||||
Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(pSearchTerm, pDateFrom, pDateTo, Nothing, Nothing)
|
||||
Public Async Function RunWithTokens(pTokens As IEnumerable(Of Search.SearchToken.Token)) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(New SearchOptions With {.SearchTokens = pTokens})
|
||||
End Function
|
||||
|
||||
Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date, pSearchTokens As IEnumerable(Of Search.SearchToken.Token), pSearchTitle As String) As Task(Of SearchResult)
|
||||
Dim oWindowTitle = GetResultWindowString(pSearchTerm, pSearchTitle)
|
||||
|
||||
'Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date) As Task(Of SearchResult)
|
||||
' Return Await RunWithSearchTerm(pSearchTerm, pDateFrom, pDateTo, Nothing, Nothing)
|
||||
'End Function
|
||||
|
||||
Private Async Function RunWithSearchTerm(pOptions As SearchOptions) As Task(Of SearchResult)
|
||||
Dim oDateConstraint = Await GetDateConstraint(pOptions.DateFrom, pOptions.DateTo)
|
||||
Dim oWindowTitle = GetResultWindowString(pOptions.SearchString, pOptions.SearchTitle)
|
||||
Dim oParams = GetParams(oWindowTitle)
|
||||
Dim oDateConstraint = Await GetDateConstraint(pDateFrom, pDateTo)
|
||||
Dim oTokens = pOptions.SearchTokens
|
||||
Dim oSearchTerm = pOptions.SearchString
|
||||
|
||||
Await InsertSearchTokens(pSearchTokens)
|
||||
Dim oSQL
|
||||
|
||||
Dim oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{pSearchTerm}','{oDateConstraint}', '{UserLanguage}'"
|
||||
If pSearchTokens IsNot Nothing AndAlso pSearchTokens.Count > 0 Then
|
||||
If oTokens.Count > 0 Then
|
||||
Await InsertSearchTokens(oTokens)
|
||||
oSQL = $"EXEC PRIDB_SEARCH_GET_TOKEN_RESULT_DOCS {UserId}, '{oDateConstraint}', '{UserLanguage}'"
|
||||
ElseIf oSearchTerm IsNot Nothing Then
|
||||
oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{pOptions.SearchString}','{oDateConstraint}', '{UserLanguage}'"
|
||||
Else
|
||||
oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{String.Empty}','{oDateConstraint}', '{UserLanguage}'"
|
||||
End If
|
||||
|
||||
If Await My.Database.ExecuteNonQueryIDBAsync(oSQL) = True Then
|
||||
@@ -130,7 +144,7 @@ Public Class SearchRunner
|
||||
Dim oRowCount = oDTDocResult.Rows.Count
|
||||
If oRowCount > 0 Then
|
||||
oParams.Results.Add(New DocumentResultList.DocumentResult() With {
|
||||
.Title = SearchTitle,
|
||||
.Title = SearchId,
|
||||
.Datatable = oDTDocResult
|
||||
})
|
||||
|
||||
@@ -157,6 +171,8 @@ Public Class SearchRunner
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Async Function GetDateConstraint(pDateFrom As Date, pDateTo As Date) As Task(Of String)
|
||||
Dim oSimpleDateConstraint = $"{_ActiveDateAttribute}~{_ActiveDateConstraint}"
|
||||
Dim oExplicitConstraint = Await MaybeSetExplicitDateConstraint(pDateFrom, pDateTo)
|
||||
@@ -230,7 +246,7 @@ Public Class SearchRunner
|
||||
|
||||
Private Function GetParams(pWindowTitle As String) As DocumentResultList.Params
|
||||
Dim oParams = New DocumentResultList.Params() With {
|
||||
.WindowGuid = SearchTitle,
|
||||
.WindowGuid = SearchId,
|
||||
.WindowTitle = pWindowTitle,
|
||||
.OperationModeOverride = Modules.ZooFlow.Constants.OperationMode.ZooFlow,
|
||||
.ProfileGuid = 35452,
|
||||
@@ -242,25 +258,31 @@ Public Class SearchRunner
|
||||
Return oParams
|
||||
End Function
|
||||
|
||||
Private Function GetResultWindowString(SearchContent As String, pWindowTitle As String) As String
|
||||
If pWindowTitle IsNot Nothing Then
|
||||
Return pWindowTitle
|
||||
End If
|
||||
Private Function GetResultWindowString(pSearchContent As String, pWindowTitle As String) As String
|
||||
Dim oWindowString
|
||||
|
||||
If SearchContent <> String.Empty Then
|
||||
If My.Application.User.Language = State.UserState.LANG_DE_DE Then
|
||||
|
||||
Return $"Suche Nach '{SearchContent}'"
|
||||
Else
|
||||
Return $"Search For '{SearchContent}'"
|
||||
End If
|
||||
' This is the default title
|
||||
If UserLanguage = State.UserState.LANG_DE_DE Then
|
||||
oWindowString = $"Suche"
|
||||
Else
|
||||
If My.Application.User.Language = State.UserState.LANG_DE_DE Then
|
||||
Return $"Suche Datumsbegrenzt"
|
||||
oWindowString = $"Search"
|
||||
End If
|
||||
|
||||
' If a Search String is given, we might take this
|
||||
If pSearchContent <> String.Empty Then
|
||||
If UserLanguage = State.UserState.LANG_DE_DE Then
|
||||
Return $"Suche Nach '{pSearchContent}'"
|
||||
Else
|
||||
Return $"Search via date"
|
||||
Return $"Search For '{pSearchContent}'"
|
||||
End If
|
||||
End If
|
||||
|
||||
' Window Title overrides everything
|
||||
If pWindowTitle IsNot Nothing Then
|
||||
oWindowString = pWindowTitle
|
||||
End If
|
||||
|
||||
Return oWindowString
|
||||
End Function
|
||||
|
||||
Public Sub SetDateConstraint()
|
||||
@@ -341,6 +363,16 @@ Public Class SearchRunner
|
||||
_ActiveDateAttribute = SEARCH_FACT_DATE_DEFAULT
|
||||
End Sub
|
||||
|
||||
Public Class SearchOptions
|
||||
Public SearchTitle As String
|
||||
|
||||
Public SearchString As String
|
||||
Public SearchTokens As IEnumerable(Of Search.SearchToken.Token)
|
||||
|
||||
Public DateFrom As Date
|
||||
Public DateTo As Date
|
||||
End Class
|
||||
|
||||
Public Class SearchResult
|
||||
Public OK As Boolean = True
|
||||
Public Count As Integer = 0
|
||||
|
||||
Reference in New Issue
Block a user