53 lines
1.9 KiB
VB.net
53 lines
1.9 KiB
VB.net
Imports System.IO
|
|
Imports DigitalData.Modules.Config
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Logging.LogConfig
|
|
|
|
Public Class ZUGFeRDService
|
|
Private _config As ConfigManager(Of Config)
|
|
Private _logConfig As LogConfig
|
|
Private _logger As Logger
|
|
Private _firebird As Firebird
|
|
Private _mssql As MSSQLServer = Nothing
|
|
|
|
Private _threadRunner As ThreadRunner
|
|
|
|
Protected Overrides Sub OnStart(args() As String)
|
|
_logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, "Digital Data", "DDZUGFeRDService")
|
|
_config = New ConfigManager(Of Config)(_logConfig, My.Application.Info.DirectoryPath)
|
|
_logConfig.Debug = _config.Config.Debug
|
|
_logger = _logConfig.GetLogger()
|
|
_logger.Info($"{Constants.SERVICE_NAME} is starting.")
|
|
|
|
Dim oJobInterval As Integer = _config.Config.JobInterval
|
|
Dim oMSSQLConnectionString As String = _config.Config.MSSQLConnectionString
|
|
|
|
If oMSSQLConnectionString = String.Empty Then
|
|
_logger.Warn("MSSQL Connectionstring is empty. Exiting.")
|
|
Throw New ArgumentNullException("ConnectionString is missing!")
|
|
End If
|
|
|
|
_mssql = New MSSQLServer(_logConfig, oMSSQLConnectionString)
|
|
|
|
If _mssql.DBInitialized = False Then
|
|
_logger.Warn("MSSQL Connection failed. Exiting.")
|
|
Throw New ApplicationException("Connection failed!")
|
|
End If
|
|
|
|
Try
|
|
_threadRunner = New ThreadRunner(_logConfig, _config, _firebird, _mssql)
|
|
_threadRunner.Start(oJobInterval)
|
|
Catch ex As Exception
|
|
_logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnStop()
|
|
_logger.Info($"{Constants.SERVICE_NAME} is stopping.")
|
|
|
|
_threadRunner.Stop()
|
|
End Sub
|
|
|
|
End Class
|