diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs index 050a849b..395dfa4c 100644 --- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs +++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs @@ -3,7 +3,9 @@ using PARR.API.Authentication.Models; using PARR.API.Contracts.V1.Responses; using PARR.API.MappingProfiles.Resolvers; using PARR.BLL.Helpers; +using PARR.Constants.Shortcode; using PARR.DAL.DomainModels; +using PARR.DAL.Extensions; using PARR.DAL.Models; namespace PARR.API.MappingProfiles @@ -118,9 +120,11 @@ namespace PARR.API.MappingProfiles .ForMember(d => d.ProcessEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.Process!.EsppId)) .ForMember(d => d.SubprocessName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.Name)) .ForMember(d => d.SubprocessEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.EsppId)) - .ForMember(d => d.TnkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Name)) + .ForMember(d => d.TnkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Name.ApplyShortcode(Shortcodes.EK, s.Template!.Host!.Ek))) .ForMember(d => d.TnkEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.EsppId)) - .ForMember(d => d.WorkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Name)) + //.ForMember(d => d.WorkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Name)) + // .ForMember(d => d.WorkName, o => o.MapFrom(s => ShortcodeHelpers.ApplyShortcode(Shortcodes.EK, s.Template.Host.Ek, ref s.Template!.ApplicationsInWork!.Work!.Name.ToString()))) + .ForMember(d => d.WorkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Name.ApplyShortcode(Shortcodes.EK, s.Template!.Host!.Ek))) .ForMember(d => d.WorkEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.EsppId)); CreateMap() diff --git a/PARR.Constants/Shortcode/ShortcodeNames.cs b/PARR.Constants/Shortcode/ShortcodeNames.cs new file mode 100644 index 00000000..cb8f01c8 --- /dev/null +++ b/PARR.Constants/Shortcode/ShortcodeNames.cs @@ -0,0 +1,16 @@ +namespace PARR.Constants.Shortcode +{ + public static class ShortcodeNames + { + private static Dictionary ShortcodeNamesList = new Dictionary + { + {Shortcodes.EK, "%ЭК%" } + }; + + public static string GetShortcodeName(Shortcodes shortcode) + { + return ShortcodeNamesList[shortcode]; + } + + } +} diff --git a/PARR.Constants/Shortcode/Shortcodes.cs b/PARR.Constants/Shortcode/Shortcodes.cs new file mode 100644 index 00000000..160d4dfb --- /dev/null +++ b/PARR.Constants/Shortcode/Shortcodes.cs @@ -0,0 +1,8 @@ +namespace PARR.Constants.Shortcode +{ + public enum Shortcodes + { + EK + //!!!Не забыть добавить в справочник имен (ShortcodeName) строковое значение + } +} diff --git a/PARR.DAL/Extensions/GeneralExtesions.cs b/PARR.DAL/Extensions/GeneralExtesions.cs index 842edc73..6e7de687 100644 --- a/PARR.DAL/Extensions/GeneralExtesions.cs +++ b/PARR.DAL/Extensions/GeneralExtesions.cs @@ -1,4 +1,5 @@ -using System.Text.Encodings.Web; +using PARR.Constants.Shortcode; +using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Unicode; @@ -26,6 +27,8 @@ namespace PARR.DAL.Extensions return null; } } + + public static DateTimeOffset EndOfDay(this DateTimeOffset date) { return new DateTimeOffset(date.Year, date.Month, date.Day, 23, 59, 59, 999, new TimeSpan(0)); @@ -35,5 +38,19 @@ namespace PARR.DAL.Extensions { return new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, 0, new TimeSpan(0)); } + + /// + /// + /// + /// Исходная строка, включающая переменные части вида %ШАБЛОН% + /// Код шаблона из PARR.Constants.Shortcode.Shortcodes + /// Итоговое строковое значение + /// + public static string ApplyShortcode(this string sourceString, Shortcodes shortcode, string shortcodeValue) + { + var shortcodeName = ShortcodeNames.GetShortcodeName(shortcode); + + return sourceString.Replace(shortcodeName, shortcodeValue); + } } } diff --git a/PARR.EsppTemplateSync/TemplateMQSyncer.cs b/PARR.EsppTemplateSync/TemplateMQSyncer.cs index c1aab207..27956df1 100644 --- a/PARR.EsppTemplateSync/TemplateMQSyncer.cs +++ b/PARR.EsppTemplateSync/TemplateMQSyncer.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using PARR.BLL.Services.Interfaces; using PARR.DAL.Contracts; +using PARR.DAL.Extensions; using PARR.DAL.Models; using PARR.EsppSync; using PARR.EsppTemplateSync.Domain; @@ -81,8 +82,8 @@ namespace PARR.EsppTemplateSync Solution = template.ApplicationsInWork.Solution, Process = template.ApplicationsInWork.Work!.Tnk!.Subprocess!.Process!.Name, SubProcess = template.ApplicationsInWork.Work.Tnk.Subprocess.Name, - TNK = template.ApplicationsInWork.Work.Tnk.Name, - Work = template.ApplicationsInWork.Work.Name + TNK = template.ApplicationsInWork.Work.Tnk.Name.ApplyShortcode(Constants.Shortcode.Shortcodes.EK, template.Host.Ek), + Work = template.ApplicationsInWork.Work.Name.ApplyShortcode(Constants.Shortcode.Shortcodes.EK, template.Host.Ek) }; return templateFromDb; @@ -106,7 +107,7 @@ namespace PARR.EsppTemplateSync var templateName = splittedContent[0].Trim(); var currentCulture = Thread.CurrentThread.CurrentCulture; - + //if (!string.IsNullOrEmpty(settingsFromDb.TemplatePrefixName) || !templateName.StartsWith(settingsFromDb.TemplatePrefixName, true, currentCulture)) if (string.IsNullOrEmpty(settingsFromDb.TemplatePrefixWithoutVariable) || !templateName.Contains(settingsFromDb.TemplatePrefixWithoutVariable)) // , StringComparison.CurrentCultureIgnoreCase { diff --git a/PARR.GeneratorTemplates/Services/TemplateManager.cs b/PARR.GeneratorTemplates/Services/TemplateManager.cs index 40a8f8d9..97fa9c35 100644 --- a/PARR.GeneratorTemplates/Services/TemplateManager.cs +++ b/PARR.GeneratorTemplates/Services/TemplateManager.cs @@ -4,6 +4,7 @@ using PARR.BLL.Domain.Mq; using PARR.BLL.Helpers; using PARR.Constants; using PARR.DAL.Contracts; +using PARR.DAL.Extensions; using PARR.DAL.Models; using PARR.DAL.Services.Interfaces; using System.Text.Json; @@ -90,7 +91,7 @@ namespace PARR.GeneratorTemplates.Services Id = Guid.NewGuid(), //TODO:!!! //Name = TemplateHelpers.GenerateTemplateName("ЗО" ,settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name), - Name = TemplateHelpers.GenerateTemplateNameWithResponseArea(host.ResponseArea!.Name, settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name), + Name = TemplateHelpers.GenerateTemplateNameWithResponseArea(host.ResponseArea!.Name, settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name.ApplyShortcode(Constants.Shortcode.Shortcodes.EK, host.Ek)), IsActiveTemplate = true, IsActiveSchedule = true, ApplicationInWorkId = appInWork.Id,