ClipboardWatcher: Fix null ref when client is not initialized in Environment

This commit is contained in:
Jonathan Jenne 2022-11-08 08:54:41 +01:00
parent 456a729f46
commit 9708b0ddeb

View File

@ -12,10 +12,9 @@ Imports DigitalData.Modules.ZooFlow.Params
Public Class ProfileSearches Public Class ProfileSearches
Inherits BaseClass Inherits BaseClass
Private _Environment As Environment Private ReadOnly _Environment As Environment
Private _Client As Client Private ReadOnly _Client As Client
Private ReadOnly _ClipboardContents As String
Private _ClipboardContents As String
Public Class Search Public Class Search
Public Guid As Integer Public Guid As Integer
@ -32,7 +31,7 @@ Public Class ProfileSearches
_Environment = pEnvironment _Environment = pEnvironment
_ClipboardContents = pClipboardContents _ClipboardContents = pClipboardContents
Try Try
If _Environment.Service.Client.IsOnline = True Then If _Environment.Service.Client IsNot Nothing AndAlso _Environment.Service.Client.IsOnline = True Then
Try Try
Dim oSplit() As String = _Environment.Service.Address.Split(":") Dim oSplit() As String = _Environment.Service.Address.Split(":")
Dim oAppServerAddress As String = oSplit(0) Dim oAppServerAddress As String = oSplit(0)
@ -50,6 +49,8 @@ Public Class ProfileSearches
Logger.Warn($"Could not initialize the AppServer: {ex.Message}") Logger.Warn($"Could not initialize the AppServer: {ex.Message}")
Logger.Error(ex) Logger.Error(ex)
End Try End Try
Else
Logger.Debug("No client found in Env.")
End If End If
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
@ -82,9 +83,7 @@ Public Class ProfileSearches
End Function End Function
Public Async Function LoadDocumentSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search)) Public Async Function LoadDocumentSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
Return Await Task.Run(Function() Return Await Task.Run(Function() DoLoadDocumentSearches(ProfileId))
Return DoLoadDocumentSearches(ProfileId)
End Function)
End Function End Function
Private Function DoLoadDocumentSearches(ProfileId As Integer) As List(Of Search) Private Function DoLoadDocumentSearches(ProfileId As Integer) As List(Of Search)
@ -146,9 +145,7 @@ Public Class ProfileSearches
End Function End Function
Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search)) Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
Return Await Task.Run(Function() Return Await Task.Run(Function() DoLoadDataSearches(ProfileId))
Return DoLoadDataSearches(ProfileId)
End Function)
End Function End Function
Private Function DoLoadDataSearches(ProfileId As Integer) As List(Of Search) Private Function DoLoadDataSearches(ProfileId As Integer) As List(Of Search)