Создана таблица StatusTemplates
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
@@ -37,16 +38,21 @@ namespace PARR.EsppTemplateSync.Services
|
||||
|
||||
var template = parserService.ParseString(str);
|
||||
|
||||
if (template == null) {
|
||||
if (template == null)
|
||||
{
|
||||
isSuccess = false;
|
||||
logger.LogError($"Не удалось распознать строку({str}) в Template");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
//если шаблон не аквтивен, пропускаем
|
||||
if (!template.isActive)
|
||||
if (!template.IsActive)
|
||||
{
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
//TODO: !!! тут метод называет чек, но он же исохраняет. По идее надо чтобы чек че то вернул, а исходя из этого дургой метод сохранит или ченить изменит
|
||||
// и опять же, saccess всегда true получается??? или это норм.
|
||||
await CheckChangesAsync(template);
|
||||
}
|
||||
|
||||
@@ -97,19 +103,19 @@ namespace PARR.EsppTemplateSync.Services
|
||||
prop.Name == "Status" ||
|
||||
prop.Name == "DateCreated" ||
|
||||
prop.Name == "DateModified" ||
|
||||
prop.Name == "Status"
|
||||
prop.Name == "StatusCode"
|
||||
) continue;
|
||||
|
||||
var parrValue = template.GetType().GetProperty(prop.Name)?.GetValue(template, null);
|
||||
var esppValue = esppTemplate.GetType().GetProperty(prop.Name)?.GetValue(esppTemplate, null);
|
||||
|
||||
if (parrValue == null || esppValue == null) continue;
|
||||
if (parrValue == null || esppValue == null) continue;
|
||||
|
||||
if (parrValue!.ToString()!.ToLower() !=
|
||||
esppValue!.ToString()!.ToLower()
|
||||
)
|
||||
{
|
||||
isChanged = true;
|
||||
isChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -117,20 +123,24 @@ namespace PARR.EsppTemplateSync.Services
|
||||
if (isChanged)
|
||||
{
|
||||
logger.LogInformation($"----- Запись в ЕСПП отличается от Template {esppTemplate.Name}({esppTemplate.ShortDescription}) -----");
|
||||
template.Status = "Updating";
|
||||
if(!await templateService.CommitAsync())
|
||||
|
||||
//template.Status = "Updating";
|
||||
template.StatusCode = (int)StatusTemplateEnum.Updating;
|
||||
|
||||
if (!await templateService.CommitAsync())
|
||||
logger.LogError($"Не удалось обновить запись Template {esppTemplate.Name}({esppTemplate.ShortDescription})");
|
||||
else
|
||||
logger.LogInformation($"----- Требуется обновление шаблона в ЕСПП роботом {esppTemplate.Name}({esppTemplate.ShortDescription}) -----");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (template.Status != "Ok")
|
||||
//if (template.Status != "Ok")
|
||||
if (template.StatusCode != (int)StatusTemplateEnum.Ok)
|
||||
{
|
||||
template.DateModified = DateTimeOffset.UtcNow;
|
||||
template.Status = "Ok";
|
||||
template.StatusCode = (int)StatusTemplateEnum.Ok;
|
||||
if (!await templateService.CommitAsync())
|
||||
logger.LogInformation($"Шаблон в ЕСПП соответствует шаблону в ПАРР {esppTemplate.Name}({esppTemplate.ShortDescription}). Установлен статус Ok");
|
||||
logger.LogInformation($"Шаблон в ЕСПП соответствует шаблону в ПАРР {esppTemplate.Name}({esppTemplate.ShortDescription}). Установлен статус {StatusTemplateEnum.Ok}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user