From f52e69b24fc11bad3e7c727394df4d3c7192a26f Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Tue, 13 Feb 2024 13:44:08 +1000 Subject: [PATCH] =?UTF-8?q?feat(generatorTemplates):=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=20=D0=BF=D1=80=D0=B5=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D1=81=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PARR.BLL/Helpers/TemplateHelpers.cs | 28 +++++++++++++++---- PARR.DAL/Context/DataContext.cs | 2 +- .../Services/TemplateManager.cs | 5 +++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/PARR.BLL/Helpers/TemplateHelpers.cs b/PARR.BLL/Helpers/TemplateHelpers.cs index 93e6bf3a..05318b01 100644 --- a/PARR.BLL/Helpers/TemplateHelpers.cs +++ b/PARR.BLL/Helpers/TemplateHelpers.cs @@ -1,21 +1,39 @@ -namespace PARR.BLL.Helpers +using System.Text.RegularExpressions; + +namespace PARR.BLL.Helpers { public static class TemplateHelpers { /// /// Генерация имени шаблона /// - /// + /// %PREFIX% для замены в шаблоне настроек + /// берется из настроек /// /// /// - public static string GenerateTemplateName(string prefix, string ek, string work) + public static string GenerateTemplateName(string prefix, string settingsPrefix, string ek, string work) { if (string.IsNullOrEmpty(prefix)) - prefix = "ПАРР-PREFIX"; + prefix = "ОБЩЕЕ"; + + if (string.IsNullOrEmpty(settingsPrefix)) + settingsPrefix = "%PREFIX%-ЭИТИ-ПАРР"; + + var joinedPrefix = settingsPrefix.Replace("%PREFIX%", prefix); var splitter = "__"; - return prefix + splitter + ek + splitter + work.Replace(" ", "-").ToUpper(); + return joinedPrefix + splitter + ek + splitter + work.Replace(" ", "-").ToUpper(); } + + + public static string GenerateTemplateNameWithResponseArea(string responseAreaCode, string settingsPrefix, string ek, string work) + { + var shortName = new Regex("[А-я]+$").Match(responseAreaCode).Value; + + return GenerateTemplateName(shortName, settingsPrefix, ek, work); + } + + } } diff --git a/PARR.DAL/Context/DataContext.cs b/PARR.DAL/Context/DataContext.cs index f518c07e..e2e38068 100644 --- a/PARR.DAL/Context/DataContext.cs +++ b/PARR.DAL/Context/DataContext.cs @@ -89,7 +89,7 @@ namespace PARR.DAL.Context new { Name = nameof(SettingsFromDb.Initiator), Description = "Инициатор регламентной работы, указывается при создании шаблона в ЕСПП.", Value = "КУЗНЕЦОВ МИХАИЛ ВАЛЕРЬЕВИЧ (IVC_KUZNETSOVMV@DVGD.OAO.RZD)" }, new { Name = nameof(SettingsFromDb.ClosingCode), Description = "Код закрытия регламентной работы, указывается при создании шаблона в ЕСПП.", Value = "выполнен" }, new { Name = nameof(SettingsFromDb.Category), Description = "Категория создаваемого объекта в ЕСПП", Value = "регламентная работа" }, - new { Name = nameof(SettingsFromDb.TemplatePrefixName), Description = "Префикс имени шаблона в ЕСПП", Value = "ПАРР-ДВС-ПТК" }, + new { Name = nameof(SettingsFromDb.TemplatePrefixName), Description = "Префикс имени шаблона в ЕСПП", Value = "%PREFIX%-ЭИТИ-ПАРР" }, new { Name = nameof(SettingsFromDb.RobotAttemptsNumber), Description = "Количество попыток выполнения задания роботом", Value = "3" }, new { Name = nameof(SettingsFromDb.RobotWaitTime), Description = "Время ожидания выполнения роботом задания", Value = "00:15:00" }, new { Name = nameof(SettingsFromDb.ScheduleTimezone), Description = "Расписание регламентной работы - В каком часовом поясе", Value = "MSK" }, diff --git a/PARR.GeneratorTemplates/Services/TemplateManager.cs b/PARR.GeneratorTemplates/Services/TemplateManager.cs index 7f4633ef..40a8f8d9 100644 --- a/PARR.GeneratorTemplates/Services/TemplateManager.cs +++ b/PARR.GeneratorTemplates/Services/TemplateManager.cs @@ -47,6 +47,7 @@ namespace PARR.GeneratorTemplates.Services .ThenInclude(t => t.Application).ThenInclude(t => t!.ApplicationsInWorks).ThenInclude(w => w.Work) .Include(t => t.Templates) .ThenInclude(w => w.ApplicationsInWork) + .Include(t => t.ResponseArea) .Where(t => t.ApplicationsInHosts.Any(h => h.ApplicationId == query.ApplicationId @@ -87,7 +88,9 @@ namespace PARR.GeneratorTemplates.Services var template = new Template { Id = Guid.NewGuid(), - Name = TemplateHelpers.GenerateTemplateName(settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name), + //TODO:!!! + //Name = TemplateHelpers.GenerateTemplateName("ЗО" ,settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name), + Name = TemplateHelpers.GenerateTemplateNameWithResponseArea(host.ResponseArea!.Name, settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name), IsActiveTemplate = true, IsActiveSchedule = true, ApplicationInWorkId = appInWork.Id,