refactor(udt-011): Quartz jobs usan TimeProvider (closes #24) #28
@@ -22,15 +22,18 @@ public sealed class AuditIntegrityCheckJob : IJob
|
|||||||
private readonly SqlConnectionFactory _factory;
|
private readonly SqlConnectionFactory _factory;
|
||||||
private readonly ISecurityEventLogger _security;
|
private readonly ISecurityEventLogger _security;
|
||||||
private readonly ILogger<AuditIntegrityCheckJob> _logger;
|
private readonly ILogger<AuditIntegrityCheckJob> _logger;
|
||||||
|
private readonly TimeProvider _timeProvider;
|
||||||
|
|
||||||
public AuditIntegrityCheckJob(
|
public AuditIntegrityCheckJob(
|
||||||
SqlConnectionFactory factory,
|
SqlConnectionFactory factory,
|
||||||
ISecurityEventLogger security,
|
ISecurityEventLogger security,
|
||||||
ILogger<AuditIntegrityCheckJob> logger)
|
ILogger<AuditIntegrityCheckJob> logger,
|
||||||
|
TimeProvider timeProvider)
|
||||||
{
|
{
|
||||||
_factory = factory;
|
_factory = factory;
|
||||||
_security = security;
|
_security = security;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_timeProvider = timeProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(IJobExecutionContext context)
|
public async Task Execute(IJobExecutionContext context)
|
||||||
@@ -50,7 +53,7 @@ public sealed class AuditIntegrityCheckJob : IJob
|
|||||||
failures.Add($"system_versioning_missing:{string.Join(',', missing)}");
|
failures.Add($"system_versioning_missing:{string.Join(',', missing)}");
|
||||||
|
|
||||||
// 2. Next 3 months have partitions in both event tables
|
// 2. Next 3 months have partitions in both event tables
|
||||||
var now = DateTime.UtcNow;
|
var now = _timeProvider.GetUtcNow().UtcDateTime;
|
||||||
var required = new[]
|
var required = new[]
|
||||||
{
|
{
|
||||||
new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(1),
|
new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(1),
|
||||||
|
|||||||
Reference in New Issue
Block a user