Создана таблица StatusTemplates

This commit is contained in:
Mikhail Trubnikov
2023-09-14 17:00:56 +10:00
parent 09996a5c18
commit e634ba0143
9 changed files with 1312 additions and 21 deletions

View File

@@ -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}");
}
}
}

View File

@@ -59,7 +59,7 @@ namespace PARR.EsppTemplateSync.Services
Id = Guid.NewGuid(),
DateCreated = DateTime.UtcNow,
Name = name,
isActive = bool.Parse(isActive),
IsActive = bool.Parse(isActive),
WorkGroup = workGroup,
ShortDescription = shortDescription,
Category = category,
@@ -75,7 +75,8 @@ namespace PARR.EsppTemplateSync.Services
TNK = tnk,
Work = work,
Worker = worker,
Status = "Checking"
//Status = "Checking"
StatusCode = 0
};
//bool isSuccess = true;