refactor(udt-011): Quartz jobs usan TimeProvider (closes #24) #28

Merged
dmolinari merged 4 commits from fix/UDT-011-quartz-jobs-timeprovider into main 2026-04-18 14:08:11 +00:00
Showing only changes of commit b79dfb2f34 - Show all commits

View File

@@ -19,11 +19,13 @@ public sealed class AuditPartitionManagerJob : IJob
private readonly SqlConnectionFactory _factory;
private readonly ILogger<AuditPartitionManagerJob> _logger;
private readonly TimeProvider _timeProvider;
public AuditPartitionManagerJob(SqlConnectionFactory factory, ILogger<AuditPartitionManagerJob> logger)
public AuditPartitionManagerJob(SqlConnectionFactory factory, ILogger<AuditPartitionManagerJob> logger, TimeProvider timeProvider)
{
_factory = factory;
_logger = logger;
_timeProvider = timeProvider;
}
public async Task Execute(IJobExecutionContext context)
@@ -34,7 +36,7 @@ public sealed class AuditPartitionManagerJob : IJob
// Target: boundary for "next month + 1" (so the next month is always pre-created and we
// keep at least one boundary ahead after the rotation).
var now = DateTime.UtcNow;
var now = _timeProvider.GetUtcNow().UtcDateTime;
var target = new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(2);
var affected = 0;