diff --git a/PARR.DAL/TransformServices/EsppScheduleTransformService.cs b/PARR.DAL/TransformServices/EsppScheduleTransformService.cs index e21a65e3..1788ec49 100644 --- a/PARR.DAL/TransformServices/EsppScheduleTransformService.cs +++ b/PARR.DAL/TransformServices/EsppScheduleTransformService.cs @@ -82,8 +82,15 @@ namespace PARR.DAL.TransformServices public List GetNextSchedule(EsppScheduleDto esppSchedule, DateTimeOffset lastRun) { // расписание на оставшееся на сегодня время. его так мало... + lastRun = lastRun.UtcDateTime; var schedules = new List(); var curTime = lastRun; + + //Если ещё не произошло то добавляем расписание, возможно это новое AiW и он ещё ниразу не запускался. + //lastRun это будущее + if (lastRun >= DateTimeOffset.UtcNow && lastRun <= DateTimeOffset.UtcNow.EndOfDay()) + schedules.Add(lastRun); + while (curTime < DateTimeOffset.UtcNow.EndOfDay()) { switch (esppSchedule.TypeSchedule.Id) @@ -118,20 +125,20 @@ namespace PARR.DAL.TransformServices public async Task GetNextDateAsync(Guid applicationInWorkId, DateTimeOffset lastRun) { - return GetNextDate(await GetEsppSchedule(applicationInWorkId), lastRun); + return GetNextDate(await GetEsppScheduleAsync(applicationInWorkId), lastRun); } public async Task> GetNextScheduleAsync(Guid applicationInWorkId, DateTimeOffset lastRun) { - var esppSchedule = await GetEsppSchedule(applicationInWorkId); + var esppSchedule = await GetEsppScheduleAsync(applicationInWorkId); var nextSchedule = GetNextSchedule(esppSchedule, lastRun); return nextSchedule; } - private async Task GetEsppSchedule(Guid applicationInWorkId) + private async Task GetEsppScheduleAsync(Guid applicationInWorkId) { var esppSchedule = await esppSchTypeConfigService.GetEsppScheduleDtoAsync(applicationInWorkId); if (esppSchedule == null)