ZUGFeRD Service: Clean up
This commit is contained in:
parent
a16d40169d
commit
6df0d3deff
@ -68,9 +68,6 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=7.5.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\FirebirdSql.Data.FirebirdClient.7.5.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NLog.5.0.5\lib\net46\NLog.dll</HintPath>
|
<HintPath>..\packages\NLog.5.0.5\lib\net46\NLog.dll</HintPath>
|
||||||
|
|||||||
@ -18,10 +18,7 @@ Public Class ThreadRunner
|
|||||||
Private ReadOnly _jobArguments As WorkerArgs
|
Private ReadOnly _jobArguments As WorkerArgs
|
||||||
Private ReadOnly _mssql As MSSQLServer
|
Private ReadOnly _mssql As MSSQLServer
|
||||||
|
|
||||||
Private ReadOnly RejectedMaxDifferenceInMinutes As Integer = 60
|
Public Sub New(LogConfig As LogConfig, ConfigManager As ConfigManager(Of Config), MSSQL As MSSQLServer)
|
||||||
Private RejectedLastRun As Date = Now.AddMinutes(-(RejectedMaxDifferenceInMinutes - 1))
|
|
||||||
|
|
||||||
Public Sub New(LogConfig As LogConfig, ConfigManager As ConfigManager(Of Config), Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
|
|
||||||
_logConfig = LogConfig
|
_logConfig = LogConfig
|
||||||
_logger = _logConfig.GetLogger()
|
_logger = _logConfig.GetLogger()
|
||||||
_config = ConfigManager
|
_config = ConfigManager
|
||||||
|
|||||||
@ -5,48 +5,42 @@ Imports DigitalData.Modules.Logging
|
|||||||
Imports DigitalData.Modules.Logging.LogConfig
|
Imports DigitalData.Modules.Logging.LogConfig
|
||||||
|
|
||||||
Public Class ZUGFeRDService
|
Public Class ZUGFeRDService
|
||||||
Private _config As ConfigManager(Of Config)
|
Private LogConfig As LogConfig
|
||||||
Private _logConfig As LogConfig
|
Private Logger As Logger
|
||||||
Private _logger As Logger
|
Private ThreadRunner As ThreadRunner
|
||||||
Private _firebird As Firebird
|
|
||||||
Private _mssql As MSSQLServer = Nothing
|
|
||||||
|
|
||||||
Private _threadRunner As ThreadRunner
|
|
||||||
|
|
||||||
Protected Overrides Sub OnStart(args() As String)
|
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
|
Try
|
||||||
_threadRunner = New ThreadRunner(_logConfig, _config, _firebird, _mssql)
|
LogConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, "Digital Data", "DDZUGFeRDService")
|
||||||
_threadRunner.Start(oJobInterval)
|
Dim oConfig = New ConfigManager(Of Config)(LogConfig, My.Application.Info.DirectoryPath)
|
||||||
|
LogConfig.Debug = oConfig.Config.Debug
|
||||||
|
Logger = LogConfig.GetLogger()
|
||||||
|
Logger.Info($"{Constants.SERVICE_NAME} is starting.")
|
||||||
|
|
||||||
|
If oConfig.Config.MSSQLConnectionString = String.Empty Then
|
||||||
|
Logger.Warn("MSSQL Connectionstring is empty. Exiting.")
|
||||||
|
Throw New ArgumentNullException("ConnectionString is missing!")
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim oDatabase = New MSSQLServer(LogConfig, oConfig.Config.MSSQLConnectionString)
|
||||||
|
|
||||||
|
If oDatabase.DBInitialized = False Then
|
||||||
|
Logger.Warn("MSSQL Connection failed. Exiting.")
|
||||||
|
Throw New ApplicationException("Connection failed!")
|
||||||
|
End If
|
||||||
|
|
||||||
|
ThreadRunner = New ThreadRunner(LogConfig, oConfig, oDatabase)
|
||||||
|
ThreadRunner.Start(oConfig.Config.JobInterval)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
Logger.Warn("Starting the Service failed.")
|
||||||
|
Logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Protected Overrides Sub OnStop()
|
Protected Overrides Sub OnStop()
|
||||||
_logger.Info($"{Constants.SERVICE_NAME} is stopping.")
|
Logger.Info($"{Constants.SERVICE_NAME} is stopping.")
|
||||||
|
ThreadRunner.Stop()
|
||||||
_threadRunner.Stop()
|
Logger.Info($"{Constants.SERVICE_NAME} stopped.")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="FirebirdSql.Data.FirebirdClient" version="7.5.0" targetFramework="net461" />
|
|
||||||
<package id="NLog" version="5.0.5" targetFramework="net461" />
|
<package id="NLog" version="5.0.5" targetFramework="net461" />
|
||||||
</packages>
|
</packages>
|
||||||
Loading…
x
Reference in New Issue
Block a user