ZooFlow: Add Time Filter, Loading indicator when running search

This commit is contained in:
Jonathan Jenne
2020-11-10 16:25:29 +01:00
parent b33a381bb9
commit 7fd8af6a14
5 changed files with 277 additions and 118 deletions

View File

@@ -7,6 +7,8 @@ Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraEditors
Imports DigitalData.GUIs.Common
Imports System.Random
Imports DevExpress.XtraSplashScreen
Imports DevExpress.XtraEditors.Repository
Public Class frmSearchStart
Private Logger As Logger
@@ -43,9 +45,70 @@ Public Class frmSearchStart
oSearchTerms.Columns.Add("BracketRight", GetType(String))
oSearchTerms.Columns.Add("Operator", GetType(String))
DTSearchTerms = oSearchTerms
End Sub
Private Sub frmSearchStart_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
Me.Panel1.Visible = False
For Each oTab As XtraTabPage In XtraTabControl1.TabPages
oTab.PageVisible = False
Next
RepositoryItemComboBox2.Items.AddRange(New List(Of FilterTimeframe) From {
New FilterTimeframe() With {.Name = "Alle", .From = Nothing, .[To] = Nothing},
New FilterTimeframe() With {.Name = "Eigener", .From = Nothing, .[To] = Nothing},
New FilterTimeframe() With {
.Name = "letzte 7 Tage",
.From = Date.Now.Subtract(TimeSpan.FromDays(7)),
.[To] = Date.Now
},
New FilterTimeframe() With {
.Name = "letzte 14 Tage",
.From = Date.Now.Subtract(TimeSpan.FromDays(14)),
.[To] = Date.Now
}
})
If DTSearchProfiles.Rows.Count > 1 Then
cmbProfile.DataSource = DTSearchProfiles
cmbProfile.ValueMember = DTSearchProfiles.Columns("SEARCH_PROFILE_ID").ColumnName
cmbProfile.DisplayMember = DTSearchProfiles.Columns("TITLE").ColumnName
cmbProfile.AutoCompleteMode = AutoCompleteMode.Suggest
cmbProfile.AutoCompleteSource = AutoCompleteSource.ListItems
cmbProfile.SelectedIndex = -1
TabSelectedIndex = -1
Me.Panel1.Visible = True
For Each orow As DataRow In DTSearchProfiles.Rows
RepositoryItemComboBox1.Items.Add(orow.Item("TITLE"))
Next
Else
TabSelectedIndex = 0
TabSelected = XtraTabControl1.TabPages(0)
TabSelected.PageVisible = True
PSEARCH_ID = DTSearchProfiles.Rows(0).Item("SEARCH_PROFILE_ID")
SEARCH_SQL = DTSearchProfiles.Rows(0).Item("RESULT_SQL")
SEARCH_TITLE = DTSearchProfiles.Rows(0).Item("TITLE")
TabSelected.Text = DTSearchProfiles.Rows(0).Item("TITLE")
Load_Search_Attributes()
BarButtonItemNewSearch.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End If
SEARCH_COUNT = DTSearchProfiles.Rows.Count
SplitContainerControlSearch.Collapsed = True
RibbonControl1.ColorScheme = DevExpress.XtraBars.Ribbon.RibbonControlColorScheme.Red
If My.UIConfig.SearchForm.Location.X > 0 And My.UIConfig.SearchForm.Location.Y > 0 Then
Me.Location = My.UIConfig.SearchForm.Location
End If
Catch ex As Exception
Logger.Error(ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error while loading ProfileSearches:")
End Try
End Sub
Public Sub AddSearchAttribute(pAttributeId As String, pAttributeTitle As String, pSearchTerm As String, Optional pCriteria As String = "=")
GridControlSerchTerms.DataSource = Nothing
Dim oMultiselect As Boolean = False
@@ -107,51 +170,6 @@ Public Class frmSearchStart
End Sub
Private Sub frmSearchStart_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
Me.Panel1.Visible = False
For Each oTab As XtraTabPage In XtraTabControl1.TabPages
oTab.PageVisible = False
Next
If DTSearchProfiles.Rows.Count > 1 Then
cmbProfile.DataSource = DTSearchProfiles
cmbProfile.ValueMember = DTSearchProfiles.Columns("SEARCH_PROFILE_ID").ColumnName
cmbProfile.DisplayMember = DTSearchProfiles.Columns("TITLE").ColumnName
cmbProfile.AutoCompleteMode = AutoCompleteMode.Suggest
cmbProfile.AutoCompleteSource = AutoCompleteSource.ListItems
cmbProfile.SelectedIndex = -1
TabSelectedIndex = -1
Me.Panel1.Visible = True
For Each orow As DataRow In DTSearchProfiles.Rows
RepositoryItemComboBox1.Items.Add(orow.Item("TITLE"))
Next
Else
TabSelectedIndex = 0
TabSelected = XtraTabControl1.TabPages(0)
TabSelected.PageVisible = True
PSEARCH_ID = DTSearchProfiles.Rows(0).Item("SEARCH_PROFILE_ID")
SEARCH_SQL = DTSearchProfiles.Rows(0).Item("RESULT_SQL")
SEARCH_TITLE = DTSearchProfiles.Rows(0).Item("TITLE")
TabSelected.Text = DTSearchProfiles.Rows(0).Item("TITLE")
Load_Search_Attributes()
BarButtonItemNewSearch.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End If
SEARCH_COUNT = DTSearchProfiles.Rows.Count
SplitContainerControlSearch.Collapsed = True
RibbonControl1.ColorScheme = DevExpress.XtraBars.Ribbon.RibbonControlColorScheme.Red
If My.UIConfig.SearchForm.Location.X > 0 And My.UIConfig.SearchForm.Location.Y > 0 Then
Me.Location = My.UIConfig.SearchForm.Location
End If
Catch ex As Exception
Logger.Error(ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error while loading ProfileSearches:")
End Try
End Sub
Sub Load_Search_Attributes()
Try
DataLoaded = False
@@ -754,10 +772,14 @@ Public Class frmSearchStart
End Function
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
Start_Search
Start_Search()
End Sub
Private Function Start_Search()
Private Sub Start_Search()
Dim oHandle As IOverlaySplashScreenHandle = Nothing
Try
oHandle = SplashScreenManager.ShowOverlayForm(Me)
Dim oSEARCH_SQL = SEARCH_SQL
Dim oOperator As String
Dim oCount As Integer = 1
@@ -772,14 +794,18 @@ Public Class frmSearchStart
oOperator = oRow.Item("Operator").ToString
Dim oSearchTerm = GetSearchTermForType(oRow.Item("AttrID"), oRow.Item("AttrTitle").ToString, oRow.Item("Criteria").ToString, oRow.Item("SearchTerm").ToString)
oSEARCH_SQL &= IIf(oCount = 0, " ", "") + $"{oRow.Item("BracketLeft").ToString}{oSearchTerm}{oRow.Item("BracketLeft").ToString}"
Dim oBracketLeft As String = oRow.Item("BracketLeft").ToString
Dim oBracketRight As String = oRow.Item("BracketLeft").ToString
Dim oSpaceChar = IIf(oCount = 0, " ", "")
oSEARCH_SQL &= $"{oSpaceChar}{oBracketLeft}{oSearchTerm}{oBracketRight}"
If DTSearchTerms.Rows.Count > oCount Then
oSEARCH_SQL &= $" {oOperator} {Chr(13)}"
End If
oCount += 1
Next
Dim oEnvironment As New DigitalData.Modules.ZooFlow.Environment() With {
Dim oEnvironment As New Modules.ZooFlow.Environment() With {
.User = My.Application.User,
.Modules = My.Application.Modules,
.Database = My.Database,
@@ -791,6 +817,7 @@ Public Class frmSearchStart
Dim oShortGuid = Guid.NewGuid()
Dim oWindowGuid = $"{PSEARCH_ID.ToString}-{My.User.Name}"
Dim oParams = New DocumentResultParams() With {
.IsIDBResult = True,
.WindowGuid = oWindowGuid,
.Results = New List(Of DocumentResult) From {
New DocumentResult() With {
@@ -805,12 +832,11 @@ Public Class frmSearchStart
Else
Display_InfoItem("No results for this searchcombination!", Color.OrangeRed)
End If
Catch ex As Exception
Finally
SplashScreenManager.CloseOverlayForm(oHandle)
End Try
End Function
End Sub
Private Sub frmSearchStart_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.F2 Then
@@ -818,5 +844,34 @@ Public Class frmSearchStart
End If
End Sub
Private Sub SwitchFilter_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SwitchFilter.CheckedChanged
If SwitchFilter.Checked Then
RibbonPageGroupFilter.Enabled = True
Else
RibbonPageGroupFilter.Enabled = False
End If
End Sub
Private Class FilterTimeframe
Public Property Name As String
Public Property From As Date
Public Property [To] As Date
Public Overrides Function ToString() As String
Return Name.ToString
End Function
End Class
Private Sub cmbFilterTimeframe_EditValueChanged(sender As Object, e As EventArgs) Handles cmbFilterTimeframe.EditValueChanged
Dim oTimeframe As FilterTimeframe = DirectCast(cmbFilterTimeframe.EditValue, FilterTimeframe)
If IsNothing(oTimeframe.From) And IsNothing(oTimeframe.To) Then
txtFilterFrom.Reset()
txtFilterTo.Reset()
Else
txtFilterFrom.EditValue = oTimeframe.From
txtFilterTo.EditValue = oTimeframe.[To]
End If
End Sub
End Class