Refactor job execution to remove Quartz and job runner

Simplify FinalizeDocumentJob execution by removing Quartz dependencies and the IFinalizeDocumentJobRunner abstraction. The job now uses an ExecuteAsync method with direct access to configuration and options via dependency injection. Worker is updated to call the job directly, and service registration is streamlined. This improves clarity and integration with .NET DI.
This commit is contained in:
2026-02-25 13:29:00 +01:00
parent 9d5e2e6ad2
commit 45b715ed74
4 changed files with 12 additions and 68 deletions

View File

@@ -49,14 +49,14 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
public byte[]? DocAsByte { get; set; }
}
public Task Execute(IJobExecutionContext context)
public Task ExecuteAsync(CancellationToken cancellationToken = default)
{
var gdPictureKey = (string)context.MergedJobDataMap[Value.GDPICTURE];
_logConfig = (LogConfig)context.MergedJobDataMap[Value.LOGCONFIG];
var gdPictureKey = _options.GdPictureLicenseKey;
_logConfig = new LogConfig { Debug = _options.Debug };
_logger = _logConfig.GetLogger();
_tempFiles = new TempFiles(_logConfig);
_tempFiles.Create();
var jobId = context.JobDetail.Key;
var jobId = typeof(FinalizeDocumentJob).FullName;
_logger.Debug("Starting job {0}", jobId);
try
@@ -66,7 +66,7 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
_licenseManager.RegisterKEY(gdPictureKey);
_logger.Debug("Loading Database..");
var connectionString = (string)context.MergedJobDataMap[Value.DATABASE];
var connectionString = config.GetConnectionString("Default") ?? throw new InvalidOperationException("Connection string 'Default' not found.");
_databaseConnectionString = MSSQLServer.DecryptConnectionString(connectionString);
_database = new MSSQLServer(_logConfig, _databaseConnectionString);
@@ -81,7 +81,7 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
InitializeServices(state);
_logger.Debug("Loading PDFBurner..");
var pdfBurnerParams = (PDFBurnerParams)context.MergedJobDataMap[Value.PDF_BURNER_PARAMS];
var pdfBurnerParams = _options.PdfBurnerParams;
_pdfBurner = new PDFBurner(_logConfig, gdPictureKey, pdfBurnerParams, _databaseConnectionString);
_logger.Debug("Loading PDFMerger..");