65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
|
|
using Microsoft.Extensions.Logging;
|
|||
|
|
using PARR.DAL.DomainModels;
|
|||
|
|
using PARR.DAL.Services.Interfaces;
|
|||
|
|
|
|||
|
|
namespace PARR.DAL.TransformServices
|
|||
|
|
{
|
|||
|
|
internal class EsppScheduleTransformService : IEsppScheduleTransformService
|
|||
|
|
{
|
|||
|
|
private readonly IEsppSchTypeConfigService esppSchTypeConfigService;
|
|||
|
|
private readonly ILogger<EsppScheduleTransformService> logger;
|
|||
|
|
|
|||
|
|
public EsppScheduleTransformService(IEsppSchTypeConfigService esppSchTypeConfigService, ILogger<EsppScheduleTransformService> logger)
|
|||
|
|
{
|
|||
|
|
this.esppSchTypeConfigService = esppSchTypeConfigService;
|
|||
|
|
this.logger = logger;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public DateTimeOffset GetNextDate(EsppScheduleDto esppSchedule, DateTimeOffset lastRun)
|
|||
|
|
{
|
|||
|
|
//todo:
|
|||
|
|
|
|||
|
|
return lastRun;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public List<DateTimeOffset> GetNextSchedule(EsppScheduleDto esppSchedule, DateTimeOffset lastRun)
|
|||
|
|
{
|
|||
|
|
var schedules = new List<DateTimeOffset>();
|
|||
|
|
|
|||
|
|
//todo:
|
|||
|
|
schedules.Add(lastRun);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
return schedules.OrderBy(t => t).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public async Task<DateTimeOffset> GetNextDateAsync(Guid applicationInWorkId, DateTimeOffset lastRun)
|
|||
|
|
{
|
|||
|
|
return GetNextDate(await GetEsppSchedule(applicationInWorkId), lastRun);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public async Task<List<DateTimeOffset>> GetNextScheduleAsync(Guid applicationInWorkId, DateTimeOffset lastRun)
|
|||
|
|
{
|
|||
|
|
return GetNextSchedule(await GetEsppSchedule(applicationInWorkId), lastRun);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private async Task<EsppScheduleDto> GetEsppSchedule(Guid applicationInWorkId)
|
|||
|
|
{
|
|||
|
|
var esppSchedule = await esppSchTypeConfigService.GetEsppScheduleDtoAsync(applicationInWorkId);
|
|||
|
|
if (esppSchedule == null)
|
|||
|
|
{
|
|||
|
|
logger.LogError($"Не найдено расписание в БД, applicationInWorkId: {applicationInWorkId}");
|
|||
|
|
throw new Exception($"Не найдено расписание в БД, applicationInWorkId: {applicationInWorkId}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return esppSchedule;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|