feat(dal): добавлено расширение string ApplyShortcode - позволяет подставлять в строковых переменные шаблонные значения типа %ЭК%
This commit is contained in:
@@ -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<RobotConfiguration, RobotTaskScheduleResponse>()
|
||||
|
||||
16
PARR.Constants/Shortcode/ShortcodeNames.cs
Normal file
16
PARR.Constants/Shortcode/ShortcodeNames.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace PARR.Constants.Shortcode
|
||||
{
|
||||
public static class ShortcodeNames
|
||||
{
|
||||
private static Dictionary<Shortcodes, string> ShortcodeNamesList = new Dictionary<Shortcodes, string>
|
||||
{
|
||||
{Shortcodes.EK, "%ЭК%" }
|
||||
};
|
||||
|
||||
public static string GetShortcodeName(Shortcodes shortcode)
|
||||
{
|
||||
return ShortcodeNamesList[shortcode];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
8
PARR.Constants/Shortcode/Shortcodes.cs
Normal file
8
PARR.Constants/Shortcode/Shortcodes.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace PARR.Constants.Shortcode
|
||||
{
|
||||
public enum Shortcodes
|
||||
{
|
||||
EK
|
||||
//!!!Не забыть добавить в справочник имен (ShortcodeName) строковое значение
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sourceString">Исходная строка, включающая переменные части вида %ШАБЛОН%</param>
|
||||
/// <param name="shortcode">Код шаблона из PARR.Constants.Shortcode.Shortcodes</param>
|
||||
/// <param name="shortcodeValue">Итоговое строковое значение</param>
|
||||
/// <returns></returns>
|
||||
public static string ApplyShortcode(this string sourceString, Shortcodes shortcode, string shortcodeValue)
|
||||
{
|
||||
var shortcodeName = ShortcodeNames.GetShortcodeName(shortcode);
|
||||
|
||||
return sourceString.Replace(shortcodeName, shortcodeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user