1
0
mirror of synced 2024-12-20 18:25:52 +01:00
GC-local-server-rewrite/Application/Jobs/MaintainTenpoIdJob.cs

37 lines
1.4 KiB
C#
Raw Normal View History

2023-02-16 08:26:13 +01:00
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using Quartz;
namespace Application.Jobs;
public class MaintainTenpoIdJob : IJob
{
private readonly ILogger<MaintainTenpoIdJob> logger;
private readonly ICardDbContext cardDbContext;
public static readonly JobKey KEY = new("MaintainTenpoIdJob");
public MaintainTenpoIdJob(ILogger<MaintainTenpoIdJob> logger, ICardDbContext cardDbContext)
{
this.logger = logger;
this.cardDbContext = cardDbContext;
}
[SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records",
Justification = "All details might be read")]
2023-02-16 09:04:38 +01:00
[SuppressMessage("ReSharper.DPA", "DPA0006: Large number of DB commands")]
2023-02-16 08:26:13 +01:00
public async Task Execute(IJobExecutionContext context)
{
logger.LogInformation("Starting changing null values in card detail table");
2023-02-16 09:04:38 +01:00
var details = await cardDbContext.CardDetails.Where(detail => detail.LastPlayTenpoId == null ||
detail.LastPlayTenpoId == "GC local server").ToListAsync();
2023-02-16 08:26:13 +01:00
details.ForEach(detail => detail.LastPlayTenpoId="1337");
cardDbContext.CardDetails.UpdateRange(details);
var count = await cardDbContext.SaveChangesAsync(new CancellationToken());
logger.LogInformation("Updated {Count} entries in card detail table", count);
}
}