Zooflow: Search
This commit is contained in:
@@ -3,6 +3,7 @@ Imports DevExpress.Skins
|
||||
Imports DevExpress.Utils.Svg
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Views.Tile
|
||||
Imports DevExpress.XtraSplashScreen
|
||||
Imports DigitalData.GUIs.ZooFlow.ClassConstants
|
||||
@@ -30,13 +31,14 @@ Public Class frmFlowSearch2
|
||||
}
|
||||
|
||||
TokenTable = GetTokenTable()
|
||||
RadioGroupDateConstraints.Properties.Items.AddRange(LoadDateConstraints().ToArray)
|
||||
ComboBoxDateAttributes.Properties.Items.AddRange(LoadDateAttributes())
|
||||
GridPredefinedSearches.DataSource = LoadPredefinedSearches()
|
||||
|
||||
Dim oTokens = GetTokensFromTable(Of AttributeValueToken)(TokenTable)
|
||||
AddTokens(TokenEditEx1, oTokens)
|
||||
|
||||
TileView1.FocusedRowHandle = GridControl.InvalidRowHandle
|
||||
|
||||
FormLoading = False
|
||||
End Sub
|
||||
|
||||
@@ -63,21 +65,24 @@ Public Class frmFlowSearch2
|
||||
})
|
||||
Next
|
||||
|
||||
Return oTokens.Distinct().ToList()
|
||||
Return oTokens.
|
||||
OrderBy(Function(token) token.TermValue).
|
||||
Distinct().
|
||||
ToList()
|
||||
End Function
|
||||
|
||||
Private Function LoadDateConstraints() As List(Of RadioGroupItem)
|
||||
Return New List(Of RadioGroupItem) From {
|
||||
New RadioGroupItem(SearchRunner.CREATED_TODAY, "Heute"),
|
||||
New RadioGroupItem(SearchRunner.CREATED_TOMORROW, "Gestern"),
|
||||
New RadioGroupItem(SearchRunner.CREATED_LAST_7_DAYS, "Letzte 7 Tage"),
|
||||
New RadioGroupItem(SearchRunner.CREATED_MONTH_CURR, "Dieser Monat"),
|
||||
New RadioGroupItem(SearchRunner.CREATED_LAST_7_DAYS, "Letzter Monat"),
|
||||
New RadioGroupItem(SearchRunner.CREATED_YEAR_CURRENT, "Dieses Jahr"),
|
||||
New RadioGroupItem(SearchRunner.CREATED_YEAR_LAST, "Letztes Jahr"),
|
||||
New RadioGroupItem("NOTHING", "Keine Einschränkung")
|
||||
}
|
||||
End Function
|
||||
'Private Function LoadDateConstraints() As List(Of RadioGroupItem)
|
||||
' Return New List(Of RadioGroupItem) From {
|
||||
' New RadioGroupItem(SearchRunner.CREATED_TODAY, "Heute"),
|
||||
' New RadioGroupItem(SearchRunner.CREATED_TOMORROW, "Gestern"),
|
||||
' New RadioGroupItem(SearchRunner.CREATED_LAST_7_DAYS, "Letzte 7 Tage"),
|
||||
' New RadioGroupItem(SearchRunner.CREATED_MONTH_CURR, "Dieser Monat"),
|
||||
' New RadioGroupItem(SearchRunner.CREATED_LAST_7_DAYS, "Letzter Monat"),
|
||||
' New RadioGroupItem(SearchRunner.CREATED_YEAR_CURRENT, "Dieses Jahr"),
|
||||
' New RadioGroupItem(SearchRunner.CREATED_YEAR_LAST, "Letztes Jahr"),
|
||||
' New RadioGroupItem("NOTHING", "Keine Einschränkung")
|
||||
' }
|
||||
'End Function
|
||||
|
||||
Private Function LoadDateAttributes() As List(Of String)
|
||||
Return My.Tables.DTIDB_ATTRIBUTE.
|
||||
@@ -105,7 +110,7 @@ Public Class frmFlowSearch2
|
||||
.Image = SvgImageCollection1.Item("yesterday")
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Letzte Woche",
|
||||
.Name = "Letzte 7 Tage",
|
||||
.Description = "Dokumente, die in den letzten 7 Tagen abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.Last7Days,
|
||||
.Image = SvgImageCollection1.Item("week")
|
||||
@@ -142,72 +147,52 @@ Public Class frmFlowSearch2
|
||||
Return oTokens.Select(Of Token)(Function(token) token.Value).ToList()
|
||||
End Function
|
||||
|
||||
Private Async Sub TextEdit1_KeyUp(sender As Object, e As KeyEventArgs)
|
||||
If e.KeyCode = Keys.Enter Then
|
||||
Await RunSearch(GetTokens())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Sub SearchControl2_KeyUp(sender As Object, e As KeyEventArgs) Handles TokenEditEx1.KeyUp
|
||||
If e.KeyCode = Keys.Enter And TokenEditEx1.IsPopupOpen = False Then
|
||||
Await RunSearch(GetTokens())
|
||||
Await RunSearch2(GetTokens())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Sub TextEdit1_ButtonClick(sender As Object, e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs)
|
||||
If e.Button.Tag = "SEARCH" Then
|
||||
Await RunSearch(GetTokens())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Function RunSearch(pTokens As IEnumerable(Of Token)) As Threading.Tasks.Task
|
||||
Dim oHandle = StartUpdateUI()
|
||||
|
||||
If pTokens.Count = 0 Then
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oDateFrom = DateEditFrom.EditValue
|
||||
Dim oDateTo = DateEditTo.EditValue
|
||||
|
||||
If CheckEdit1.IsOn = False Then
|
||||
oDateTo = Nothing
|
||||
End If
|
||||
|
||||
SearchRunner.SetDateConstraint()
|
||||
Dim oResult = Await SearchRunner.RunWithSearchTerm(String.Empty, oDateFrom, oDateTo, pTokens, "")
|
||||
|
||||
If oResult.OK = False Then
|
||||
SetStatusBarColor(Color.OrangeRed, Color.White)
|
||||
End If
|
||||
|
||||
lblResults.Caption = $"{oResult.Count} Ergebnisse"
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
|
||||
Finally
|
||||
StopUpdateUI(oHandle)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Async Sub TileView1_ItemClick(sender As Object, e As TileViewItemClickEventArgs) Handles TileView1.ItemClick
|
||||
Private Async Function RunSearch2(pTokens As IEnumerable(Of Token)) As Threading.Tasks.Task
|
||||
Dim oHandle = StartUpdateUI()
|
||||
Dim oSearchTitle As String = "Suche"
|
||||
|
||||
Try
|
||||
' If the user clicked on a Search Tile, it will set the date constraint for this search
|
||||
Dim oSearch = TileView1.GetRow(TileView1.FocusedRowHandle)
|
||||
Dim oSearchTitle As String = "Suche"
|
||||
|
||||
If TypeOf oSearch Is PredefinedDateSearch Then
|
||||
If oSearch IsNot Nothing AndAlso TypeOf oSearch Is PredefinedDateSearch Then
|
||||
Dim oDateSearch As PredefinedDateSearch = oSearch
|
||||
oSearchTitle = oDateSearch.DisplayName
|
||||
SearchRunner.SetDateConstraint(oDateSearch.DateConstraint)
|
||||
Else
|
||||
SearchRunner.SetDateConstraint()
|
||||
End If
|
||||
|
||||
Dim oResult = Await SearchRunner.RunWithSearchTerm("", oSearchTitle)
|
||||
' If the user selected a custom date range, process it including the 'with end date' toggle
|
||||
Dim oDateFrom, oDateTo As Date
|
||||
If chkDatefilter2.Checked Then
|
||||
oDateFrom = DateEditFrom.EditValue
|
||||
oDateTo = DateEditTo.EditValue
|
||||
If CheckEdit1.IsOn = False Then
|
||||
oDateTo = Nothing
|
||||
End If
|
||||
Else
|
||||
oDateFrom = Nothing
|
||||
oDateTo = Nothing
|
||||
End If
|
||||
|
||||
' Run the actual search
|
||||
Dim oResult As SearchRunner.SearchResult
|
||||
If chkSearchEverywhere.Checked Then
|
||||
Dim oToken = pTokens.First()
|
||||
oResult = Await SearchRunner.RunWithSearchTerm(oToken.TermValue, oDateFrom, oDateTo, oSearchTitle)
|
||||
Else
|
||||
oResult = Await SearchRunner.RunWithTokens(pTokens)
|
||||
End If
|
||||
|
||||
' If there was an error, show the message
|
||||
' otherwise just show the count of results and color it
|
||||
' if none were found
|
||||
If oResult.OK = False Then
|
||||
SetStatusBarColor(Color.OrangeRed, Color.White)
|
||||
lblResults.Caption = oResult.ErrorMessage
|
||||
@@ -221,11 +206,86 @@ Public Class frmFlowSearch2
|
||||
|
||||
End If
|
||||
|
||||
' Reset the clicked tile
|
||||
TileView1.FocusedRowHandle = GridControl.InvalidRowHandle
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
Finally
|
||||
StopUpdateUI(oHandle)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'Private Async Function RunSearch(pTokens As IEnumerable(Of Token)) As Threading.Tasks.Task
|
||||
' Dim oHandle = StartUpdateUI()
|
||||
|
||||
' If pTokens.Count = 0 Then
|
||||
' Exit Function
|
||||
' End If
|
||||
|
||||
' Try
|
||||
' Dim oDateFrom = DateEditFrom.EditValue
|
||||
' Dim oDateTo = DateEditTo.EditValue
|
||||
|
||||
' If CheckEdit1.IsOn = False Then
|
||||
' oDateTo = Nothing
|
||||
' End If
|
||||
|
||||
' SearchRunner.SetDateConstraint()
|
||||
' Dim oResult = Await SearchRunner.RunWithSearchTerm(String.Empty, oDateFrom, oDateTo, pTokens, "")
|
||||
|
||||
' If oResult.OK = False Then
|
||||
' SetStatusBarColor(Color.OrangeRed, Color.White)
|
||||
' End If
|
||||
|
||||
' lblResults.Caption = $"{oResult.Count} Ergebnisse"
|
||||
|
||||
' Catch ex As Exception
|
||||
' MsgBox(ex.Message)
|
||||
|
||||
' Finally
|
||||
' StopUpdateUI(oHandle)
|
||||
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Private Async Sub TileView1_ItemClick(sender As Object, e As TileViewItemClickEventArgs) Handles TileView1.ItemClick
|
||||
Await RunSearch2(GetTokens())
|
||||
|
||||
'Dim oHandle = StartUpdateUI()
|
||||
|
||||
'TokenEditEx1.Properties.Tokens.Clear()
|
||||
|
||||
'Try
|
||||
' Dim oSearch = TileView1.GetRow(TileView1.FocusedRowHandle)
|
||||
' Dim oSearchTitle As String = "Suche"
|
||||
|
||||
' If TypeOf oSearch Is PredefinedDateSearch Then
|
||||
' Dim oDateSearch As PredefinedDateSearch = oSearch
|
||||
' oSearchTitle = oDateSearch.DisplayName
|
||||
' SearchRunner.SetDateConstraint(oDateSearch.DateConstraint)
|
||||
' End If
|
||||
|
||||
' Dim oResult = Await SearchRunner.RunWithSearchTerm("", oSearchTitle)
|
||||
|
||||
' If oResult.OK = False Then
|
||||
' SetStatusBarColor(Color.OrangeRed, Color.White)
|
||||
' lblResults.Caption = oResult.ErrorMessage
|
||||
|
||||
' ElseIf oResult.Count = 0 Then
|
||||
' SetStatusBarColor(Color.OrangeRed, Color.White)
|
||||
' lblResults.Caption = $"Keine Ergebnisse"
|
||||
|
||||
' Else
|
||||
' lblResults.Caption = $"{oResult.Count} Ergebnisse"
|
||||
|
||||
' End If
|
||||
|
||||
'Catch ex As Exception
|
||||
' MsgBox(ex.Message)
|
||||
'Finally
|
||||
' StopUpdateUI(oHandle)
|
||||
'End Try
|
||||
End Sub
|
||||
|
||||
Private Function StartUpdateUI() As IOverlaySplashScreenHandle
|
||||
@@ -255,17 +315,6 @@ Public Class frmFlowSearch2
|
||||
LookAndFeelHelper.ForceDefaultLookAndFeelChanged()
|
||||
End Sub
|
||||
|
||||
Private Sub RadioGroup1_EditValueChanged(sender As Object, e As EventArgs) Handles RadioGroupDateConstraints.EditValueChanged
|
||||
Dim oIndex = RadioGroupDateConstraints.SelectedIndex
|
||||
Dim oItem As RadioGroupItem = RadioGroupDateConstraints.Properties.Items.Item(oIndex)
|
||||
Dim oSearchConstraintString As String = oItem.Value
|
||||
Dim oDateConstraint = SearchRunner.ConstantToDateConstraint(oSearchConstraintString)
|
||||
|
||||
If oDateConstraint <> SearchRunner.DateConstraint.Undefined Then
|
||||
SearchRunner.SetDateConstraint(oDateConstraint)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Class PredefinedSearch
|
||||
Public Property Name As String
|
||||
Public Property Description As String
|
||||
@@ -299,6 +348,12 @@ Public Class frmFlowSearch2
|
||||
AddTokens(Editor, Tokens)
|
||||
End Sub
|
||||
|
||||
Private Sub ClearTokens(Editor As TokenEdit)
|
||||
'Editor.Properties.Tokens.Clear()
|
||||
|
||||
'TODO
|
||||
End Sub
|
||||
|
||||
Private Sub AddTokens(Editor As TokenEdit, Tokens As IEnumerable(Of Token))
|
||||
For Each oToken In Tokens
|
||||
Dim oTokenEditToken = New TokenEditToken With {
|
||||
@@ -314,7 +369,9 @@ Public Class frmFlowSearch2
|
||||
Select Case e.Value.GetType()
|
||||
Case GetType(AttributeValueToken)
|
||||
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 214, 49)), e.Bounds)
|
||||
Case Else
|
||||
|
||||
Case GetType(ValueOnlyToken)
|
||||
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 214, 49)), e.Bounds)
|
||||
End Select
|
||||
|
||||
' Draw the glyph on top
|
||||
@@ -339,10 +396,8 @@ Public Class frmFlowSearch2
|
||||
|
||||
Private Sub BarCheckItem3_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles chkDatefilter2.CheckedChanged
|
||||
If chkDatefilter2.Checked Then
|
||||
LayoutControlGroupDate1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always
|
||||
LayoutControlGroupDate2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always
|
||||
Else
|
||||
LayoutControlGroupDate1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never
|
||||
LayoutControlGroupDate2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never
|
||||
End If
|
||||
End Sub
|
||||
@@ -354,13 +409,14 @@ Public Class frmFlowSearch2
|
||||
' Create a list of tokens that only contains every term once,
|
||||
' without caring about attribute names.
|
||||
oTokens = GetTokensFromTable(Of ValueOnlyToken)(TokenTable)
|
||||
|
||||
RibbonPageGroup5.Enabled = False
|
||||
Else
|
||||
' Create a list of tokens where every term - attribute value is present once.
|
||||
oTokens = GetTokensFromTable(Of AttributeValueToken)(TokenTable)
|
||||
|
||||
RibbonPageGroup5.Enabled = True
|
||||
End If
|
||||
|
||||
ClearTokens(TokenEditEx1)
|
||||
SetTokens(TokenEditEx1, oTokens)
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user