- Removed redundant initial info log. - Added detailed logging after job execution: - Logs total finalized envelope count. - Logs UUIDs of finalized envelopes when available. - Logs success message when no envelopes were finalized.
55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
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<FinishEnvelopeJob> _logger;
|
|
|
|
private readonly GdPictureOptions _gdPictureOptions;
|
|
|
|
private readonly IMediator _mediator;
|
|
|
|
public FinishEnvelopeJob(ILogger<FinishEnvelopeJob> logger, IOptions<GdPictureOptions> gdPictureOptions, IMediator mediator)
|
|
{
|
|
_logger = logger;
|
|
_gdPictureOptions = gdPictureOptions.Value;
|
|
_mediator = mediator;
|
|
}
|
|
|
|
public async Task Execute(IJobExecutionContext context)
|
|
{
|
|
var cancel = context.CancellationToken;
|
|
|
|
var envelopes = await _mediator.Send(new ReadEnvelopeQuery()
|
|
{
|
|
Status = new() { Include = [EnvelopeStatus.EnvelopeCompletelySigned] },
|
|
HasDocResult = false
|
|
}, cancel);
|
|
|
|
foreach (var envelope in envelopes)
|
|
{
|
|
// add sub-steps
|
|
}
|
|
|
|
if (envelopes.Any())
|
|
_logger.LogInformation(
|
|
"Job '{JobName}' executed at {Timestamp}. {EnvelopeCount} envelope(s) successfully finalized. UUID(s): {EnvelopeUuids}",
|
|
context.JobDetail.Key.Name,
|
|
DateTimeOffset.Now,
|
|
envelopes.Count(),
|
|
string.Join(", ", envelopes.Select(e => e.Uuid))
|
|
);
|
|
else
|
|
_logger.LogInformation("Job '{JobName}' executed successfully at {Timestamp}. No envelopes were finalized.",
|
|
context.JobDetail.Key.Name,
|
|
DateTimeOffset.Now
|
|
);
|
|
}
|
|
}
|
|
} |