feat(api,core): Задания роботам на обновление расписаний, выдается с периодом охлаждения, если последнее изменение было NextRunWorker или EsppScheduleWorker и значение lastRun+ период охлаждения, меньше чем сейчас.
This commit is contained in:
@@ -61,69 +61,5 @@ namespace PARR.NextRun
|
||||
}, workerSettings.RepeatEvery);
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// Рассчет следующей даты срабатываения
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//private async Task HandlerAsync(ITemplateService templateService, INextRunService nextRunService, IRobotConfigurationService robotConfigurationService)
|
||||
//{
|
||||
// logger.LogInformation("Начинаю обновлять NextRun по расписанию");
|
||||
|
||||
// await UpdateNextRunAsync(templateService, nextRunService, robotConfigurationService);
|
||||
|
||||
// logger.LogInformation($"Завершено обновление полей NextRun.");
|
||||
//}
|
||||
|
||||
|
||||
//private async Task UpdateNextRunAsync(ITemplateService templateService, INextRunService nextRunService, IRobotConfigurationService robotConfigurationService)
|
||||
//{
|
||||
// // выбираем все шаблоны с просроченным nextRun в статусе Used
|
||||
|
||||
// var templatesForUpdate = await templateService.Get()
|
||||
// .Include(t => t.RobotConfigurations)
|
||||
// .Where(t =>
|
||||
// t.StatusTypeId == TemplateStatusTypeEnum.Used
|
||||
// && t.NextRun < DateTimeOffset.UtcNow
|
||||
// ).ToListAsync();
|
||||
|
||||
// logger.LogInformation("Найдено шаблонов в статусе Used с просроченным NextRun {count} шт.", templatesForUpdate.Count);
|
||||
|
||||
// if (!templatesForUpdate.Any())
|
||||
// return;
|
||||
|
||||
|
||||
// foreach (var template in templatesForUpdate)
|
||||
// {
|
||||
// var newNextRun = await nextRunService.GetNextRunForTemplateAsync(template.Id, false);
|
||||
|
||||
// if (newNextRun.HasValue)
|
||||
// {
|
||||
// template.LastRun = template.NextRun;
|
||||
// template.NextRun = newNextRun.Value;
|
||||
|
||||
// //так как nextRun обновился, пробуем поставить задание на обновление
|
||||
// var config = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.ScheduleOrder, template);
|
||||
// robotConfigurationService.SetUpdateTaskStatusIfAllow(config);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// logger.LogError("При расчете nextRun для шаблона {templateId}, '{templateName}', nextRun=null. Это значит что при расчете возникла ошибка.", template.Id, template.Name);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Обновлён NextRun", InitiatorParrComponentId = ParrComponentsEnum.NextRun }))
|
||||
// {
|
||||
// logger.LogInformation("Обновлены значения полей NextRun для шаблонов в статусе Used, {count} шт.", templatesForUpdate.Count);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// logger.LogError("Ошибка при обновлении значений полей NextRun, для шаблонов в статусе Used, {count} шт.", templatesForUpdate.Count);
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user