feat(dal,api,nextRunWorker): подключена логика NextRunServiceV2 в nextRunWorker, в api RobotTaskController
This commit is contained in:
@@ -58,7 +58,7 @@ namespace PARR.EsppSync
|
||||
{
|
||||
// Загружаем Template и TemplateForShortcodes в одном запросе
|
||||
var query = templateService.Get()
|
||||
//.AsNoTracking() <- не надо так, а то потом не сохранится
|
||||
//.AsNoTracking()
|
||||
.Include(h => h.Unit)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Value)
|
||||
@@ -91,22 +91,26 @@ namespace PARR.EsppSync
|
||||
|
||||
var dbObjectInEsppObject = converterToEsppObject.Invoke(template);
|
||||
|
||||
// Проверяем наличие Shortcode в полях объекта из БД
|
||||
var properties = dbObjectInEsppObject.GetType().GetProperties();
|
||||
await ApplyShortcodesAsync(dbObjectInEsppObject, template, shortcodesService);
|
||||
|
||||
foreach (PropertyInfo property in properties)
|
||||
{
|
||||
if (property.PropertyType == typeof(string))
|
||||
{
|
||||
var value = property.GetValue(dbObjectInEsppObject)?.ToString();
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
// Передаём исходный template — он уже загружен с Include
|
||||
var processedValue = await shortcodesService.ApplyShortcodesAsync(value, template);
|
||||
property.SetValue(dbObjectInEsppObject, processedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region old
|
||||
//// Проверяем наличие Shortcode в полях объекта из БД
|
||||
//var properties = dbObjectInEsppObject.GetType().GetProperties();
|
||||
|
||||
//foreach (PropertyInfo property in properties)
|
||||
//{
|
||||
// if (property.PropertyType == typeof(string))
|
||||
// {
|
||||
// var value = property.GetValue(dbObjectInEsppObject)?.ToString();
|
||||
// if (!string.IsNullOrEmpty(value))
|
||||
// {
|
||||
// // Передаём исходный template — он уже загружен с Include
|
||||
// var processedValue = await shortcodesService.ApplyShortcodesAsync(value, template);
|
||||
// property.SetValue(dbObjectInEsppObject, processedValue);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
bool isChanged = false;
|
||||
//TODO: FIX ME Please, BRO
|
||||
@@ -128,6 +132,8 @@ namespace PARR.EsppSync
|
||||
isChanged = IsChanged(esppObject, dbObjectInEsppObject, esppObject.TemplateName);
|
||||
}
|
||||
|
||||
//todo: если это сравнение расписаний, рассчитать nextRun, и сравнить все три nextRun, БД - ЕСПП - Расчитанное
|
||||
|
||||
if (isChanged)
|
||||
{
|
||||
logger.LogDebug("Есть изменения, требуется обновление. {TemplateName}", esppObject.TemplateName);
|
||||
@@ -185,6 +191,32 @@ namespace PARR.EsppSync
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Применяем шорткоды
|
||||
/// </summary>
|
||||
/// <param name="dbObjectInEsppObject"></param>
|
||||
/// <param name="template"></param>
|
||||
/// <param name="shortcodesService"></param>
|
||||
/// <returns></returns>
|
||||
private async Task ApplyShortcodesAsync(EsppObject dbObjectInEsppObject, Template template, IShortcodesService shortcodesService)
|
||||
{
|
||||
// Проверяем наличие Shortcode в полях объекта из БД
|
||||
var properties = dbObjectInEsppObject.GetType().GetProperties();
|
||||
|
||||
foreach (PropertyInfo property in properties)
|
||||
{
|
||||
if (property.PropertyType == typeof(string))
|
||||
{
|
||||
var value = property.GetValue(dbObjectInEsppObject)?.ToString();
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
// Передаём исходный template — он уже загружен с Include
|
||||
var processedValue = await shortcodesService.ApplyShortcodesAsync(value, template);
|
||||
property.SetValue(dbObjectInEsppObject, processedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUpdateStatus(ref Template template, IRobotConfigurationService robotConfigurationService, RobotsEnum robot)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user