using EnvelopeGenerator.Application.Envelopes.Queries; using EnvelopeGenerator.Domain.Constants; using EnvelopeGenerator.Finalizer.Models; using MediatR; using Microsoft.Extensions.Options; using Quartz; namespace EnvelopeGenerator.Finalizer.Job { public class FinishEnvelopeJob : IJob { private readonly ILogger _logger; private readonly GdPictureOptions _gdPictureOptions; private readonly IMediator _mediator; public FinishEnvelopeJob(ILogger logger, IOptions gdPictureOptions, IMediator mediator) { _logger = logger; _gdPictureOptions = gdPictureOptions.Value; _mediator = mediator; } public async Task Execute(IJobExecutionContext context) { var cancel = context.CancellationToken; if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("{jobName} running at: {time}", context.JobDetail.Key, DateTimeOffset.Now); } var envelopes = await _mediator.Send(new ReadEnvelopeQuery() { Status = new() { Include = [EnvelopeStatus.EnvelopeCompletelySigned] }, HasDocResult = false }, cancel); foreach (var envelope in envelopes) { // add sub-steps } } } }