Übersetzendie FinalizeDocumentJob-Funktion des EnvelopeGenerator.Service-Projekts in C# und kopieren sie.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using DigitalData.Modules.Logging;
|
||||
using EnvelopeGenerator.ServiceHost.Jobs.FinalizeDocument;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Quartz;
|
||||
|
||||
namespace EnvelopeGenerator.ServiceHost.Jobs;
|
||||
|
||||
public interface IFinalizeDocumentJobRunner
|
||||
{
|
||||
Task RunAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public class FinalizeDocumentJobRunner : IFinalizeDocumentJobRunner
|
||||
{
|
||||
private readonly FinalizeDocumentJob _job;
|
||||
private readonly IOptions<FinalizeDocumentJobOptions> _options;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<FinalizeDocumentJobRunner> _logger;
|
||||
|
||||
public FinalizeDocumentJobRunner(
|
||||
FinalizeDocumentJob job,
|
||||
IOptions<FinalizeDocumentJobOptions> options,
|
||||
IConfiguration configuration,
|
||||
ILogger<FinalizeDocumentJobRunner> logger)
|
||||
{
|
||||
_job = job;
|
||||
_options = options;
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task RunAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var options = _options.Value;
|
||||
var connectionString = options.ConnectionString;
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
connectionString = _configuration.GetConnectionString("Default") ?? string.Empty;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
_logger.LogWarning("FinalizeDocumentJob skipped: missing connection string.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var dataMap = new JobDataMap
|
||||
{
|
||||
{ JobDataKeys.GdPicture, options.GdPictureLicenseKey },
|
||||
{ JobDataKeys.Database, connectionString },
|
||||
{ JobDataKeys.LogConfig, new LogConfig { Debug = options.Debug } },
|
||||
{ JobDataKeys.PdfBurnerParams, options.PdfBurnerParams }
|
||||
};
|
||||
|
||||
return _job.Execute(dataMap, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user