diff --git a/PARR.Test/Worker.cs b/PARR.Test/Worker.cs index 919ade88..e8a38173 100644 --- a/PARR.Test/Worker.cs +++ b/PARR.Test/Worker.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using PARR.BLL.Services.Interfaces; using PARR.Constants; using PARR.DAL.DomainServices.Interfaces; -using PARR.DAL.Services.Interfaces.Unit; +using PARR.DAL.Services.Interfaces; using PARR.EsppApi; using PARR.EsppApi.Constants; using PARR.EsppApi.Models.Query; @@ -35,29 +35,57 @@ namespace PARR.Test protected override async Task ExecuteAsync(CancellationToken stoppingToken) { #region test - using (var scope = serviceProvider.CreateScope()) - { - var unitFilterService = scope.ServiceProvider.GetService(); + //using (var scope = serviceProvider.CreateScope()) + //{ + // var templateService = scope.ServiceProvider.GetService(); + // var shortcodesService = scope.ServiceProvider.GetService(); + // var robotConfigurationService = scope.ServiceProvider.GetService(); - if (unitFilterService == null) - return; - var jobId = Guid.Parse("926793f7-c6d3-4f08-b5ce-517ce1a1ac37"); - //var unitsId = await unitFilterService.GetUnitsIdByJobFilterAsync(jobId); + // var ts = await templateService.Get().Include(t => t.Job).Where(t => t.ScheduleEsppId != null && t.Name.Contains("ЭИТИ-ПТК-ПАРР") && !t.Name.Contains("!!!")).ToListAsync(); - var unitService = scope.ServiceProvider.GetService(); + // if (!ts.Any()) + // return; - if (unitService == null) - return; - var tForCreate = await unitFilterService.GetUnitsIdForExistTemplatesByJobFilterAsync(jobId); - if (tForCreate == null) - return; + // var jobIds = ts.Select(t => t.JobId).Distinct(); + // foreach (var template in ts) + // { + // var isExistSameKeyValueTemplate = await templateService.Get().AsNoTracking().AnyAsync(t => t.JobId == template.JobId && t.UnitId == template.UnitId && t.Name != template.Name); - var units = await unitService - .Get().AsNoTracking() - .Where(t => tForCreate.Any(x => x == t.Id)).ToListAsync(); - } + // var templateName = await shortcodesService.ApplyShortcodesAsync(template.Job.TemplateNameMask, template.UnitId, template.JobId); + + // if (isExistSameKeyValueTemplate) + // { + // template.IsActiveTemplate = false; + // template.IsActiveSchedule = false; + // template.Name = string.Concat("!!!", templateName.ToUpper()); + // template.DateModified = DateTimeOffset.UtcNow; + // if (!(await templateService.CommitAsync(template))) + // _logger.LogInformation($"Не удалось сохнаить изменения {template.ToString()}"); + // continue; + // } + + + // var oldName = template.Name; + // var rt = await robotConfigurationService.Get().FirstOrDefaultAsync(t => t.TemplateId == template.Id); + + // if (rt != null) + // { + // template.IsActiveTemplate = true; + // template.IsActiveSchedule = false; + // template.Name = templateName.ToUpper(); + // template.DateModified = DateTimeOffset.UtcNow; + + // robotConfigurationService.ChangeTaskStatus(DAL.Contracts.TaskStatusEnum.Updating, ref rt); + // //_logger.LogInformation(templateName); + // } + + // if (!(await templateService.CommitAsync(template))) + // _logger.LogInformation($"Не удалось сохранить изменения {template.ToString()}"); + // } + // _logger.LogInformation($"Опа опа опа..."); + //} #endregion #region unit