DD.WellWorkover.Cloud/AsbCloudInfrastructure/Background/WorkToDeleteOldReports.cs

35 lines
1.2 KiB
C#

using AsbCloudApp.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Background
{
/// <summary>
/// Задача по удалению загруженных отчетов
/// </summary>
public class WorkToDeleteOldReports : Work
{
public WorkToDeleteOldReports()
: base("work to delete reports older than 30 days")
{
Timeout = TimeSpan.FromMinutes(10);
}
/// <summary>
/// Удаление отчетов, загруженных ранее 30 дней от текущей даты
/// </summary>
/// <param name="id"></param>
/// <param name="services"></param>
/// <param name="onProgressCallback"></param>
/// <param name="token"></param>
/// <returns></returns>
protected override async Task Action(string id, IServiceProvider services, Action<string, double?> onProgressCallback, CancellationToken token)
{
var reportService = services.GetRequiredService<IReportService>();
await reportService.DeleteAllOldReportsAsync(TimeSpan.FromDays(30), token);
}
}
}