Класс WorkToDeleteOldReports вынесен в отдельный файл

This commit is contained in:
Olga Nemt 2023-11-10 10:11:36 +05:00
parent 5ad342d4d3
commit 66c0e6ad65
3 changed files with 24 additions and 15 deletions

View File

@ -0,0 +1,23 @@
using AsbCloudApp.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Background
{
public class WorkToDeleteOldReports : Work
{
public WorkToDeleteOldReports()
: base("work to delete reports older than 30 days")
{
Timeout = TimeSpan.FromMinutes(10);
}
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
{
var reportService = services.GetRequiredService<IReportService>();
await reportService.DeleteAllOldReportsAsync(-30, token);
}
}
}

View File

@ -18,20 +18,6 @@ namespace AsbCloudInfrastructure.Services
public class ReportService : IReportService
{
public class WorkToDeleteOldReports : Work
{
public WorkToDeleteOldReports()
: base("work to delete reports older than 30 days")
{
Timeout = TimeSpan.FromMinutes(10);
}
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
{
var reportService = services.GetRequiredService<IReportService>();
await reportService.DeleteAllOldReportsAsync(-30, token);
}
}
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
private readonly FileService fileService;

View File

@ -29,7 +29,7 @@ namespace AsbCloudInfrastructure
_ = provider.GetRequiredService<ITelemetryDataCache<TelemetryDataSpinDto>>();
var backgroundWorker = provider.GetRequiredService<PeriodicBackgroundWorker>();
backgroundWorker.Add<ReportService.WorkToDeleteOldReports>(TimeSpan.FromDays(1));
backgroundWorker.Add<WorkToDeleteOldReports>(TimeSpan.FromDays(1));
backgroundWorker.Add<WellInfoService.WorkWellInfoUpdate>(TimeSpan.FromMinutes(30));
backgroundWorker.Add<WorkOperationDetection>(TimeSpan.FromMinutes(15));
backgroundWorker.Add<WorkSubsystemOperationTimeCalc>(TimeSpan.FromMinutes(30));