Files
EnvelopeGenerator/EnvelopeGenerator.Service_legacy/Scheduler_FinishEnvelope.vb
TekH eb533a1dc2 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`.
2026-08-27 10:36:01 +02:00

85 lines
2.7 KiB
VB.net

Imports System.Collections.Specialized
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging
Imports EnvelopeGenerator.CommonServices.Jobs
Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument
Imports EnvelopeGenerator.Domain.Constants
Imports Quartz
Public Class Scheduler_FinishEnvelope
Inherits BaseClass
Private Scheduler As IScheduler
Private ReadOnly ConnectionString As String
Private ReadOnly LicenseKey As String
Private Property _pdfBurnerParams As PDFBurnerParams
Private Const JobName = "CertificateDocumentJob"
Public Sub New(pLogConfig As LogConfig, pConnectionString As String, pLicenseKey As String, pdfBurnerParams As PDFBurnerParams)
MyBase.New(pLogConfig)
ConnectionString = pConnectionString
LicenseKey = pLicenseKey
_pdfBurnerParams = pdfBurnerParams
Dim oLogProvider = New LogProvider(Logger)
Logging.LogProvider.SetCurrentLogProvider(oLogProvider)
End Sub
Public Async Function Start(pInterval As Integer) As Task
Try
Logger.Debug("Starting Scheduler Finish Envelope..")
Dim oProperties As New NameValueCollection()
Scheduler = Await SchedulerBuilder.Create(oProperties).
UseDefaultThreadPool(Sub(x) x.MaxConcurrency = 5).
BuildScheduler()
Dim oJobKey = New JobKey(JobName)
Dim oJobData = New JobDataMap() From {
{Value.GDPICTURE, LicenseKey},
{Value.LOGCONFIG, LogConfig},
{Value.DATABASE, ConnectionString},
{Value.PDF_BURNER_PARAMS, _pdfBurnerParams}
}
Logger.Debug("Initialized Job [{0}]", JobName)
Dim oJob As IJobDetail = JobBuilder.Create(Of FinalizeDocumentJob).
UsingJobData(oJobData).
WithIdentity(oJobKey).
Build()
Dim oTrigger As ITrigger = TriggerBuilder.Create().
ForJob(oJobKey).
WithIdentity($"{JobName}-trigger").
WithSimpleSchedule(Sub(s) s.
RepeatForever().
WithIntervalInMinutes(pInterval)).
StartNow().
Build()
Logger.Debug("Initialized Trigger")
Await Scheduler.ScheduleJob(oJob, oTrigger)
Logger.Debug("Job scheduled.")
Await Scheduler.Start()
Logger.Debug("Scheduler started!")
Catch ex As Exception
Logger.Error(ex)
End Try
End Function
Public Async Function [Stop]() As Task
Logger.Info("Stopping scheduler..")
Await Scheduler.Shutdown()
Logger.Info("Scheduler stopped!")
End Function
End Class