fix FormatException в ParserService(isActive), добавлен CallbackException в честный MqService
This commit is contained in:
@@ -37,20 +37,18 @@ namespace PARR.EsppTemplateSync.Services
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<bool> ManageStringAsync(string str)
|
||||
public async Task ManageStringAsync(string str)
|
||||
{
|
||||
bool isSuccess = true;
|
||||
////TODO:
|
||||
|
||||
// тут обязательно нужна проверка, если str не того формата, возникает exception в ParseStringAsync
|
||||
if (str == null || str.Trim().Length == 0)
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return;
|
||||
|
||||
var esppTemplate = parserService.ParseString(str);
|
||||
|
||||
if (esppTemplate == null)
|
||||
{
|
||||
isSuccess = false;
|
||||
logger.LogError($"Не удалось распознать строку({str}) в Template");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -61,77 +59,12 @@ namespace PARR.EsppTemplateSync.Services
|
||||
//}
|
||||
|
||||
await SyncTemplateAsync(esppTemplate);
|
||||
// var template = await GetTemplateAsync(esppTemplate);
|
||||
//var isChanged = false;
|
||||
//if (template == null)
|
||||
//{
|
||||
// // создает запись-шаблон из ЕСПП в ПАРР. Возможно избыточно так как эталон в ПАРР
|
||||
// ////esppTemplate.StatusCode = "Deactivating";
|
||||
// ////---
|
||||
// //esppTemplate.StatusCode = (int)StatusTemplateEnum.Ok;
|
||||
// //esppTemplate.IsActive = false;
|
||||
// //if (!await templateService.CreateAsync(esppTemplate) || !await templateService.CommitAsync())
|
||||
// //{
|
||||
// // logger.LogError($"Не удалось создать запись Template {esppTemplate.Name}({esppTemplate.ShortDescription})");
|
||||
// //}
|
||||
// //else
|
||||
// // logger.LogInformation($"----- Создана запись Template {esppTemplate.Name}({esppTemplate.ShortDescription}) -----");
|
||||
// //---
|
||||
// logger.LogWarning($"----- Найден шаблон ЕСПП незарегистрированный в ПАРР {esppTemplate.Name}({esppTemplate.ApplicationsInWork?.ShortDescription}) -----");
|
||||
// return false;
|
||||
//}
|
||||
//else isChanged = await CheckChangesAsync(esppTemplate, template);
|
||||
////if (isChanged)
|
||||
|
||||
////var isChanged = await UpdateIfNeedAsync(template);
|
||||
|
||||
// //if (isChanged)
|
||||
// //{
|
||||
// // logger.LogInformation($"----- Запись в ЕСПП отличается от Template {esppTemplate.Name}({esppTemplate.ApplicationsInWork?.ShortDescription}) -----");
|
||||
|
||||
// // //template.Status = "Updating";
|
||||
// // template.StatusCode = (int)StatusTemplateEnum.Updating;
|
||||
|
||||
// // if (!await templateService.CommitAsync())
|
||||
// // logger.LogError($"Не удалось обновить запись Template {esppTemplate.Name}({esppTemplate.ApplicationsInWork?.ShortDescription})");
|
||||
// // else
|
||||
// // logger.LogInformation($"----- Требуется обновление шаблона в ЕСПП роботом {esppTemplate.Name}({esppTemplate.ApplicationsInWork?.ShortDescription}) -----");
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // //if (template.Status != "Ok")
|
||||
// // if (template.StatusCode != (int)StatusTemplateEnum.Ok)
|
||||
// // {
|
||||
// // template.DateModified = DateTimeOffset.UtcNow;
|
||||
// // template.StatusCode = (int)StatusTemplateEnum.Ok;
|
||||
|
||||
// // if (!await templateService.CommitAsync())
|
||||
// // logger.LogInformation($"Шаблон в ЕСПП соответствует шаблону в ПАРР {esppTemplate.Name}({esppTemplate.ApplicationsInWork?.ShortDescription}). Установлен статус {StatusTemplateEnum.Ok}");
|
||||
// // }
|
||||
// //}
|
||||
}
|
||||
|
||||
//todo: only true?????
|
||||
return isSuccess;
|
||||
return;
|
||||
}
|
||||
|
||||
//private async Task<Template?> GetTemplateAsync(Template esppTemplate)
|
||||
//{
|
||||
// using (var scope = serviceProvider.CreateScope())
|
||||
// {
|
||||
// var services = scope.ServiceProvider;
|
||||
|
||||
// var templateService = services.GetService<ITemplateService>();
|
||||
|
||||
// if (templateService == null)
|
||||
// {
|
||||
// throw new Exception($"Не найден сервис: {nameof(ITemplateService)}");
|
||||
// // return;
|
||||
// }
|
||||
|
||||
// return await templateService.GetTemplateByNameAsync(esppTemplate.Name);
|
||||
// }
|
||||
//}
|
||||
|
||||
private async Task SyncTemplateAsync(EsppTemplate esppTemplate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user