diff --git a/GUIs.ClipboardWatcher/My Project/licenses.licx b/GUIs.ClipboardWatcher/My Project/licenses.licx index e69de29b..f44a7f5f 100644 --- a/GUIs.ClipboardWatcher/My Project/licenses.licx +++ b/GUIs.ClipboardWatcher/My Project/licenses.licx @@ -0,0 +1 @@ +DevExpress.XtraEditors.TileControl, DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/GUIs.ClipboardWatcher/ProfileSearches.vb b/GUIs.ClipboardWatcher/ProfileSearches.vb index 735276c8..3fc900c8 100644 --- a/GUIs.ClipboardWatcher/ProfileSearches.vb +++ b/GUIs.ClipboardWatcher/ProfileSearches.vb @@ -9,9 +9,10 @@ Public Class ProfileSearches Private _LogConfig As LogConfig Private _Logger As Logger Private _Environment As Environment - Private _Params As ClipboardWatcherParams Private _Client As Client + Private _ClipboardContents As String + Public Class Search Public Guid As Integer Public DataTable As DataTable @@ -21,11 +22,11 @@ Public Class ProfileSearches Public SQLCommand As String End Class - Public Sub New(LogConfig As LogConfig, Environment As Environment, Params As ClipboardWatcherParams) + Public Sub New(LogConfig As LogConfig, Environment As Environment, pClipboardContents As String) _LogConfig = LogConfig _Logger = LogConfig.GetLogger() _Environment = Environment - _Params = Params + _ClipboardContents = pClipboardContents Try If _Environment.Service.IsActive = True Then Try @@ -84,7 +85,7 @@ Public Class ProfileSearches oSQL = oRow.Item("SQL_COMMAND") oSQL = oPatterns.ReplaceUserValues(oSQL, _Environment.User) oSQL = oPatterns.ReplaceInternalValues(oSQL) - oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents) + oSQL = oPatterns.ReplaceClipboardContents(oSQL, _ClipboardContents) Dim oConnectionString = ProfileUtils.GetConnectionString(_Environment.Database, oConnectionId) @@ -150,7 +151,7 @@ Public Class ProfileSearches oSQL = oRow.Item("SQL_COMMAND") oSQL = oPatterns.ReplaceUserValues(oSQL, _Environment.User) oSQL = oPatterns.ReplaceInternalValues(oSQL) - oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents) + oSQL = oPatterns.ReplaceClipboardContents(oSQL, _ClipboardContents) Dim oConnectionString = ProfileUtils.GetConnectionString(_Environment.Database, oConnectionId) diff --git a/GUIs.ClipboardWatcher/frmMatch.vb b/GUIs.ClipboardWatcher/frmMatch.vb index e345b9bc..4ac1964d 100644 --- a/GUIs.ClipboardWatcher/frmMatch.vb +++ b/GUIs.ClipboardWatcher/frmMatch.vb @@ -41,8 +41,11 @@ Public Class frmMatch Private ShouldHideInitially As Boolean = False Private Const NO_COUNT_SQL As Integer = 99998 + Private Const INVALID_COUNT_SQL As Integer = 99999 + 'Public Event ResultsRefreshed As EventHandler + Private Enum ProfileType ANY = 0 DOCS_ONLY = 1 @@ -133,7 +136,7 @@ Public Class frmMatch If oCreatedTiles = 1 Then Dim oProfile As ProfileData = _Params.MatchingProfiles.First() - Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params) + Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params.ClipboardContents) If oProfile.CountDocs > 0 And oProfile.CountData = 0 Then _Logger.Debug($"ONLY Docs") @@ -308,7 +311,7 @@ Public Class frmMatch Dim oItem As TileItem = e.Item Dim oProfileId As Integer = oItem.Tag - Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params) + Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params.ClipboardContents) Dim oProfile As ProfileData = _Params.MatchingProfiles. Where(Function(p) p.Guid = oProfileId). ToList(). @@ -345,7 +348,8 @@ Public Class frmMatch Dim oParams = New DocumentResultList.Params() With { .WindowGuid = oWindowGuid, .WindowTitle = GetResultWindowString(_Params.ClipboardContents), - .OperationModeOverride = _Params.OperationModeOverride + .OperationModeOverride = _Params.OperationModeOverride, + .ProfileGuid = Profile.Guid } For Each oSearch In Searches @@ -357,8 +361,11 @@ Public Class frmMatch Dim oForm As New frmDocumentResultList(_LogConfig, _Environment, oParams) AddHandler oForm.FormClosed, AddressOf ProfileResultForm_Closed + AddHandler oForm.NeedsRefresh, AddressOf ProfileResultForm_NeedsRefresh + OpenForms.Add(oForm) oForm.Show() + End Sub Private Sub OpenDataResults(Profile As ProfileData, Searches As List(Of ProfileSearches.Search)) @@ -406,4 +413,23 @@ Public Class frmMatch Show() End If End Sub + + Private Async Sub ProfileResultForm_NeedsRefresh(sender As Object, e As Integer) + Dim oThisForm As IResultForm = sender + Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params.ClipboardContents) + + If TypeOf sender Is frmDocumentResultList Then + Dim oProfileId = e + Dim oSearches = Await oProfileSearch.LoadDocumentSearchesAsync(oProfileId) + Dim oResults = oSearches.Select(Function(search) + Return New DocumentResultList.DocumentResult() With { + .Title = search.TabCaption, + .Datatable = search.DataTable + } + End Function).ToList() + + 'RaiseEvent ResultsRefreshed(Me, Nothing) + oThisForm.RefreshResults(oResults) + End If + End Sub End Class diff --git a/GUIs.Common/Common.vbproj b/GUIs.Common/Common.vbproj index 0a87b209..5b0c6db3 100644 --- a/GUIs.Common/Common.vbproj +++ b/GUIs.Common/Common.vbproj @@ -190,6 +190,10 @@ {3DCD6D1A-C830-4241-B7E4-27430E7EA483} LookupControl + + {ef29f400-be45-4283-9d18-ca7acd9accc9} + MessageBoxEx + {6ea0c51f-c2b1-4462-8198-3de0b32b74f8} Base @@ -303,5 +307,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/GUIs.Common/DataResultList/frmDataResultList.vb b/GUIs.Common/DataResultList/frmDataResultList.vb index c4a080b4..b3451a8e 100644 --- a/GUIs.Common/DataResultList/frmDataResultList.vb +++ b/GUIs.Common/DataResultList/frmDataResultList.vb @@ -33,6 +33,8 @@ Public Class frmDataResultList Private Property OperationMode As OperationMode Implements IResultForm.OperationMode + Public Event NeedsRefresh As EventHandler(Of Integer) Implements IResultForm.NeedsRefresh + Public Sub New(LogConfig As LogConfig, Environment As Environment, Params As DataResultParams) ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() diff --git a/GUIs.Common/DocumentResultList/Params.vb b/GUIs.Common/DocumentResultList/Params.vb index defd37fb..88626acc 100644 --- a/GUIs.Common/DocumentResultList/Params.vb +++ b/GUIs.Common/DocumentResultList/Params.vb @@ -10,6 +10,7 @@ Namespace DocumentResultList Public Results As New List(Of DocumentResult) Public ColumnNames As New ColumnNames Public OperationModeOverride As OperationMode = OperationMode.None + Public ProfileGuid As Integer End Class Public Class DocumentResult diff --git a/GUIs.Common/DocumentResultList/Watcher.vb b/GUIs.Common/DocumentResultList/Watcher.vb index a91de14e..d8a14a8b 100644 --- a/GUIs.Common/DocumentResultList/Watcher.vb +++ b/GUIs.Common/DocumentResultList/Watcher.vb @@ -35,6 +35,7 @@ Namespace DocumentResultList Public ProcessId As Integer Public FilePath As String Public CurrentlyProcessing As Boolean = False + Public Exited As Boolean = False End Class Public Class FileChangedArgs @@ -51,11 +52,11 @@ Namespace DocumentResultList End Sub Public Async Function OpenDocument(pDocument As Document) As Task(Of Boolean) - Dim oResult As Tuple(Of Process, String) = Nothing + Dim oResult As Tuple(Of Integer, String) = Nothing If pDocument.FullPath IsNot Nothing AndAlso pDocument.FullPath.Trim <> String.Empty Then ' TODO: DONT put into openfiles - oResult = OpenFileFromPath(pDocument) + oResult = Await OpenFileFromPath(pDocument) ElseIf pDocument.Extension IsNot Nothing AndAlso pDocument.Contents IsNot Nothing Then oResult = Await OpenFileFromByteArray(pDocument) @@ -67,15 +68,15 @@ Namespace DocumentResultList Return False End If - Dim oProcess = oResult.Item1 + Dim oProcessId = oResult.Item1 Dim oFilePath = oResult.Item2 - Logger.Debug("File [{0}] opened with ProcessId [{1}]", oFilePath, oProcess.Id) + Logger.Debug("File [{0}] opened with ProcessId [{1}]", oFilePath, oProcessId) Dim oOpenFile = New OpenFile With { .Document = pDocument, .FilePath = oFilePath, - .ProcessId = oProcess.Id + .ProcessId = oProcessId } OpenFiles.Add(oOpenFile) @@ -97,7 +98,7 @@ Namespace DocumentResultList ProcessedFiles.Remove(pOpenFile) End Sub - Private Async Function OpenFileFromByteArray(pDocument As Document) As Task(Of Tuple(Of Process, String)) + Private Async Function OpenFileFromByteArray(pDocument As Document) As Task(Of Tuple(Of Integer, String)) Try Dim oTempPath = Path.Combine(Path.GetTempPath(), Constants.TEMP_PATH_SUBFOLDER) Dim oDirectory = Directory.CreateDirectory(oTempPath) @@ -110,8 +111,9 @@ Namespace DocumentResultList End Using End Using - Dim oProcess = DoOpenFile(oFilePath) - Return New Tuple(Of Process, String)(oProcess, oFilePath) + Dim oProcessId = Await DoOpenFile(oFilePath) + + Return New Tuple(Of Integer, String)(oProcessId, oFilePath) Catch ex As Exception Logger.Error(ex) @@ -120,10 +122,10 @@ Namespace DocumentResultList End Try End Function - Private Function OpenFileFromPath(pDocument As Document) As Tuple(Of Process, String) + Private Async Function OpenFileFromPath(pDocument As Document) As Task(Of Tuple(Of Integer, String)) Try - Dim oProcess = DoOpenFile(pDocument.FullPath) - Return New Tuple(Of Process, String)(oProcess, pDocument.FullPath) + Dim oProcessId = Await DoOpenFile(pDocument.FullPath) + Return New Tuple(Of Integer, String)(oProcessId, pDocument.FullPath) Catch ex As Exception Logger.Error(ex) @@ -131,12 +133,28 @@ Namespace DocumentResultList End Try End Function - Private Function DoOpenFile(pFilePath As String) As Process - Dim oProcess = Process.Start(New ProcessStartInfo With { - .FileName = pFilePath - }) + Private Async Function DoOpenFile(pFilePath As String) As Task(Of Integer) + Dim _Process = New Process + _Process.StartInfo.FileName = pFilePath + _Process.EnableRaisingEvents = True - Return oProcess + AddHandler _Process.Exited, AddressOf Process_Exited + + _Process.Start() + + Return _Process.Id + End Function + + Private Function Process_Exited(sender As Object, e As EventArgs) As Boolean + Debug.WriteLine("Process is exited") + + Dim oProcess As Process = sender + Dim oOpenFile = OpenFiles. + Where(Function(file) file.ProcessId = oProcess.Id). + SingleOrDefault() + oOpenFile.Exited = True + + Return True End Function Private Sub FileOpenTimer_Elapsed() Handles FileOpenTimer.Elapsed @@ -154,9 +172,11 @@ Namespace DocumentResultList ' Check if the file is currently in use, and skip if it is. Dim oIsLocked = FileEx.TestFileIsLocked(oOpenFile.FilePath) + Dim oIsExited = oOpenFile.Exited Debug.WriteLine($"File is locked: [{oIsLocked}]") + Debug.WriteLine($"File is exited: [{oIsExited}]") - If oIsLocked Then + If oIsLocked Or oIsExited = False Then Continue For End If diff --git a/GUIs.Common/IResultForm.vb b/GUIs.Common/IResultForm.vb index e5dbb79f..cf5c6fbe 100644 --- a/GUIs.Common/IResultForm.vb +++ b/GUIs.Common/IResultForm.vb @@ -2,7 +2,10 @@ Public Interface IResultForm Property OperationMode As OperationMode - Property ShouldReturnToPreviousForm As Boolean + + + Event NeedsRefresh As EventHandler(Of Integer) + Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean End Interface diff --git a/GUIs.Common/My Project/Resources.Designer.vb b/GUIs.Common/My Project/Resources.Designer.vb index 992e0d06..1f5bff43 100644 --- a/GUIs.Common/My Project/Resources.Designer.vb +++ b/GUIs.Common/My Project/Resources.Designer.vb @@ -80,6 +80,16 @@ Namespace My.Resources End Get End Property + ''' + ''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage. + ''' + Friend ReadOnly Property actions_question() As DevExpress.Utils.Svg.SvgImage + Get + Dim obj As Object = ResourceManager.GetObject("actions_question", resourceCulture) + Return CType(obj,DevExpress.Utils.Svg.SvgImage) + End Get + End Property + ''' ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. ''' @@ -230,6 +240,16 @@ Namespace My.Resources End Get End Property + ''' + ''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage. + ''' + Friend ReadOnly Property refreshallpivottable() As DevExpress.Utils.Svg.SvgImage + Get + Dim obj As Object = ResourceManager.GetObject("refreshallpivottable", resourceCulture) + Return CType(obj,DevExpress.Utils.Svg.SvgImage) + End Get + End Property + ''' ''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage. ''' diff --git a/GUIs.Common/My Project/Resources.resx b/GUIs.Common/My Project/Resources.resx index af32bc25..4885af69 100644 --- a/GUIs.Common/My Project/Resources.resx +++ b/GUIs.Common/My Project/Resources.resx @@ -127,6 +127,9 @@ ..\Resources\tiff.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\_blank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\ZooFlow-Vergroessern.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a @@ -172,6 +175,9 @@ ..\Resources\zoom_more.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\actions_question.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + ..\Resources\grid.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a @@ -181,8 +187,8 @@ ..\Resources\dxf.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\_blank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\editcolors.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a ..\Resources\singlepageview1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a @@ -190,7 +196,7 @@ ..\Resources\copy.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - - ..\Resources\editcolors.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + ..\Resources\refreshallpivottable.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a \ No newline at end of file diff --git a/GUIs.Common/My Project/licenses.licx b/GUIs.Common/My Project/licenses.licx index 7b200139..2cf99fc3 100644 --- a/GUIs.Common/My Project/licenses.licx +++ b/GUIs.Common/My Project/licenses.licx @@ -1,3 +1,4 @@ -DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a DevExpress.XtraEditors.Repository.RepositoryItemTextEdit, DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraLayout.LayoutControl, DevExpress.XtraLayout.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/GUIs.Common/Resources/actions_question.svg b/GUIs.Common/Resources/actions_question.svg new file mode 100644 index 00000000..ee8513c0 --- /dev/null +++ b/GUIs.Common/Resources/actions_question.svg @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/GUIs.Common/Resources/refreshallpivottable.svg b/GUIs.Common/Resources/refreshallpivottable.svg new file mode 100644 index 00000000..29796d3e --- /dev/null +++ b/GUIs.Common/Resources/refreshallpivottable.svg @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/GUIs.Common/frmDocumentResultList.Designer.vb b/GUIs.Common/frmDocumentResultList.Designer.vb index a06317c2..2398c636 100644 --- a/GUIs.Common/frmDocumentResultList.Designer.vb +++ b/GUIs.Common/frmDocumentResultList.Designer.vb @@ -43,6 +43,7 @@ Partial Class frmDocumentResultList Me.MenuItemPropertiesECM = New DevExpress.XtraBars.BarButtonItem() Me.MenuItemsOpenFileZooFlow = New DevExpress.XtraBars.BarButtonItem() Me.MenuItemPropertiesZooFlow = New DevExpress.XtraBars.BarButtonItem() + Me.ButtonRefresh = New DevExpress.XtraBars.BarButtonItem() Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage() Me.RibbonPageGroup_Navigation = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.RibbonPageGroup_Layout = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() @@ -150,9 +151,9 @@ Partial Class frmDocumentResultList 'RibbonControl ' Me.RibbonControl.ExpandCollapseItem.Id = 0 - Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.SwitchMainContainerHorizontal, Me.SwitchDetailContainerHorizontal, Me.BarButtonItemExportGrid1, Me.BarStaticItem1, Me.labelResultCount, Me.BarButtonBack, Me.BarButtonResetLayout, Me.labelCriticalError, Me.labelWarning, Me.MenuItemFileOpen, Me.MenuItemPropertiesIDB, Me.MenuItemFolderOpen, Me.MenuItemFilepathCopy, Me.MenuItemFolderpathCopy, Me.MenuItemPropertiesECM, Me.MenuItemsOpenFileZooFlow, Me.MenuItemPropertiesZooFlow}) + Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.SwitchMainContainerHorizontal, Me.SwitchDetailContainerHorizontal, Me.BarButtonItemExportGrid1, Me.BarStaticItem1, Me.labelResultCount, Me.BarButtonBack, Me.BarButtonResetLayout, Me.labelCriticalError, Me.labelWarning, Me.MenuItemFileOpen, Me.MenuItemPropertiesIDB, Me.MenuItemFolderOpen, Me.MenuItemFilepathCopy, Me.MenuItemFolderpathCopy, Me.MenuItemPropertiesECM, Me.MenuItemsOpenFileZooFlow, Me.MenuItemPropertiesZooFlow, Me.ButtonRefresh}) resources.ApplyResources(Me.RibbonControl, "RibbonControl") - Me.RibbonControl.MaxItemId = 29 + Me.RibbonControl.MaxItemId = 30 Me.RibbonControl.Name = "RibbonControl" Me.RibbonControl.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1}) Me.RibbonControl.RepositoryItems.AddRange(New DevExpress.XtraEditors.Repository.RepositoryItem() {Me.RepositoryItemTextEdit1, Me.RepositoryItemTextEdit2}) @@ -295,6 +296,13 @@ Partial Class frmDocumentResultList Me.MenuItemPropertiesZooFlow.ImageOptions.SvgImage = Global.DigitalData.GUIs.Common.My.Resources.Resources.editcolors Me.MenuItemPropertiesZooFlow.Name = "MenuItemPropertiesZooFlow" ' + 'BarButtonItem1 + ' + resources.ApplyResources(Me.ButtonRefresh, "BarButtonItem1") + Me.ButtonRefresh.Id = 29 + Me.ButtonRefresh.ImageOptions.SvgImage = Global.DigitalData.GUIs.Common.My.Resources.Resources.refreshallpivottable + Me.ButtonRefresh.Name = "BarButtonItem1" + ' 'RibbonPage1 ' Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup_Navigation, Me.RibbonPageGroup_Layout, Me.RibbonPageGroup_Export}) @@ -305,6 +313,7 @@ Partial Class frmDocumentResultList ' Me.RibbonPageGroup_Navigation.AllowTextClipping = False Me.RibbonPageGroup_Navigation.ItemLinks.Add(Me.BarButtonBack) + Me.RibbonPageGroup_Navigation.ItemLinks.Add(Me.ButtonRefresh) Me.RibbonPageGroup_Navigation.Name = "RibbonPageGroup_Navigation" resources.ApplyResources(Me.RibbonPageGroup_Navigation, "RibbonPageGroup_Navigation") ' @@ -571,4 +580,5 @@ Partial Class frmDocumentResultList Friend WithEvents MenuFullAccess_ZOOFLOW As DevExpress.XtraBars.PopupMenu Friend WithEvents MenuItemsOpenFileZooFlow As DevExpress.XtraBars.BarButtonItem Friend WithEvents MenuItemPropertiesZooFlow As DevExpress.XtraBars.BarButtonItem + Friend WithEvents ButtonRefresh As DevExpress.XtraBars.BarButtonItem End Class diff --git a/GUIs.Common/frmDocumentResultList.resx b/GUIs.Common/frmDocumentResultList.resx index ece90751..03bc4f0f 100644 --- a/GUIs.Common/frmDocumentResultList.resx +++ b/GUIs.Common/frmDocumentResultList.resx @@ -426,6 +426,9 @@ Eigenschaften + + Ergebnisse aktualisieren + 0, 0 @@ -975,6 +978,12 @@ DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + BarButtonItem1 + + + DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + RibbonPage1 diff --git a/GUIs.Common/frmDocumentResultList.vb b/GUIs.Common/frmDocumentResultList.vb index 6b02393c..b4b341c4 100644 --- a/GUIs.Common/frmDocumentResultList.vb +++ b/GUIs.Common/frmDocumentResultList.vb @@ -20,6 +20,7 @@ Imports DigitalData.Modules.Logging Imports DigitalData.Modules.ZooFlow Imports DigitalData.Modules.ZooFlow.Constants Imports DigitalData.Modules.Base.IDB.FileStore +Imports DigitalData.Controls.MessageBoxEx Public Class frmDocumentResultList Implements IResultForm @@ -46,7 +47,6 @@ Public Class frmDocumentResultList Private ReadOnly Logger As Logger Private ReadOnly Config As ConfigManager(Of DocumentResultList.Config) Private ReadOnly Environment As Environment - Private ReadOnly ResultLists As List(Of DocumentResultList.DocumentResult) Private ReadOnly Filesystem As Modules.Filesystem.File Private ReadOnly GridBuilder As GridBuilder Private ReadOnly FileEx As Modules.Windows.File @@ -59,6 +59,8 @@ Public Class frmDocumentResultList Private Documentloader As DocumentResultList.Loader ' Runtime variables + Private Property _ResultLists As List(Of DocumentResultList.DocumentResult) + Private _IsLoading As Boolean = True Private _ActiveGrid As GridControl = Nothing Private _ActiveGridBand As GridBand = Nothing @@ -72,6 +74,11 @@ Public Class frmDocumentResultList Public Property ShouldReturnToPreviousForm As Boolean = False Implements IResultForm.ShouldReturnToPreviousForm + Public Event NeedsRefresh As EventHandler(Of Integer) Implements IResultForm.NeedsRefresh + Public Event ResultsRefreshed As EventHandler(Of List(Of DocumentResultList.DocumentResult)) + + Public Delegate Sub SetDatasourceCallback(pDatatable As DataTable) + Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pParams As DocumentResultList.Params) ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() @@ -96,7 +103,7 @@ Public Class frmDocumentResultList Environment = pEnvironment Params = pParams - ResultLists = pParams.Results + _ResultLists = pParams.Results _Language = Utils.NotNull(Me.Environment.User.Language, State.UserState.LANG_EN_US) End Sub @@ -127,6 +134,8 @@ Public Class frmDocumentResultList End If + + Documentloader = New DocumentResultList.Loader(LogConfig, OperationMode, _IDBClient, Environment.User) If Params.WindowTitle <> "" Then @@ -316,26 +325,29 @@ Public Class frmDocumentResultList MsgBox($"Beim Speichern der Datei '{oFileInfo.Name}' Fehler ist ein Fehler aufgetreten!", MsgBoxStyle.Critical, Text) Else MsgBox($"Die Datei '{oFileInfo.Name}' wurde erfolgreich gespeichert!", MsgBoxStyle.Information, Text) + RaiseEvent NeedsRefresh(Me, Params.ProfileGuid) End If End Function Private Async Function Watcher_Ask(pFile As DocumentResultList.Watcher.OpenFile) As Task Dim oFileInfo = New FileInfo(pFile.FilePath) - Dim oMessage = $"Die Datei '{oFileInfo.Name}' wurde außerhalb des Systems verändert. Wollen Sie diese Änderung als neue Version in das System übernehmen? 'Nein' überschreibt die ursprüngliche Datei." - Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.YesNoCancel Or MsgBoxStyle.Question, "Datei verändert") + Dim oMessage = $"Die Datei '{oFileInfo.Name}' wurde außerhalb des Systems verändert. Wollen Sie diese Änderung als neue Version in das System übernehmen oder überschreiben?" - Select Case oResult - Case DialogResult.Yes - Await Watcher_VersionFile(pFile) + Dim oMessageBox As New MsgBoxEx(oMessage, "Datei verändert", MessageBoxIcon.Question) + oMessageBox.SetButtons("Überschreiben", "Neue Version", "Abbrechen") + oMessageBox.ShowDialog() - Case DialogResult.No + Select Case oMessageBox.Result + Case MsgBoxEx.DialogBoxResult.Button1 Await Watcher_OverwriteFile(pFile) + Case MsgBoxEx.DialogBoxResult.Button2 + Await Watcher_VersionFile(pFile) + Case Else ' Cancel, do nothing End Select - End Function @@ -366,7 +378,8 @@ Public Class frmDocumentResultList Return True Catch ex As Exception Logger.Error(ex) - MessageBox.Show("Error while loading results:" & vbNewLine & vbNewLine & ex.Message, Text) + + MessageBox.Show("Error while loading results:" & vbNewLine & vbNewLine & ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error) Return False Finally _IsLoading = False @@ -382,37 +395,49 @@ Public Class frmDocumentResultList Throw New ApplicationException($"Datatable is missing Filepath Column [{COLUMN_FILEPATH}] for search {Result.Title}!") End If - GridControl1.DataSource = Result.Datatable - GridControl1.ForceInitialize() + ' This is needed to update the grid from another form like frmMatch + ' Another form means another thread, so we need a delegate here + If GridControl1.InvokeRequired Then + Dim oCallback As New SetDatasourceCallback(AddressOf SetGridDataSource) + Invoke(oCallback, Result.Datatable) + + Else + SetGridDataSource(Result.Datatable) + End If + End Sub + + Private Sub SetGridDataSource(pTable As DataTable) + GridControl1.DataSource = Nothing + GridControl1.DataSource = pTable End Sub Private Sub UpdateGridData() ' Load Grids - For oIndex = 0 To ResultLists.Count - 1 + For oIndex = 0 To _ResultLists.Count - 1 Select Case oIndex Case 0 - Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(0) + Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(0) LoadGridData(oResult) CreateDocumentGrid(GridView1, oResult) RestoreLayout(GridView1) - UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count) + UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count) Case 1 - Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(1) + Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(1) LoadGridData(oResult) CreateDocumentGrid(GridView2, oResult) RestoreLayout(GridView2) - UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count) + UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count) Case 2 - Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(2) + Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(2) LoadGridData(oResult) CreateDocumentGrid(GridView3, oResult) RestoreLayout(GridView3) - UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count) + UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count) Case Else MessageBox.Show(Constants.MESSAGE_TOO_MANY_SEARCHES, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) @@ -421,7 +446,7 @@ Public Class frmDocumentResultList Next ' Hide Grids depending on Result count - Select Case ResultLists.Count + Select Case _ResultLists.Count Case 0 SplitContainerControl1.SetPanelCollapsed(True) @@ -453,7 +478,7 @@ Public Class frmDocumentResultList Private Sub UpdateTotalResults() Dim oTotalResults = 0 - For Each oList In ResultLists + For Each oList In _ResultLists oTotalResults += oList.Datatable.Rows.Count Next @@ -640,17 +665,17 @@ Public Class frmDocumentResultList Private Sub GridView1_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView1.ColumnFilterChanged Dim oRowCount = sender.RowCount - UpdateGridHeader(ResultLists, 0, oRowCount) + UpdateGridHeader(_ResultLists, 0, oRowCount) End Sub Private Sub GridView2_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView2.ColumnFilterChanged Dim oRowCount = sender.RowCount - UpdateGridHeader(ResultLists, 1, oRowCount) + UpdateGridHeader(_ResultLists, 1, oRowCount) End Sub Private Sub GridView3_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView3.ColumnFilterChanged Dim oRowCount = sender.RowCount - UpdateGridHeader(ResultLists, 2, oRowCount) + UpdateGridHeader(_ResultLists, 2, oRowCount) End Sub Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick @@ -825,8 +850,8 @@ Public Class frmDocumentResultList oPropertyDialog.Show() End Sub - Private Sub MenuItemsOpenFileZooFlow_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemsOpenFileZooFlow.ItemClick - 'TODO: Save file to temp dir and then open + Private Async Sub MenuItemsOpenFileZooFlow_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemsOpenFileZooFlow.ItemClick + Await Watcher.OpenDocument(_CurrentDocument) End Sub #End Region @@ -924,14 +949,10 @@ Public Class frmDocumentResultList End Try End Sub - Private Sub RibbonControl_Click(sender As Object, e As EventArgs) Handles RibbonControl.Click - + Private Sub ButtonRefresh_ItemClick(sender As Object, e As ItemClickEventArgs) Handles ButtonRefresh.ItemClick + RaiseEvent NeedsRefresh(Me, Params.ProfileGuid) End Sub - - - - #End Region End Class \ No newline at end of file