Implement refreshing search from DocumentResultList

This commit is contained in:
Jonathan Jenne 2022-06-15 16:36:18 +02:00
parent 930b2e4900
commit 0c26b56c84
4 changed files with 168 additions and 74 deletions

View File

@ -21,10 +21,10 @@
</DigitalData.GUIs.ZooFlow.Settings>
<DevExpress.LookAndFeel.Design.AppSettings>
<setting name="DefaultAppSkin" serializeAs="String">
<value>Skin/Office 2019 Colorful</value>
<value></value>
</setting>
<setting name="DefaultPalette" serializeAs="String">
<value>Custom/Digital Data Palette</value>
<value>Custom/Digital Data 2</value>
</setting>
<setting name="TouchUI" serializeAs="String">
<value></value>
@ -36,7 +36,7 @@
<value></value>
</setting>
<setting name="DirectX" serializeAs="String">
<value></value>
<value>True</value>
</setting>
<setting name="RegisterUserSkins" serializeAs="String">
<value></value>
@ -81,6 +81,30 @@
<SvgColor Name="Gray" Value="169,168,168" />
<SvgColor Name="White" Value="255,255,255" />
</SvgPalette>
<SvgPalette Name="Digital Data 2">
<SvgColor Name="Paint" Value="248,248,248" />
<SvgColor Name="Paint High" Value="255,255,255" />
<SvgColor Name="Paint Shadow" Value="255,214,49" />
<SvgColor Name="Paint Deep Shadow" Value="230,230,230" />
<SvgColor Name="Brush" Value="72,70,68" />
<SvgColor Name="Brush High" Value="72,70,68" />
<SvgColor Name="Brush Light" Value="119,119,119" />
<SvgColor Name="Brush Major" Value="171,171,171" />
<SvgColor Name="Brush Minor" Value="210,210,210" />
<SvgColor Name="Accent Paint" Value="165,36,49" />
<SvgColor Name="Accent Paint Dark" Value="165,36,49" />
<SvgColor Name="Accent Paint Light" Value="250,220,221" />
<SvgColor Name="Accent Paint Lighter" Value="251,233,234" />
<SvgColor Name="Accent Brush" Value="255,255,255" />
<SvgColor Name="Accent Brush Light" Value="218,175,176" />
<SvgColor Name="Red" Value="237,61,59" />
<SvgColor Name="Green" Value="48,144,72" />
<SvgColor Name="Blue" Value="30,139,205" />
<SvgColor Name="Yellow" Value="251,152,59" />
<SvgColor Name="Black" Value="87,87,85" />
<SvgColor Name="Gray" Value="169,168,168" />
<SvgColor Name="White" Value="255,255,255" />
</SvgPalette>
</Skin>
<Skin Name="Basic">
<SvgPalette Name="Digital Data">
@ -107,6 +131,30 @@
<SvgColor Name="Gray" Value="191,191,194" />
<SvgColor Name="White" Value="255,255,255" />
</SvgPalette>
<SvgPalette Name="Digital Data 2">
<SvgColor Name="Paint" Value="240,240,240" />
<SvgColor Name="Paint High" Value="255,255,255" />
<SvgColor Name="Paint Shadow" Value="255,214,49" />
<SvgColor Name="Paint Deep Shadow" Value="210,210,210" />
<SvgColor Name="Brush" Value="40,40,40" />
<SvgColor Name="Brush High" Value="40,40,40" />
<SvgColor Name="Brush Light" Value="120,120,120" />
<SvgColor Name="Brush Major" Value="160,160,160" />
<SvgColor Name="Brush Minor" Value="200,200,200" />
<SvgColor Name="Accent Paint" Value="165,36,49" />
<SvgColor Name="Accent Paint Dark" Value="133,28,38" />
<SvgColor Name="Accent Paint Light" Value="255,236,161" />
<SvgColor Name="Accent Paint Lighter" Value="255,244,203" />
<SvgColor Name="Accent Brush" Value="255,255,255" />
<SvgColor Name="Accent Brush Light" Value="255,236,161" />
<SvgColor Name="Red" Value="208,49,68" />
<SvgColor Name="Green" Value="56,152,83" />
<SvgColor Name="Blue" Value="78,138,200" />
<SvgColor Name="Yellow" Value="241,151,63" />
<SvgColor Name="Black" Value="108,109,117" />
<SvgColor Name="Gray" Value="191,191,194" />
<SvgColor Name="White" Value="255,255,255" />
</SvgPalette>
</Skin>
</CustomPaletteCollection>
</value>

View File

@ -40,28 +40,40 @@ Namespace Search
Public Event NeedsNewSavedSearch As EventHandler
Public Event Closed As EventHandler(Of Integer)
Private Property _ActiveDateConstraint As String = String.Empty
Public ReadOnly Property ActiveDateConstraint As String
'Private Property _ActiveDateConstraint As String = String.Empty
'Public ReadOnly Property ActiveDateConstraint As String
' Get
' Return _ActiveDateConstraint
' 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
'Public ReadOnly Property ActiveDateAttribute As String
' Get
' Return _ActiveDateAttribute
' End Get
'End Property
'Public ReadOnly Property ActiveTokens As List(Of SearchToken.Token)
' Get
' Return _ActiveSearchTokens
' End Get
'End Property
Private _ActiveParams As New SearchParameters
Public ReadOnly Property ActiveSearchParameters As SearchParameters
Get
Return _ActiveDateConstraint
Return _ActiveParams
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
Public ReadOnly Property ActiveDateAttribute As String
Get
Return _ActiveDateAttribute
End Get
End Property
Public ReadOnly Property ActiveTokens As List(Of SearchToken.Token)
Get
Return _ActiveSearchTokens
End Get
End Property
Public Property LastOpenedForm As Common.IResultForm
Public Property BaseSearchSQL As String
Public Property ExplicitDate As Boolean = False
@ -122,10 +134,7 @@ Namespace Search
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)
If pTokens.Count = 0 And
pDateFrom = Date.MinValue And
pDateTo = Date.MinValue And
_ActiveDateConstraint = String.Empty Then
If pTokens.Count = 0 And pDateFrom = Date.MinValue And pDateTo = Date.MinValue And _ActiveParams.DateConstraint = String.Empty Then
Return New SearchResult(0)
End If
@ -136,33 +145,38 @@ Namespace Search
})
End Function
Private Async Function ExecuteSearch(pTokens As List(Of SearchToken.Token), pSearchTerm As String, pDateConstraint As String) As Task(Of Boolean)
Dim oSQL = String.Empty
'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
_ActiveParams.DateConstraint = pDateConstraint
If pTokens IsNot Nothing AndAlso pTokens.Count > 0 Then
_ActiveParams.SearchTokens = pTokens
_ActiveParams.SearchString = String.Empty
Await InsertSearchTokens(pTokens)
oSQL = $"EXEC PRIDB_SEARCH_GET_TOKEN_RESULT_DOCS {UserId}, '{pDateConstraint}', '{UserLanguage}'"
ElseIf pSearchTerm IsNot Nothing Then
_ActiveParams.SearchTokens.Clear()
_ActiveParams.SearchString = pSearchTerm
oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{pSearchTerm}','{pDateConstraint}', '{UserLanguage}'"
Else
_ActiveParams.SearchTokens.Clear()
_ActiveParams.SearchString = String.Empty
oSQL = $"EXEC PRIDB_SEARCH_GET_TEXT_RESULTS {UserId},'{String.Empty}','{pDateConstraint}', '{UserLanguage}'"
End If
Return Await My.Database.ExecuteNonQueryIDBAsync(oSQL)
End Function
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 = 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
If Await My.Database.ExecuteNonQueryIDBAsync(oSQL) = True Then
If Await ExecuteSearch(pOptions.SearchTokens, pOptions.SearchString, oDateConstraint) = True Then
Dim oDTDocResult = Await My.Database.GetDatatableIDBAsync(BaseSearchSQL)
If oDTDocResult Is Nothing Then
@ -182,6 +196,7 @@ Namespace Search
Dim oForm As New frmDocumentResultList(My.LogConfig, Environment, oParams)
AddEventHandlers(oForm)
LastOpenedForm = oForm
oForm.Show()
Return New SearchResult(oRowCount)
@ -195,9 +210,25 @@ Namespace Search
End If
End Function
Public Async Function RunLastSearch() As Task(Of DocumentResultList.DocumentResult)
Try
If Await ExecuteSearch(_ActiveParams.SearchTokens, _ActiveParams.SearchString, _ActiveParams.DateConstraint) Then
Dim oResult = Await My.Database.GetDatatableIDBAsync(BaseSearchSQL)
Return New DocumentResultList.DocumentResult() With {
.Title = SearchId,
.Datatable = oResult
}
Else
Return Nothing
End If
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
Private Sub AddEventHandlers(pForm As frmDocumentResultList)
' TODO: Implement
'AddHandler pForm.NeedsRefresh, AddressOf Form_NeedsRefresh
AddHandler pForm.FormClosed, AddressOf Form_Closed
' Only setup event if it is actually used
@ -220,7 +251,7 @@ Namespace Search
End Sub
Private Async Function GetDateConstraint(pDateFrom As Date, pDateTo As Date) As Task(Of String)
Dim oSimpleDateConstraint = $"{_ActiveDateAttribute}~{_ActiveDateConstraint}"
Dim oSimpleDateConstraint = $"{_ActiveParams.DateAttribute}~{_ActiveParams.DateConstraint}"
Dim oExplicitConstraint = Await MaybeSetExplicitDateConstraint(pDateFrom, pDateTo)
If IsNothing(oExplicitConstraint) Then
@ -246,7 +277,7 @@ Namespace Search
Dim oOperatorString
Select Case _ActiveTokenOperator
Select Case _ActiveParams.TokenOperator
Case TokenOperator.Or
oOperatorString = "OR"
Case Else
@ -277,7 +308,7 @@ Namespace Search
End If
Dim oProc = $"EXEC PRIDB_SEARCH_ADD_USR_DATE {UserId},'{pDateFrom}','{oDateTo}'"
If Await My.Database.ExecuteNonQueryIDBAsync(oProc) = True Then
Return $"{_ActiveDateAttribute}~DATEPART"
Return $"{_ActiveParams.DateAttribute}~DATEPART"
Else
Return Nothing
End If
@ -332,19 +363,19 @@ Namespace Search
End Function
Public Sub SetDateConstraint()
_ActiveDateConstraint = String.Empty
_ActiveParams.DateConstraint = String.Empty
End Sub
Public Sub SetDateConstraint(pConstraintName As String)
_ActiveDateConstraint = pConstraintName
_ActiveParams.DateConstraint = pConstraintName
End Sub
Public Sub SetDateConstraint(pConstraint As DateConstraint)
_ActiveDateConstraint = DateConstraintToConstant(pConstraint)
_ActiveParams.DateConstraint = DateConstraintToConstant(pConstraint)
End Sub
Public Sub SetTokenOperator(pOperator As TokenOperator)
_ActiveTokenOperator = pOperator
_ActiveParams.DateConstraint = pOperator
End Sub
Public Function DateConstraintToConstant(pConstraint As DateConstraint) As String
@ -402,13 +433,21 @@ Namespace Search
End Function
Public Sub SetDateAttribute(pAttributeName As String)
_ActiveDateAttribute = pAttributeName
_ActiveParams.DateAttribute = pAttributeName
End Sub
Public Sub SetDateAttribute()
_ActiveDateAttribute = SEARCH_FACT_DATE_DEFAULT
_ActiveParams.DateAttribute = SEARCH_FACT_DATE_DEFAULT
End Sub
Public Class SearchParameters
Public SearchTokens As New List(Of Search.SearchToken.Token)
Public TokenOperator As TokenOperator
Public SearchString As String
Public DateConstraint As String
Public DateAttribute As String
End Class
Public Class SearchOptions
Public SearchTitle As String

View File

@ -6,6 +6,7 @@ Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Tile
Imports DevExpress.XtraSplashScreen
Imports DigitalData.GUIs.Common
Imports DigitalData.GUIs.ZooFlow.ClassConstants
Imports DigitalData.GUIs.ZooFlow.SavedSearch
Imports DigitalData.GUIs.ZooFlow.Search
@ -17,7 +18,7 @@ Public Class frmSearchFlow
Private ReadOnly LogConfig As LogConfig = My.LogConfig
Private ReadOnly Logger = My.LogConfig.GetLogger()
Private SearchLoader As SearchLoader
Private SearchRunner As SearchRunner
Private WithEvents SearchRunner As SearchRunner
Private TokenTable As DataTable = Nothing
Private FormLoading As Boolean = True
@ -34,6 +35,7 @@ Public Class frmSearchFlow
}
AddHandler SearchRunner.NeedsNewSavedSearch, AddressOf SearchRunner_NewSavedSearch
AddHandler SearchRunner.NeedsRefresh, AddressOf SearchRunner_NeedsRefresh
TokenTable = GetTokenTable()
ComboBoxDateAttributes.Properties.Items.AddRange(LoadDateAttributes())
@ -51,13 +53,18 @@ Public Class frmSearchFlow
End Sub
Private Async Sub SearchRunner_NeedsRefresh(sender As Object, e As Integer)
Dim oResult = Await SearchRunner.RunLastSearch()
SearchRunner.LastOpenedForm.RefreshResults(New List(Of DocumentResultList.DocumentResult) From {oResult})
End Sub
Private Sub SearchRunner_NewSavedSearch(sender As Object, e As EventArgs)
Dim oForm As New frmEditSearch With {.IsNew = True}
If oForm.ShowDialog() = DialogResult.OK Then
' Get active tokens and create the search
Dim oTokens = SearchRunner.ActiveTokens
Dim oTokens = SearchRunner.ActiveSearchParameters.SearchTokens
SearchLoader.CreateCustomSearch(oForm.Title, oForm.Description, oTokens, oForm.ImageString)
' Reload the searches

View File

@ -38,6 +38,7 @@ Partial Class frmFlowForm
Me.TestToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ToolStripSeparator2 = New System.Windows.Forms.ToolStripSeparator()
Me.ZooFlowBeendenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.TreeViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.PictureBoxSearch = New DevExpress.XtraEditors.SvgImageBox()
Me.PictureBoxPM = New DevExpress.XtraEditors.SvgImageBox()
@ -77,7 +78,6 @@ Partial Class frmFlowForm
Me.PMTaskBadgeGroup = New DevExpress.Utils.VisualEffects.Badge()
Me.PMTaskBadgeIndividual = New DevExpress.Utils.VisualEffects.Badge()
Me.TimerDisplay = New System.Windows.Forms.Timer(Me.components)
Me.TreeViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ContextMenuSystray.SuspendLayout()
CType(Me.PictureBoxSearch, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBoxPM, System.ComponentModel.ISupportInitialize).BeginInit()
@ -108,56 +108,62 @@ Partial Class frmFlowForm
'
Me.ContextMenuSystray.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.EinblendenToolStripMenuItem, Me.ToolStripSeparator1, Me.VerwaltungToolStripMenuItem, Me.ToolStripSeparator3, Me.SucheEntwurfToolStripMenuItem, Me.TestToolStripMenuItem, Me.ToolStripSeparator2, Me.ZooFlowBeendenToolStripMenuItem, Me.TreeViewToolStripMenuItem})
Me.ContextMenuSystray.Name = "ContextMenuSystray"
Me.ContextMenuSystray.Size = New System.Drawing.Size(181, 176)
Me.ContextMenuSystray.Size = New System.Drawing.Size(170, 154)
'
'EinblendenToolStripMenuItem
'
Me.EinblendenToolStripMenuItem.Image = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.action_add_16xMD
Me.EinblendenToolStripMenuItem.Name = "EinblendenToolStripMenuItem"
Me.EinblendenToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.EinblendenToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.EinblendenToolStripMenuItem.Text = "Einblenden"
Me.EinblendenToolStripMenuItem.Visible = False
'
'ToolStripSeparator1
'
Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
Me.ToolStripSeparator1.Size = New System.Drawing.Size(177, 6)
Me.ToolStripSeparator1.Size = New System.Drawing.Size(166, 6)
'
'VerwaltungToolStripMenuItem
'
Me.VerwaltungToolStripMenuItem.Image = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.gear_32xLG
Me.VerwaltungToolStripMenuItem.Name = "VerwaltungToolStripMenuItem"
Me.VerwaltungToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.VerwaltungToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.VerwaltungToolStripMenuItem.Text = "Verwaltung"
'
'ToolStripSeparator3
'
Me.ToolStripSeparator3.Name = "ToolStripSeparator3"
Me.ToolStripSeparator3.Size = New System.Drawing.Size(177, 6)
Me.ToolStripSeparator3.Size = New System.Drawing.Size(166, 6)
'
'SucheEntwurfToolStripMenuItem
'
Me.SucheEntwurfToolStripMenuItem.Name = "SucheEntwurfToolStripMenuItem"
Me.SucheEntwurfToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.SucheEntwurfToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.SucheEntwurfToolStripMenuItem.Text = "Suche Entwurf"
'
'TestToolStripMenuItem
'
Me.TestToolStripMenuItem.Name = "TestToolStripMenuItem"
Me.TestToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.TestToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.TestToolStripMenuItem.Text = "Test"
'
'ToolStripSeparator2
'
Me.ToolStripSeparator2.Name = "ToolStripSeparator2"
Me.ToolStripSeparator2.Size = New System.Drawing.Size(177, 6)
Me.ToolStripSeparator2.Size = New System.Drawing.Size(166, 6)
'
'ZooFlowBeendenToolStripMenuItem
'
Me.ZooFlowBeendenToolStripMenuItem.Name = "ZooFlowBeendenToolStripMenuItem"
Me.ZooFlowBeendenToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.ZooFlowBeendenToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.ZooFlowBeendenToolStripMenuItem.Text = "ZooFlow beenden"
'
'TreeViewToolStripMenuItem
'
Me.TreeViewToolStripMenuItem.Name = "TreeViewToolStripMenuItem"
Me.TreeViewToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.TreeViewToolStripMenuItem.Text = "treeView"
'
'PictureBoxSearch
'
Me.PictureBoxSearch.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
@ -528,12 +534,6 @@ Partial Class frmFlowForm
'
Me.TimerDisplay.Interval = 60000
'
'TreeViewToolStripMenuItem
'
Me.TreeViewToolStripMenuItem.Name = "TreeViewToolStripMenuItem"
Me.TreeViewToolStripMenuItem.Size = New System.Drawing.Size(180, 22)
Me.TreeViewToolStripMenuItem.Text = "treeView"
'
'frmFlowForm
'
Me.AllowDrop = True