First Pass of new control loader add BaseClass that provides Logger

This commit is contained in:
Jonathan Jenne
2019-03-22 16:26:15 +01:00
parent 0f4c04dde7
commit 968435c3f7
18 changed files with 379 additions and 94 deletions

View File

@@ -5,6 +5,8 @@ Imports DigitalData.Modules.EDMIFileOps.EDMIServiceReference
Imports DigitalData.Modules.Logging
Public Class ClassTimer
Inherits BaseClass
Private _Callback As TimerCallback
Private _LogConfig As LogConfig
Private _Logger As Logger
@@ -15,10 +17,9 @@ Public Class ClassTimer
Public Delegate Sub OnlineChangedEventHandler(sender As Object, Online As Boolean)
Public Sub New(LogConfig As LogConfig, SynchronizingObject As frmMain, HeartbeatInterval As Integer)
Try
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger()
MyBase.New(LogConfig)
Try
_Channel = My.ChannelFactory.CreateChannel()
_Channel.Open()
@@ -29,13 +30,13 @@ Public Class ClassTimer
AddHandler _Timer.Elapsed, AddressOf Callback
Catch ex As Exception
_Logger.Error(ex)
Logger.Error(ex)
End Try
End Sub
Public Async Sub Callback(sender As Object, e As ElapsedEventArgs)
Try
_Logger.Debug("Checking if Service is up...")
Logger.Debug("Checking if Service is up...")
If _Channel.State = ServiceModel.CommunicationState.Faulted Then
_Channel = My.ChannelFactory.CreateChannel()
@@ -44,12 +45,11 @@ Public Class ClassTimer
' Connect to service and send hearbeat request
Dim oResult = Await _Channel.HeartbeatAsync()
_Logger.Debug("Service is online")
Logger.Debug("Service is online")
SetOnlineState(True)
Catch ex As Exception
_Logger.Debug("Service is offline!")
Logger.Debug("Service is offline!")
SetOnlineState(False)
Finally