Zooflow: Improve Search Ribbon, Process Independent Search
This commit is contained in:
@@ -16,51 +16,46 @@ Public Class frmFlowSearch2
|
||||
Private ReadOnly Logger = My.LogConfig.GetLogger()
|
||||
Private SearchRunner As SearchRunner
|
||||
|
||||
Private TokenTable As DataTable = Nothing
|
||||
Private FormLoading As Boolean = True
|
||||
|
||||
Private TokenListDefault As New Dictionary(Of String, Object)
|
||||
Private TokenListOperands As New Dictionary(Of String, Object)
|
||||
Private TokenListAttrValues As New Dictionary(Of String, Object)
|
||||
|
||||
Private Sub frmFlowSearch2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
|
||||
SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment, "FlowSearch") With {
|
||||
.BaseSearchSQL = LoadBaseSQL()
|
||||
.BaseSearchSQL = SQL_FLOW_SEARCH_BASE
|
||||
}
|
||||
|
||||
|
||||
TokenTable = GetTokenTable()
|
||||
RadioGroupDateConstraints.Properties.Items.AddRange(LoadDateConstraints().ToArray)
|
||||
ComboBoxDateAttributes.Properties.Items.AddRange(LoadDateAttributes())
|
||||
GridPredefinedSearches.DataSource = LoadPredefinedSearches()
|
||||
|
||||
|
||||
Dim oTokens = GetValueTokensForAttribute()
|
||||
Dim oTokens = GetTokensFromTable(Of AttributeValueToken)(TokenTable)
|
||||
AddTokens(TokenEditEx1, oTokens)
|
||||
|
||||
FormLoading = False
|
||||
End Sub
|
||||
|
||||
Private Function LoadBaseSQL() As String
|
||||
Dim oSQL = ""
|
||||
|
||||
For Each oRow As DataRow In My.Tables.DTIDB_COMMON_SQL.Rows
|
||||
If oRow.Item("TITLE") = SQLCMD_FLOW_SEARCH_BASE Then
|
||||
oSQL = oRow.Item("SQL_COMMAND")
|
||||
oSQL = oSQL.Replace("@USER_ID", My.Application.User.UserId)
|
||||
oSQL = oSQL.Replace("@LANG_CODE", My.Application.User.Language)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return oSQL
|
||||
End Function
|
||||
|
||||
Public Function GetValueTokensForAttribute() As List(Of AttributeValueToken)
|
||||
Public Function GetTokenTable() As DataTable
|
||||
Dim oSQL = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{My.Application.User.Language}', {My.Application.User.UserId}"
|
||||
Dim oTable = My.Database.GetDatatableIDB(oSQL)
|
||||
Dim oTokens As New List(Of AttributeValueToken)
|
||||
Return oTable
|
||||
End Function
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Public Function GetTokensFromTable(Of T As {New, Token})(pTable As DataTable) As List(Of T)
|
||||
Dim oTokens As New List(Of T)
|
||||
|
||||
For Each oRow As DataRow In pTable.Rows
|
||||
Dim oTermValue = oRow.Item("TERM")
|
||||
Dim oTermId = oRow.ItemEx("TERM_ID", 0)
|
||||
Dim oAttributeTitle = oRow.Item("ATTR_TITLE")
|
||||
Dim oAttributeId = oRow.ItemEx("ATTR_ID", 0)
|
||||
|
||||
oTokens.Add(New AttributeValueToken() With {
|
||||
oTokens.Add(New T() With {
|
||||
.AttributeId = oAttributeId,
|
||||
.AttributeTitle = oAttributeTitle,
|
||||
.TermId = oTermId,
|
||||
@@ -101,13 +96,13 @@ Public Class frmFlowSearch2
|
||||
.Name = "Heute",
|
||||
.Description = "Dokumente, die heute abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.Today,
|
||||
.Image = SvgImageCollection1.Item("day")
|
||||
.Image = SvgImageCollection1.Item("today")
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Gestern",
|
||||
.Description = "Dokumente, die gestern abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.Yesterday,
|
||||
.Image = SvgImageCollection1.Item("day")
|
||||
.Image = SvgImageCollection1.Item("yesterday")
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Letzte Woche",
|
||||
@@ -126,13 +121,25 @@ Public Class frmFlowSearch2
|
||||
.Description = "Dokumente, die im letzten Monat abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.LastMonth,
|
||||
.Image = SvgImageCollection1.Item("month")
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Dieses Jahr",
|
||||
.Description = "Dokumente, die in diesem Jahr abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.CurrentYear,
|
||||
.Image = SvgImageCollection1.Item("year")
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Letztes Jahr",
|
||||
.Description = "Dokumente, die im letzten Jahr abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.LastYear,
|
||||
.Image = SvgImageCollection1.Item("year")
|
||||
}
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Function GetTokens() As IEnumerable(Of AttributeValueToken)
|
||||
Dim oTokens = TokenEditEx1.GetTokenList()
|
||||
Return oTokens.Select(Of AttributeValueToken)(Function(token) token.Value)
|
||||
Return oTokens.Select(Of AttributeValueToken)(Function(token) token.Value).ToList()
|
||||
End Function
|
||||
|
||||
Private Async Sub TextEdit1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextEdit1.KeyUp
|
||||
@@ -156,7 +163,7 @@ Public Class frmFlowSearch2
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Function RunSearch(pTokens As IEnumerable(Of AttributeValueToken)) As Threading.Tasks.Task
|
||||
Private Async Function RunSearch(pTokens As IEnumerable(Of Token)) As Threading.Tasks.Task
|
||||
Dim oHandle = StartUpdateUI()
|
||||
|
||||
If pTokens.Count = 0 Then
|
||||
@@ -239,7 +246,6 @@ Public Class frmFlowSearch2
|
||||
|
||||
' Force update of LookAndFeel
|
||||
LookAndFeelHelper.ForceDefaultLookAndFeelChanged()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub RadioGroup1_EditValueChanged(sender As Object, e As EventArgs) Handles RadioGroupDateConstraints.EditValueChanged
|
||||
@@ -281,22 +287,12 @@ Public Class frmFlowSearch2
|
||||
DateEditTo.Enabled = CheckEdit1.IsOn
|
||||
End Sub
|
||||
|
||||
Private Sub chkDateFilter_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles chkDateFilter.CheckedChanged
|
||||
If chkDateFilter.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
|
||||
|
||||
Private Sub SetTokens(Editor As TokenEdit, Tokens As Dictionary(Of String, Object))
|
||||
Private Sub SetTokens(Editor As TokenEdit, Tokens As IEnumerable(Of Token))
|
||||
Editor.Properties.Tokens.Clear()
|
||||
AddTokens(Editor, Tokens)
|
||||
End Sub
|
||||
|
||||
Private Sub AddTokens(Editor As TokenEdit, Tokens As IEnumerable(Of AttributeValueToken))
|
||||
Private Sub AddTokens(Editor As TokenEdit, Tokens As IEnumerable(Of Token))
|
||||
For Each oToken In Tokens
|
||||
Dim oTokenEditToken = New TokenEditToken With {
|
||||
.Description = oToken.ToString,
|
||||
@@ -323,7 +319,53 @@ Public Class frmFlowSearch2
|
||||
SearchRunner.SetDateAttribute(ComboBoxDateAttributes.EditValue)
|
||||
End Sub
|
||||
|
||||
Private Sub BarToggleSwitchItem1_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarToggleSwitchItem1.CheckedChanged
|
||||
Private Sub TokenEditEx1_Properties_TokenAdding(sender As Object, e As TokenEditTokenAddingEventArgs) Handles TokenEditEx1.Properties.TokenAdding
|
||||
' Prevent adding more than two tokens for now
|
||||
If TokenEditEx1.GetTokenList.Count >= 2 Then
|
||||
e.Cancel = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BarToggleSwitchItem2_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)
|
||||
|
||||
End Sub
|
||||
|
||||
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
|
||||
|
||||
Private Sub chkSearchEverywhere_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles chkSearchEverywhere.CheckedChanged
|
||||
Dim oTokens As IEnumerable(Of Token)
|
||||
|
||||
If chkSearchEverywhere.Checked = True Then
|
||||
' Create a list of tokens that only contains every term once,
|
||||
' without caring about attribute names.
|
||||
oTokens = GetTokensFromTable(Of ValueOnlyToken)(TokenTable)
|
||||
|
||||
Else
|
||||
' Create a list of tokens where every term - attribute value is present once.
|
||||
oTokens = GetTokensFromTable(Of AttributeValueToken)(TokenTable)
|
||||
|
||||
End If
|
||||
|
||||
SetTokens(TokenEditEx1, oTokens)
|
||||
End Sub
|
||||
|
||||
Private Sub chkOperatorAnd_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles chkOperatorAnd.CheckedChanged
|
||||
If chkOperatorAnd.Checked And FormLoading = False Then
|
||||
SearchRunner.SetTokenOperator(SearchRunner.TokenOperator.And)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub chkOperatorOr_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles chkOperatorOr.CheckedChanged
|
||||
If chkOperatorOr.Checked And FormLoading = False Then
|
||||
SearchRunner.SetTokenOperator(SearchRunner.TokenOperator.Or)
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user