Common: Disable Watcher when opmode = notappserver

This commit is contained in:
Jonathan Jenne 2022-04-05 14:16:44 +02:00
parent f515ebf69f
commit a5fb2dac3f
2 changed files with 30 additions and 7 deletions

View File

@ -11,6 +11,7 @@ Namespace DocumentResultList
Private WithEvents FileOpenTimer As New Timer Private WithEvents FileOpenTimer As New Timer
Private FileEx As Modules.Filesystem.File Private FileEx As Modules.Filesystem.File
Private EnableWatching As Boolean = True
' TODO: Hashes for checking if the opened file was modified externally ' TODO: Hashes for checking if the opened file was modified externally
Private HashOriginalFile As String = Nothing Private HashOriginalFile As String = Nothing
@ -47,8 +48,13 @@ Namespace DocumentResultList
End Class End Class
Public Sub New(pLogConfig As LogConfig) Public Sub New(pLogConfig As LogConfig)
MyClass.New(pLogConfig, True)
End Sub
Public Sub New(pLogConfig As LogConfig, pEnableWatching As Boolean)
MyBase.New(pLogConfig) MyBase.New(pLogConfig)
FileEx = New Modules.Filesystem.File(pLogConfig) FileEx = New Modules.Filesystem.File(pLogConfig)
EnableWatching = pEnableWatching
End Sub End Sub
Public Async Function OpenDocument(pDocument As Document) As Task(Of Boolean) Public Async Function OpenDocument(pDocument As Document) As Task(Of Boolean)
@ -68,6 +74,11 @@ Namespace DocumentResultList
Return False Return False
End If 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 oProcessId = oResult.Item1
Dim oFilePath = oResult.Item2 Dim oFilePath = oResult.Item2

View File

@ -109,7 +109,6 @@ Public Class frmDocumentResultList
Filesystem = New Modules.Filesystem.File(pLogConfig) Filesystem = New Modules.Filesystem.File(pLogConfig)
GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3}) GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3})
FileEx = New Modules.Windows.File(pLogConfig) FileEx = New Modules.Windows.File(pLogConfig)
Watcher = New Watcher(pLogConfig)
LayoutManager = New Layout(pLogConfig, Config, New List(Of GridView) From {GridView1, GridView2, GridView3}) LayoutManager = New Layout(pLogConfig, Config, New List(Of GridView) From {GridView1, GridView2, GridView3})
UserLanguage = Utils.NotNull(Environment.User.Language, State.UserState.LANG_EN_US) UserLanguage = Utils.NotNull(Environment.User.Language, State.UserState.LANG_EN_US)
@ -141,7 +140,13 @@ Public Class frmDocumentResultList
End If 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 If Params.WindowTitle <> "" Then
Text = $"{Text} - {Params.WindowTitle}" Text = $"{Text} - {Params.WindowTitle}"
@ -165,8 +170,11 @@ Public Class frmDocumentResultList
' Hide options relating to a filepath for zooflow ' Hide options relating to a filepath for zooflow
If OperationMode = OperationMode.ZooFlow Then If OperationMode = OperationMode.ZooFlow Then
RibbonPageGroupFilesystem.Visible = False RibbonPageGroupFilesystem.Visible = False
Else End If
RibbonPageGroupFilesystem.Visible = False
If OperationMode = OperationMode.NoAppServer Then
RibbonPageCategoryAttribute.Visible = False
RibbonPageActions2.Visible = False
End If End If
If OperationMode = OperationMode.ZooFlow Or OperationMode = OperationMode.WithAppServer Then If OperationMode = OperationMode.ZooFlow Or OperationMode = OperationMode.WithAppServer Then
@ -793,9 +801,13 @@ Public Class frmDocumentResultList
End Sub End Sub
Private Async Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick 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 Try
Await Watcher.OpenDocument(_CurrentDocument) If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then
End If Await Watcher.OpenDocument(_CurrentDocument)
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub End Sub
Private Sub BarButtonResetLayout_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonResetLayout.ItemClick Private Sub BarButtonResetLayout_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonResetLayout.ItemClick