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