feat(api,dal,esppSync,esppTemplateSync,esppScheduleSync): Реализован сервис ShortcodesService подменяющий динамические составляющие в полях шаблонов и расписаний. В API контроллер выдачи заданий роботу теперь выдаёт значение полй в новом виде, реализуя Shortcodes.
This commit is contained in:
@@ -9,5 +9,7 @@ namespace PARR.DAL.DomainServices
|
||||
public interface IShortcodesService
|
||||
{
|
||||
Task<string> ApplyShortcodesAsync(string str, Guid unitId, Guid jobId);
|
||||
|
||||
bool isAnyShortcodes(string str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Services.Implementations.Job;
|
||||
using PARR.DAL.Services.Implementations.Unit;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PARR.DAL.DomainServices
|
||||
{
|
||||
internal class ShortcodesService : IShortcodesService
|
||||
{
|
||||
private const string shortcodePattern = "%[^%\\s]+%";
|
||||
private readonly SettingsFromDb settingsFromDb;
|
||||
private readonly IJobService jobService;
|
||||
private readonly IUnitService unitService;
|
||||
@@ -41,7 +35,7 @@ namespace PARR.DAL.DomainServices
|
||||
|
||||
if (job != null && unit != null && job.TemplateNameMask != null)
|
||||
{
|
||||
var resultName = job.TemplateNameMask;
|
||||
var resultName = str;
|
||||
|
||||
var shortcodesInMask = GetShortCodes(resultName);
|
||||
|
||||
@@ -72,6 +66,12 @@ namespace PARR.DAL.DomainServices
|
||||
}
|
||||
|
||||
|
||||
public bool isAnyShortcodes(string str)
|
||||
{
|
||||
return Regex.IsMatch(str, shortcodePattern);
|
||||
}
|
||||
|
||||
|
||||
private async Task<string> ReplaceFieldValues(Guid unitId, string resultName, List<Match> shortcodesInMask)
|
||||
{
|
||||
var unitWithFields = await unitService.Get()
|
||||
@@ -120,7 +120,6 @@ namespace PARR.DAL.DomainServices
|
||||
|
||||
private static List<Match> GetShortCodes(string resultName)
|
||||
{
|
||||
var shortcodePattern = "%[^%\\s]+%";
|
||||
var shortcodesInMask = Regex.Matches(resultName, shortcodePattern).ToList();
|
||||
return shortcodesInMask;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,18 @@ namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
return Get()
|
||||
.Include(h => h.Unit)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Value)
|
||||
.Include(h => h.Unit)
|
||||
.ThenInclude(t => t!.UnitValues)
|
||||
.ThenInclude(t => t.Field)
|
||||
.Include(a => a.Job)
|
||||
.ThenInclude(t => t!.Tnk)
|
||||
.ThenInclude(s => s!.Subprocess)
|
||||
.ThenInclude(p => p!.Process)
|
||||
.Include(t=>t.Job)
|
||||
.ThenInclude(t=>t!.Group);
|
||||
.Include(t => t.Job)
|
||||
.ThenInclude(t => t!.Group);
|
||||
|
||||
|
||||
//return Get()
|
||||
// .Include(h => h.Host)
|
||||
|
||||
Reference in New Issue
Block a user