Zooflow: Save Tokens in Custom searches
This commit is contained in:
@@ -47,6 +47,7 @@ Namespace Search
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private _ActiveSearchTokens As New List(Of SearchToken.Token)
|
||||
Private _ActiveDateAttribute As String = SEARCH_FACT_DATE_DEFAULT
|
||||
Private _ActiveTokenOperator As TokenOperator = TokenOperator.And
|
||||
|
||||
@@ -56,6 +57,12 @@ Namespace Search
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property ActiveTokens As List(Of SearchToken.Token)
|
||||
Get
|
||||
Return _ActiveSearchTokens
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Property BaseSearchSQL As String
|
||||
Public Property ExplicitDate As Boolean = False
|
||||
|
||||
@@ -102,22 +109,20 @@ Namespace Search
|
||||
''' Only search for Term. Used for sidebar quicksearch.
|
||||
''' </summary>
|
||||
Public Async Function RunWithSearchTerm(pSearchTerm As String) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(New SearchOptions With {.SearchString = pSearchTerm})
|
||||
Return Await RunWithSearchOptions(New SearchOptions With {.SearchString = pSearchTerm})
|
||||
End Function
|
||||
|
||||
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,
|
||||
.DateFrom = pDateFrom,
|
||||
.DateTo = pDateTo
|
||||
})
|
||||
Return Await RunWithSearchOptions(New SearchOptions With {
|
||||
.SearchString = pSearchTerm,
|
||||
.SearchTitle = pSearchTitle,
|
||||
.DateFrom = pDateFrom,
|
||||
.DateTo = pDateTo
|
||||
})
|
||||
End Function
|
||||
|
||||
Public Async Function RunWithTokens(pTokens As IEnumerable(Of Search.SearchToken.Token)) As Task(Of SearchResult)
|
||||
Return Await RunWithSearchTerm(New SearchOptions With {
|
||||
.SearchTokens = pTokens
|
||||
})
|
||||
Return Await RunWithSearchOptions(New SearchOptions With {.SearchTokens = pTokens})
|
||||
End Function
|
||||
|
||||
Public Async Function RunWithTokens(pTokens As IEnumerable(Of Search.SearchToken.Token), pDateFrom As Date, pDateTo As Date, pSearchTitle As String) As Task(Of SearchResult)
|
||||
@@ -128,11 +133,11 @@ Namespace Search
|
||||
Return New SearchResult(0)
|
||||
End If
|
||||
|
||||
Return Await RunWithSearchTerm(New SearchOptions With {
|
||||
.SearchTokens = pTokens,
|
||||
.DateFrom = pDateFrom,
|
||||
.DateTo = pDateTo
|
||||
})
|
||||
Return Await RunWithSearchOptions(New SearchOptions With {
|
||||
.SearchTokens = pTokens,
|
||||
.DateFrom = pDateFrom,
|
||||
.DateTo = pDateTo
|
||||
})
|
||||
End Function
|
||||
|
||||
|
||||
@@ -140,21 +145,24 @@ Namespace Search
|
||||
' Return Await RunWithSearchTerm(pSearchTerm, pDateFrom, pDateTo, Nothing, Nothing)
|
||||
'End Function
|
||||
|
||||
Private Async Function RunWithSearchTerm(pOptions As SearchOptions) As Task(Of SearchResult)
|
||||
Private Async Function RunWithSearchOptions(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 oTokens = pOptions.SearchTokens
|
||||
Dim oSearchTerm = pOptions.SearchString
|
||||
|
||||
Dim oSQL
|
||||
Dim oSQL = String.Empty
|
||||
|
||||
If oTokens IsNot Nothing AndAlso oTokens.Count > 0 Then
|
||||
_ActiveSearchTokens = oTokens
|
||||
Await InsertSearchTokens(oTokens)
|
||||
oSQL = $"EXEC PRIDB_SEARCH_GET_TOKEN_RESULT_DOCS {UserId}, '{oDateConstraint}', '{UserLanguage}'"
|
||||
ElseIf oSearchTerm IsNot Nothing Then
|
||||
_ActiveSearchTokens.Clear()
|
||||
oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{pOptions.SearchString}','{oDateConstraint}', '{UserLanguage}'"
|
||||
Else
|
||||
_ActiveSearchTokens.Clear()
|
||||
oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{String.Empty}','{oDateConstraint}', '{UserLanguage}'"
|
||||
End If
|
||||
|
||||
@@ -168,9 +176,9 @@ Namespace Search
|
||||
Dim oRowCount = oDTDocResult.Rows.Count
|
||||
If oRowCount > 0 Then
|
||||
oParams.Results.Add(New DocumentResultList.DocumentResult() With {
|
||||
.Title = SearchId,
|
||||
.Datatable = oDTDocResult
|
||||
})
|
||||
.Title = SearchId,
|
||||
.Datatable = oDTDocResult
|
||||
})
|
||||
|
||||
If oDTDocResult.Rows.Count = 1 Then
|
||||
oParams.ShowFileList = False
|
||||
|
||||
Reference in New Issue
Block a user