Zooflow: Zooflow: Rework New Search
This commit is contained in:
@@ -1,43 +1,190 @@
|
||||
Imports DigitalData.GUIs.ZooFlow.ClassConstants
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports DevExpress.XtraGrid.Views.Tile
|
||||
Imports DevExpress.XtraSplashScreen
|
||||
Imports DigitalData.GUIs.ZooFlow.ClassConstants
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class frmFlowSearch2
|
||||
Private ReadOnly LogConfig As LogConfig = My.LogConfig
|
||||
Private ReadOnly Logger = My.LogConfig.GetLogger()
|
||||
Private SearchRunner As SearchRunner
|
||||
Private BaseSearchSQL As String
|
||||
|
||||
Private Sub frmFlowSearch2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
For Each oRow As DataRow In My.Tables.DTIDB_COMMON_SQL.Rows
|
||||
If oRow.Item("TITLE") = SQLCMD_FLOW_SEARCH_BASE Then
|
||||
BaseSearchSQL = oRow.Item("SQL_COMMAND")
|
||||
BaseSearchSQL = BaseSearchSQL.Replace("@USER_ID", My.Application.User.UserId)
|
||||
BaseSearchSQL = BaseSearchSQL.Replace("@LANG_CODE", My.Application.User.Language)
|
||||
End If
|
||||
Next
|
||||
|
||||
SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment, "FlowSearch")
|
||||
SearchRunner.BaseSearchSQL = BaseSearchSQL
|
||||
|
||||
Dim osql = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{My.Application.User.Language}',{My.Application.User.UserId}"
|
||||
Dim oDTSuggest As DataTable
|
||||
oDTSuggest = My.Database.GetDatatableIDB(osql)
|
||||
Dim collection As AutoCompleteStringCollection = New AutoCompleteStringCollection
|
||||
For Each orow As DataRow In oDTSuggest.Rows
|
||||
collection.Add(orow.Item("TERM"))
|
||||
Next
|
||||
SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment, "FlowSearch") With {
|
||||
.BaseSearchSQL = LoadBaseSQL()
|
||||
}
|
||||
|
||||
TextEdit1.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource
|
||||
TextEdit1.MaskBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend
|
||||
TextEdit1.MaskBox.AutoCompleteCustomSource = collection
|
||||
TextEdit1.MaskBox.AutoCompleteCustomSource = LoadAutoSuggest()
|
||||
|
||||
RadioGroup1.Properties.Items.AddRange(LoadDateConstraints.ToArray)
|
||||
|
||||
GridControl1.DataSource = LoadPredefinedSearches()
|
||||
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
|
||||
|
||||
Private Function LoadAutoSuggest() As AutoCompleteStringCollection
|
||||
Dim oCollection As New AutoCompleteStringCollection
|
||||
Dim oSql = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{My.Application.User.Language}',{My.Application.User.UserId}"
|
||||
Dim oTable As DataTable = My.Database.GetDatatableIDB(oSql)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
|
||||
Return New AutoCompleteStringCollection()
|
||||
End If
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
oCollection.Add(oRow.Item("TERM"))
|
||||
Next
|
||||
|
||||
Return oCollection
|
||||
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 LoadPredefinedSearches() As List(Of PredefinedSearch)
|
||||
Return New List(Of PredefinedSearch) From {
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Heute",
|
||||
.Description = "Dokumente, die heute abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.Today
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Gestern",
|
||||
.Description = "Dokumente, die gestern abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.Yesterday
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Letzte Woche",
|
||||
.Description = "Dokumente, die in den letzten 7 Tagen abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.Last7Days
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Dieser Monat",
|
||||
.Description = "Dokumente, die in diesem Monat abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.CurrentMonth
|
||||
},
|
||||
New PredefinedDateSearch() With {
|
||||
.Name = "Letzter Monat",
|
||||
.Description = "Dokumente, die im letzten Monat abgelegt wurden",
|
||||
.DateConstraint = SearchRunner.DateConstraint.LastMonth
|
||||
}
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Async Sub TextEdit1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextEdit1.KeyUp
|
||||
If e.KeyCode = Keys.Enter Then
|
||||
Await SearchRunner.Run(TextEdit1.EditValue, Nothing, Nothing)
|
||||
Await RunSearch()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Sub TextEdit1_ButtonClick(sender As Object, e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) Handles TextEdit1.ButtonClick
|
||||
If e.Button.Tag = "SEARCH" Then
|
||||
Await SearchRunner.Run(TextEdit1.EditValue, Nothing, Nothing)
|
||||
Await RunSearch()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Async Function RunSearch() As Threading.Tasks.Task
|
||||
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
|
||||
Try
|
||||
Dim oDateFrom = DateEditFrom.EditValue
|
||||
Dim oDateTo = DateEditTo.EditValue
|
||||
|
||||
If CheckEdit1.IsOn = False Then
|
||||
oDateTo = Nothing
|
||||
End If
|
||||
|
||||
SearchRunner.SetDateConstraint()
|
||||
Await SearchRunner.Run(TextEdit1.EditValue, oDateFrom, oDateTo)
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
|
||||
Finally
|
||||
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub RadioGroup1_EditValueChanged(sender As Object, e As EventArgs) Handles RadioGroup1.EditValueChanged
|
||||
Dim oIndex = RadioGroup1.SelectedIndex
|
||||
Dim oItem As RadioGroupItem = RadioGroup1.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
|
||||
Public Property Count As Integer = 0
|
||||
|
||||
Public ReadOnly Property DisplayName As String
|
||||
Get
|
||||
Return $"{Name} ({Count})"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
End Class
|
||||
|
||||
Friend Class PredefinedSQLSearch
|
||||
Public Property SQLCommand As String
|
||||
End Class
|
||||
|
||||
Friend Class PredefinedDateSearch
|
||||
Inherits PredefinedSearch
|
||||
|
||||
Public DateConstraint As SearchRunner.DateConstraint
|
||||
End Class
|
||||
|
||||
Private Async Sub TileView1_ItemClick(sender As Object, e As TileViewItemClickEventArgs) Handles TileView1.ItemClick
|
||||
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
|
||||
Try
|
||||
Dim oSearch = TileView1.GetRow(TileView1.FocusedRowHandle)
|
||||
|
||||
If TypeOf oSearch Is PredefinedDateSearch Then
|
||||
Dim oDateSearch As PredefinedDateSearch = oSearch
|
||||
SearchRunner.SetDateConstraint(oDateSearch.DateConstraint)
|
||||
End If
|
||||
|
||||
Await SearchRunner.Run()
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub CheckEdit1_Properties_EditValueChanged(sender As Object, e As EventArgs) Handles CheckEdit1.Properties.EditValueChanged
|
||||
DateEditTo.Enabled = CheckEdit1.IsOn
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user