Zooflow: Search Improvements, Multiple Tokens

This commit is contained in:
Jonathan Jenne
2022-05-18 16:19:51 +02:00
parent bdd729f590
commit bd5d63c234
10 changed files with 262 additions and 383 deletions

View File

@@ -86,18 +86,18 @@ Public Class SearchRunner
End Function
Public Async Function RunWithSearchTerm(pSearchTerm As String) As Task(Of SearchResult)
Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing)
Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing, Nothing)
End Function
Public Async Function RunWithSearchTerm(pSearchTerm As String, pSearchTitle As String) As Task(Of SearchResult)
Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, pSearchTitle)
Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing, 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)
Return Await RunWithSearchTerm(pSearchTerm, pDateFrom, pDateTo, Nothing, Nothing)
End Function
Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date, pSearchTitle As String) As Task(Of SearchResult)
Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date, pSearchTokens As IEnumerable(Of Search.SearchToken.AttributeValueToken), pSearchTitle As String) As Task(Of SearchResult)
If pDateFrom.Equals(Date.MinValue) = False Then
ExplicitDate = True
End If
@@ -106,6 +106,7 @@ Public Class SearchRunner
Dim oWindowTitle = GetResultWindowString(pSearchTerm, pSearchTitle)
Dim oParams = GetParams(oWindowTitle)
Dim oDateConstraint = $"{_ActiveDateAttribute}~{_ActiveDateConstraint}"
Dim oUserId = My.Application.User.UserId
If ExplicitDate Then
Dim oDate2 As Date
@@ -114,13 +115,27 @@ Public Class SearchRunner
Else
oDate2 = pDateFrom
End If
Dim oProc = $"EXEC PRIDB_SEARCH_ADD_USR_DATE {My.Application.User.UserId},'{pDateFrom}','{oDate2}'"
Dim oProc = $"EXEC PRIDB_SEARCH_ADD_USR_DATE {oUserId},'{pDateFrom}','{oDate2}'"
If Await My.Database.ExecuteNonQueryIDBAsync(oProc) = True Then
oDateConstraint = $"{_ActiveDateAttribute}~DATEPART"
End If
End If
Dim oSQL = $"EXEC PRIDB_SEARCH_TEXT_GET_RESULTS {My.Application.User.UserId},'{oSearchTerm}','{oDateConstraint}'"
Await My.Database.ExecuteNonQueryIDBAsync($"DELETE FROM TBIDB_SEARCH_INPUT_USER WHERE USR_ID = {oUserId}")
If pSearchTokens IsNot Nothing AndAlso pSearchTokens.Count > 0 Then
For Each oToken In pSearchTokens
Dim oSQLInsert As String = $"
INSERT INTO [dbo].[TBIDB_SEARCH_INPUT_USER] ([USR_ID], [ATTR_ID], [ATTR_TITLE], [TERM_ID], [OPERATOR])
VALUES ({oUserId}, {oToken.AttributeId}, '{oToken.AttributeTitle}', {oToken.TermId}, 'AND')"
Dim oResult = Await My.Database.ExecuteNonQueryIDBAsync(oSQLInsert)
Next
End If
Dim oSQL = $"EXEC PRIDB_SEARCH_TEXT_GET_RESULTS {oUserId},'{oSearchTerm}','{oDateConstraint}'"
If Await My.Database.ExecuteNonQueryIDBAsync(oSQL) = True Then
Dim oDTDocResult = Await My.Database.GetDatatableIDBAsync(BaseSearchSQL)