diff --git a/GUIs.Common/DocumentResultList/Watcher.vb b/GUIs.Common/DocumentResultList/Watcher.vb index fffe768b..c529cf7d 100644 --- a/GUIs.Common/DocumentResultList/Watcher.vb +++ b/GUIs.Common/DocumentResultList/Watcher.vb @@ -11,6 +11,7 @@ Namespace DocumentResultList Private WithEvents FileOpenTimer As New Timer Private FileEx As Modules.Filesystem.File + Private EnableWatching As Boolean = True ' TODO: Hashes for checking if the opened file was modified externally Private HashOriginalFile As String = Nothing @@ -47,8 +48,13 @@ Namespace DocumentResultList End Class Public Sub New(pLogConfig As LogConfig) + MyClass.New(pLogConfig, True) + End Sub + + Public Sub New(pLogConfig As LogConfig, pEnableWatching As Boolean) MyBase.New(pLogConfig) FileEx = New Modules.Filesystem.File(pLogConfig) + EnableWatching = pEnableWatching End Sub Public Async Function OpenDocument(pDocument As Document) As Task(Of Boolean) @@ -68,6 +74,11 @@ Namespace DocumentResultList Return False End If + If EnableWatching = False Then + Logger.Debug("File was opened. Watching and Events are disabled.") + Return True + End If + Dim oProcessId = oResult.Item1 Dim oFilePath = oResult.Item2 diff --git a/GUIs.Common/frmDocumentResultList.vb b/GUIs.Common/frmDocumentResultList.vb index 2d2a375a..e6de5582 100644 --- a/GUIs.Common/frmDocumentResultList.vb +++ b/GUIs.Common/frmDocumentResultList.vb @@ -109,7 +109,6 @@ Public Class frmDocumentResultList Filesystem = New Modules.Filesystem.File(pLogConfig) GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3}) FileEx = New Modules.Windows.File(pLogConfig) - Watcher = New Watcher(pLogConfig) LayoutManager = New Layout(pLogConfig, Config, New List(Of GridView) From {GridView1, GridView2, GridView3}) UserLanguage = Utils.NotNull(Environment.User.Language, State.UserState.LANG_EN_US) @@ -141,7 +140,13 @@ Public Class frmDocumentResultList End If - Documentloader = New DocumentResultList.Loader(LogConfig, OperationMode, Client, Environment.User) + Documentloader = New Loader(LogConfig, OperationMode, Client, Environment.User) + + If OperationMode = OperationMode.NoAppServer Then + Watcher = New Watcher(LogConfig, pEnableWatching:=False) + Else + Watcher = New Watcher(LogConfig) + End If If Params.WindowTitle <> "" Then Text = $"{Text} - {Params.WindowTitle}" @@ -165,8 +170,11 @@ Public Class frmDocumentResultList ' Hide options relating to a filepath for zooflow If OperationMode = OperationMode.ZooFlow Then RibbonPageGroupFilesystem.Visible = False - Else - RibbonPageGroupFilesystem.Visible = False + End If + + If OperationMode = OperationMode.NoAppServer Then + RibbonPageCategoryAttribute.Visible = False + RibbonPageActions2.Visible = False End If If OperationMode = OperationMode.ZooFlow Or OperationMode = OperationMode.WithAppServer Then @@ -793,9 +801,13 @@ Public Class frmDocumentResultList End Sub Private Async Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick - If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then - Await Watcher.OpenDocument(_CurrentDocument) - End If + Try + If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then + Await Watcher.OpenDocument(_CurrentDocument) + End If + Catch ex As Exception + Logger.Error(ex) + End Try End Sub Private Sub BarButtonResetLayout_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonResetLayout.ItemClick