fix(esppSync, dal, api): Исправление после удаления старых ShortCodes
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainServices;
|
||||
using PARR.DAL.Extensions;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.EsppSync;
|
||||
using PARR.EsppTemplateSync.Domain;
|
||||
using PARR.EsppTemplateSync.Settings;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PARR.EsppTemplateSync
|
||||
{
|
||||
@@ -16,13 +18,15 @@ namespace PARR.EsppTemplateSync
|
||||
private readonly IMqService mqService;
|
||||
private readonly ISyncService<EsppObjectTemplate> syncService;
|
||||
private readonly SettingsFromDb settingsFromDb;
|
||||
private readonly IShortcodesService shortcodesService;
|
||||
|
||||
public TemplateMQSyncer(
|
||||
ILogger<TemplateMQSyncer> logger,
|
||||
GlobalSettings globalSettings,
|
||||
IMqService mqService,
|
||||
ISyncService<EsppObjectTemplate> syncService,
|
||||
SettingsFromDb settingsFromDb
|
||||
SettingsFromDb settingsFromDb,
|
||||
IShortcodesService shortcodesService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
@@ -30,7 +34,7 @@ namespace PARR.EsppTemplateSync
|
||||
this.mqService = mqService;
|
||||
this.syncService = syncService;
|
||||
this.settingsFromDb = settingsFromDb;
|
||||
|
||||
this.shortcodesService = shortcodesService;
|
||||
if (globalSettings.MqSettings == null)
|
||||
{
|
||||
logger.LogError("Нет секции настроек хранилища. MqSettings, EsppTemplates");
|
||||
@@ -58,16 +62,16 @@ namespace PARR.EsppTemplateSync
|
||||
|
||||
private async Task SyncTemplateAsync(string str)
|
||||
{
|
||||
await syncService.SyncEsppObjectAsync(str, ParseStrToEsppObject, ConvertDbObjToEsppObj);
|
||||
await syncService.SyncEsppObjectAsync(str, ParseStrToEsppObject, ConvertDbObjToEsppObjAsync);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Преобразование модели БД в модель для сравнения
|
||||
/// </summary>
|
||||
/// <param name="template"></param>
|
||||
/// <param name="template">template должен обязательно содержать в себе информацию о Job+Group и Unit+BaseFields</param>
|
||||
/// <returns></returns>
|
||||
private EsppObjectTemplate ConvertDbObjToEsppObj(Template template)
|
||||
private async Task<EsppObjectTemplate> ConvertDbObjToEsppObjAsync(Template template)
|
||||
{
|
||||
var templateFromDb = new EsppObjectTemplate
|
||||
{
|
||||
@@ -75,18 +79,20 @@ namespace PARR.EsppTemplateSync
|
||||
IsActive = template.IsActiveTemplate,
|
||||
//WorkGroup = template.Host!.WorkGroup!,
|
||||
WorkGroup = template.Unit!.BaseFields!.WorkGroup!,
|
||||
ShortDescription = Normalize(template.Job.Group.ShortDescription.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK,template.Unit.Name)),
|
||||
//ShortDescription = Normalize(template.Job.Group.ShortDescription.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK,template.Unit.Name)),
|
||||
ShortDescription = Normalize(await shortcodesService.ApplyShortcodesAsync(template.Job!.Group!.ShortDescription,template.UnitId,template.JobId)),//TODO Вынести в переменную
|
||||
//ResponseArea = template.Host!.ResponseArea!.Name,
|
||||
//ЗО берем РГ а не хоста
|
||||
ResponseArea = template.Unit.BaseFields.ResponseArea,
|
||||
ResponseArea = template.Unit.BaseFields.ResponseArea!,
|
||||
Duration = template.Job.Group.TemplateDuration,
|
||||
EK = template.Unit.Name,
|
||||
FullDescription = Normalize(template.Job.Group.FullDescription),
|
||||
Solution = Normalize(template.Job.Group.Solution),
|
||||
Process = template.Job.Tnk!.Subprocess!.Process!.Name,
|
||||
SubProcess = template.Job.Tnk.Subprocess.Name,
|
||||
TNK = template.Job.Tnk.Name.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK, template.Unit.Name),
|
||||
Work = template.Job.WorkName.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK, template.Unit.Name),
|
||||
//TNK = template.Job.Tnk.Name.ApplyShortcode(Constants.Shortcodes.ShortcodeEnum.EK, template.Unit.Name),
|
||||
TNK = Normalize(await shortcodesService.ApplyShortcodesAsync(template.Job.Tnk.Name, template.UnitId, template.JobId)),
|
||||
Work = Normalize(await shortcodesService.ApplyShortcodesAsync(template.Job.WorkName, template.UnitId, template.JobId)),
|
||||
Initiator = settingsFromDb.Initiator
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user