Актуализация полей шаблонов и изменение разделителя в файле экспорта

This commit is contained in:
Mikhail Kuznetsov
2023-09-13 14:44:21 +10:00
parent e596e7f459
commit 7610484b11
8 changed files with 1243 additions and 24 deletions

View File

@@ -71,7 +71,7 @@ namespace PARR.EsppTemplateSync.Services
return;
}
var template = await templateService.GetTemplateByNameAsync(esppTemplate.EK);
var template = await templateService.GetTemplateByNameAsync(esppTemplate.Name);
//существует в ЕСПП но отсутствует в ПАРР.
//TODO деактивируем и видимо ещё что-то нужно
if (template == null)
@@ -80,10 +80,10 @@ namespace PARR.EsppTemplateSync.Services
esppTemplate.isActive = false;
if (!await templateService.CreateAsync(esppTemplate) || !await templateService.CommitAsync())
{
logger.LogError($"Не удалось создать запись Template {esppTemplate.EK}({esppTemplate.ShortDescription})");
logger.LogError($"Не удалось создать запись Template {esppTemplate.Name}({esppTemplate.ShortDescription})");
}
else
logger.LogInformation($"----- Создана запись Template {esppTemplate.EK}({esppTemplate.ShortDescription}) -----");
logger.LogInformation($"----- Создана запись Template {esppTemplate.Name}({esppTemplate.ShortDescription}) -----");
//TODO написать проверку успешности деактивации и удаление строки из таблицы Templates
}
else

View File

@@ -27,33 +27,54 @@ namespace PARR.EsppTemplateSync.Services
//TODO: а если формат нет тот? Все будет ок?
//TODO:
var splittedContent = str.Split(";");
if (splittedContent.Length != 8) return null;
var splittedContent = str.Split("<|>");
if (splittedContent.Length != 17)
{
return null;
}
var ek = splittedContent[0].Trim().Substring(1, splittedContent[0].Length - 2);
var isActive = splittedContent[1].Trim().Substring(1, splittedContent[1].Length - 2);
var workGroup = splittedContent[2].Trim().Substring(1, splittedContent[2].Length - 2);
var shortDescription = splittedContent[3].Trim().Substring(1, splittedContent[3].Length - 2);
var category = splittedContent[4].Trim().Substring(1, splittedContent[4].Length - 2);
var ekDateCreatedStr = splittedContent[5].Trim().Substring(1, splittedContent[5].Length - 2);
var process = splittedContent[6].Trim().Substring(1, splittedContent[6].Length - 2);
var subProcess = splittedContent[7].Trim().Substring(1, splittedContent[7].Length - 2);
//var name = splittedContent[0].Trim().Substring(1, splittedContent[0].Length - 2);
var name = splittedContent[0].Trim();
var isActive = splittedContent[1].Trim();
var workGroup = splittedContent[2].Trim();
var shortDescription = splittedContent[3].Trim();
var category = splittedContent[4].Trim();
var responseArea = splittedContent[5].Trim();
var duration = splittedContent[6].Trim();
var ek = splittedContent[7].Trim();
var initiator = splittedContent[8].Trim();
var fullDescription = splittedContent[9].Trim();
var closingCode = splittedContent[10].Trim();
var solution = splittedContent[11].Trim();
var process = splittedContent[12].Trim();
var subProcess = splittedContent[13].Trim();
var tnk = splittedContent[14].Trim();
var work = splittedContent[15].Trim();
var worker = splittedContent[16].Trim();
//logger.LogInformation($"Получено сообщение: {ek}");
var template = new Template
{
Id = Guid.NewGuid(),
DateCreated = DateTime.UtcNow,
EK = ek,
Name = name,
isActive = bool.Parse(isActive),
WorkGroup = workGroup,
ShortDescription = shortDescription,
Category = category,
//todo: EKDateCreated
EKDateCreated = ConvertDateFromStr(ekDateCreatedStr),
//EKDateCreated = null,
ResponseArea = responseArea,
Duration = duration,
EK = ek,
Initiator = initiator,
FullDescription = fullDescription,
ClosingCode = closingCode,
Solution = solution,
Process = process,
SubProcess = subProcess,
TNK = tnk,
Work = work,
Worker = worker,
Status = "Checking"
};