Replace EnvelopeGenerator.Service with Service_legacy
The project `EnvelopeGenerator.Service` has been removed from the solution and replaced with a new project, `EnvelopeGenerator.Service_legacy`. Updated build configuration mappings to reflect the addition of `Service_legacy` and the removal of `Service`. Adjusted project nesting to place `Service_legacy` under the same parent as the removed `Service`.
This commit is contained in:
87
EnvelopeGenerator.Service_legacy/Service.vb
Normal file
87
EnvelopeGenerator.Service_legacy/Service.vb
Normal file
@@ -0,0 +1,87 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports System.Threading
|
||||
|
||||
Public Class Service
|
||||
Private Logger As Logger
|
||||
Private LogConfig As LogConfig
|
||||
Private ConfigManager As ConfigManager(Of Config)
|
||||
Private Config As Config
|
||||
Private Database As MSSQLServer
|
||||
Private TempFiles As TempFiles
|
||||
Private Scheduler1 As Scheduler_FinishEnvelope
|
||||
Private Scheduler2 As Scheduler_Envelopetask_API
|
||||
|
||||
Protected Overrides Async Sub OnStart(ByVal args() As String)
|
||||
Try
|
||||
' === Initialize Logger ===
|
||||
Dim oLogPath = Path.Combine(My.Application.Info.DirectoryPath, "Log")
|
||||
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, Nothing, "Digital Data", "EnvelopeGenerator.Service")
|
||||
|
||||
' === Initialize Config ===
|
||||
ConfigManager = New ConfigManager(Of Config)(LogConfig, My.Application.Info.DirectoryPath)
|
||||
Config = ConfigManager.Config
|
||||
|
||||
LogConfig.Debug = Config.Debug
|
||||
|
||||
Logger = LogConfig.GetLogger()
|
||||
Logger.Info($"DEBUG = {LogConfig.Debug}")
|
||||
|
||||
Logger.Info("Starting [{0}]", ServiceName)
|
||||
TempFiles = New TempFiles(LogConfig)
|
||||
TempFiles.Create()
|
||||
|
||||
' === Initialize Databases ===
|
||||
Logger.Debug("Inititalize Database ...")
|
||||
|
||||
If Config.ConnectionString = String.Empty Then
|
||||
Throw New ApplicationException("Connection String is empty!")
|
||||
End If
|
||||
|
||||
Database = New MSSQLServer(LogConfig, Config.ConnectionString)
|
||||
Logger.Debug("Database initialized")
|
||||
|
||||
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' and ACTIVE = 1")
|
||||
|
||||
If String.IsNullOrWhiteSpace(oKey) Then
|
||||
Throw New ApplicationException("GDPicture License could not be loaded!")
|
||||
End If
|
||||
|
||||
' === Initialize Queue ===
|
||||
|
||||
Logger.Debug("Inititalizing scheduler(s) ...")
|
||||
|
||||
Scheduler1 = New Scheduler_FinishEnvelope(LogConfig, Config.ConnectionString, oKey, Config.PDFBurnerParams)
|
||||
Await Scheduler1.Start(Config.IntervalInMin)
|
||||
|
||||
Thread.Sleep(2500)
|
||||
|
||||
Scheduler2 = New Scheduler_Envelopetask_API(LogConfig, Config.ConnectionString)
|
||||
Await Scheduler2.Start(Config.IntervalInMin)
|
||||
|
||||
Logger.Info("Started [{0}] !", ServiceName)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Overrides Async Sub OnStop()
|
||||
Try
|
||||
Logger.Info("Stopping [{0}] ...", ServiceName)
|
||||
Await Scheduler1.Stop()
|
||||
Await Scheduler2.Stop()
|
||||
TempFiles.CleanUp()
|
||||
Logger.Info("Stopped [{0}] !", ServiceName)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user