First version of service

This commit is contained in:
Jonathan Jenne
2023-12-08 15:23:50 +01:00
parent feb429f8f8
commit 49e6da3d79
5 changed files with 85 additions and 49 deletions

View File

@@ -10,12 +10,14 @@ Public Class Scheduler
Private Scheduler As IScheduler
Private ConnectionString As String
Private LicenseKey As String
Private Const JobName = "CertificateDocumentJob"
Public Sub New(pLogConfig As LogConfig, pConnectionString As String)
Public Sub New(pLogConfig As LogConfig, pConnectionString As String, pLicenseKey As String)
MyBase.New(pLogConfig)
ConnectionString = pConnectionString
LicenseKey = pLicenseKey
End Sub
Public Async Function Start(pInterval As Integer) As Task
@@ -29,6 +31,7 @@ Public Class Scheduler
Dim oJobKey = New JobKey(JobName)
Dim oJobData = New JobDataMap() From {
{Common.Constants.GDPICTURE, LicenseKey},
{Common.Constants.LOGCONFIG, LogConfig},
{Common.Constants.DATABASE, ConnectionString}
}

View File

@@ -6,6 +6,7 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Messaging
Imports DigitalData.Modules.Config
Imports GdPicture.Internal.WPF
Public Class Service
Private Logger As Logger
@@ -37,19 +38,27 @@ Public Class Service
Logger.Info("Inititalize Databases")
If Config.ConnectionString <> String.Empty Then
Database = New MSSQLServer(LogConfig, Config.ConnectionString)
If Config.ConnectionString = String.Empty Then
Throw New ApplicationException("Connection String is empty!")
End If
If Database.DBInitialized = False Then
Logger.Warn("MSSQL Connection could not be established. Check the Error Log")
End If
Database = New MSSQLServer(LogConfig, Config.ConnectionString)
If Database.DBInitialized = False Then
Throw New ApplicationException("Database connection could not be established!")
End If
Dim oKey = Database.GetScalarValue("SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'")
If String.IsNullOrWhiteSpace(oKey) Then
Throw New ApplicationException("GDPicture License could not be loaded!")
End If
' === Initialize Queue ===
Logger.Debug("Inititalize Quartz")
Scheduler = New Scheduler(LogConfig, Config.ConnectionString)
Scheduler = New Scheduler(LogConfig, Config.ConnectionString, oKey)
Await Scheduler.Start(Config.IntervalInMin)
Logger.Info("Started [{0}] !", ServiceName)