feat: Сервисы и модели RabbitMq разнесены согласно архитектуры
This commit is contained in:
@@ -4,6 +4,7 @@ using PARR.AIHITMainLoader.Models;
|
||||
using PARR.AIHITMainLoader.Services;
|
||||
using PARR.AIHITMainLoader.Settings;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace PARR.AIHITMainLoader
|
||||
private readonly WorkerSettings workerSettings;
|
||||
private readonly LoaderSettings loaderSettings;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
private static readonly JsonSerializerOptions jsonOptions = new JsonSerializerOptions
|
||||
@@ -30,7 +31,7 @@ namespace PARR.AIHITMainLoader
|
||||
WorkerSettings workerSettings,
|
||||
LoaderSettings loaderSettings,
|
||||
MqSettings mqSettings,
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
IServiceProvider serviceProvider
|
||||
)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.AIHITMainLoader.Models;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
|
||||
namespace PARR.AIHITMainLoader.Context
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
|
||||
namespace PARR.AIHITMainLoader.Models
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
|
||||
<ProjectReference Include="..\PARR.Core\PARR.Core.csproj" />
|
||||
<ProjectReference Include="..\PARR.Domain\PARR.Domain.csproj" />
|
||||
<ProjectReference Include="..\PARR.Infrastructure\PARR.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
using PARR.Domain.Settings;
|
||||
|
||||
namespace PARR.AIHITMainLoader.Settings
|
||||
{
|
||||
internal class MqSettings : IMqSettings
|
||||
{
|
||||
public string HostName { get; set; } = string.Empty;
|
||||
public string HostName { get; init; } = string.Empty;
|
||||
|
||||
public string QueueName { get; set; } = string.Empty;
|
||||
public string QueueName { get; init; } = string.Empty;
|
||||
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string User { get; init; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Password { get; init; } = string.Empty;
|
||||
|
||||
public ushort? PrefetchCount { get; set; } = 0;
|
||||
public ushort? PrefetchCount { get; init; } = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.AIHITMainSyncer.Services;
|
||||
using PARR.AIHITMainSyncer.Settings;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
|
||||
namespace PARR.AIHITMainSyncer
|
||||
{
|
||||
internal class AihitMainSyncer : IAihitMainSyncer
|
||||
{
|
||||
private readonly ILogger<AihitMainSyncer> logger;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
public AihitMainSyncer(
|
||||
ILogger<AihitMainSyncer> logger,
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings,
|
||||
IServiceProvider serviceProvider
|
||||
)
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PARR.AIHITMainSyncer.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.DAL.Models.Unit;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
|
||||
namespace PARR.AIHITMainSyncer.Services
|
||||
{
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
using PARR.Domain.Settings;
|
||||
|
||||
namespace PARR.AIHITMainSyncer.Settings
|
||||
{
|
||||
internal class MqSettings : IMqSettings
|
||||
{
|
||||
public string HostName { get; set; } = string.Empty;
|
||||
public string HostName { get; init; } = string.Empty;
|
||||
|
||||
public string QueueName { get; set; } = string.Empty;
|
||||
public string QueueName { get; init; } = string.Empty;
|
||||
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string User { get; init; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Password { get; init; } = string.Empty;
|
||||
|
||||
public ushort? PrefetchCount { get; set; } = 0;
|
||||
public ushort? PrefetchCount { get; init; } = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.EsppApi", "PARR.EsppAp
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.Test", "PARR.Test\PARR.Test.csproj", "{CFE2A198-67BF-4828-8E8D-31A01858FDA7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.Constants", "PARR.Constants\PARR.Constants.csproj", "{46B09885-C9FB-449C-ACAA-24C671194C4D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.EsppSync", "PARR.EsppSync\PARR.EsppSync.csproj", "{71121EF7-D4C1-43A4-9243-EF5C4C82030F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.EsppScheduleSync", "PARR.EsppScheduleSync\PARR.EsppScheduleSync.csproj", "{1E7F0EFE-784E-42E1-96BA-1FF743998619}"
|
||||
@@ -170,10 +168,6 @@ Global
|
||||
{CFE2A198-67BF-4828-8E8D-31A01858FDA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CFE2A198-67BF-4828-8E8D-31A01858FDA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CFE2A198-67BF-4828-8E8D-31A01858FDA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{46B09885-C9FB-449C-ACAA-24C671194C4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{46B09885-C9FB-449C-ACAA-24C671194C4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{46B09885-C9FB-449C-ACAA-24C671194C4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{46B09885-C9FB-449C-ACAA-24C671194C4D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71121EF7-D4C1-43A4-9243-EF5C4C82030F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71121EF7-D4C1-43A4-9243-EF5C4C82030F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71121EF7-D4C1-43A4-9243-EF5C4C82030F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
namespace PARR.API.Contracts.V1.Requests
|
||||
{
|
||||
public class GeneratorTemplateRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Id работы
|
||||
/// </summary>
|
||||
public Guid WorkId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id приложения
|
||||
/// </summary>
|
||||
public Guid ApplicationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Действие: create, deactivate
|
||||
/// </summary>
|
||||
public required string Action { get; set; }
|
||||
//public class GeneratorTemplateRequest
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Id работы
|
||||
// /// </summary>
|
||||
// public Guid WorkId { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
///// ЭК, принимает регулярное выражение. Например: *, ВРТ-*-ДВС
|
||||
// /// Id приложения
|
||||
// /// </summary>
|
||||
//public required string Ek { get; set; }
|
||||
// public Guid ApplicationId { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Действие: create, deactivate
|
||||
// /// </summary>
|
||||
// public required string Action { get; set; }
|
||||
|
||||
// ///// <summary>
|
||||
// ///// ЭК, принимает регулярное выражение. Например: *, ВРТ-*-ДВС
|
||||
// ///// </summary>
|
||||
// //public required string Ek { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ЭК, принимает список маск. Например: *, ВРТ-*-ДВС
|
||||
/// </summary>
|
||||
public required List<string> Ek { get; set; }
|
||||
// /// <summary>
|
||||
// /// ЭК, принимает список маск. Например: *, ВРТ-*-ДВС
|
||||
// /// </summary>
|
||||
// public required List<string> Ek { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Список статусов ЭК. 0 - все статусы, 1,2,3,4,5,6,7,9
|
||||
/// </summary>
|
||||
public required List<int> Status { get; set; }
|
||||
// /// <summary>
|
||||
// /// Список статусов ЭК. 0 - все статусы, 1,2,3,4,5,6,7,9
|
||||
// /// </summary>
|
||||
// public required List<int> Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// При создании, активировать шаблон
|
||||
/// </summary>
|
||||
public bool? IsActiveTemplate { get; set; }
|
||||
// /// <summary>
|
||||
// /// При создании, активировать шаблон
|
||||
// /// </summary>
|
||||
// public bool? IsActiveTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// При создании, активировать расписание
|
||||
/// </summary>
|
||||
public bool? IsActiveSchedule { get; set; }
|
||||
}
|
||||
// /// <summary>
|
||||
// /// При создании, активировать расписание
|
||||
// /// </summary>
|
||||
// public bool? IsActiveSchedule { get; set; }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Requests
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Requests
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Requests
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
|
||||
@@ -11,11 +11,11 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -8,10 +8,10 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -1,442 +0,0 @@
|
||||
using AutoMapper;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ApplicationInWorkController : BaseApiController
|
||||
{
|
||||
private readonly ILogger<ApplicationInWorkController> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
private readonly IValidator<ApplicationInWorkRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IMqService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
|
||||
public ApplicationInWorkController(
|
||||
ILogger<ApplicationInWorkController> logger,
|
||||
IMapper mapper,
|
||||
IApplicationsInWorkService applicationsInWorkService,
|
||||
IValidator<ApplicationInWorkRequest> validator,
|
||||
IUriService uriService,
|
||||
ITemplateService templateService,
|
||||
IMqService mqService,
|
||||
MqSettings mqSettings
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.applicationsInWorkService = applicationsInWorkService;
|
||||
this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
this.templateService = templateService;
|
||||
this.mqService = mqService;
|
||||
this.mqSettings = mqSettings;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить список заданий на выполнение работ(ApplicationInWork) постранично
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//[HttpGet(ApiRoutes.Job.GetAll)]
|
||||
//public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] ApplicationInWorkQuery filter)
|
||||
//{
|
||||
// var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
// IQueryable<ApplicationsInWork> query = applicationsInWorkService.Get().Include(t => t.Application).ThenInclude(t => t!.ApplicationType);
|
||||
|
||||
// if (filter.IsLight != true)
|
||||
// {
|
||||
// query = query
|
||||
// .Include(t => t.Work)
|
||||
// //.Include(t => t.Templates) - большой запрос, делаем его отдельно
|
||||
// .Include(t => t.WorkGroups).ThenInclude(t => t.WorkGroup)
|
||||
// .Include(t => t.JobAutoControl);
|
||||
// }
|
||||
|
||||
// query = query.OrderBy(t => t.ShortDescription).ThenBy(t => t.Application!.Name);
|
||||
|
||||
// if (!string.IsNullOrEmpty(filter.ShortDescription))
|
||||
// query = query.Where(t => t.ShortDescription.ToLower().Contains(filter.ShortDescription.ToLower()));
|
||||
|
||||
// if (filter.WorkId.HasValue)
|
||||
// query = query.Where(t => t.WorkId == filter.WorkId.Value);
|
||||
|
||||
// var appInWorks = await applicationsInWorkService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
// if (!appInWorks.Any())
|
||||
// return NoContent();
|
||||
|
||||
// var response = mapper.Map<List<ApplicationInWorkResponse>>(appInWorks);//TODO Migration to job
|
||||
|
||||
// if (filter.IsLight != true)
|
||||
// {
|
||||
// //Если запрос не легкий, загружаем кол-во шаблонов отдельно, это значительно ускоряет запрос
|
||||
// foreach (var item in response)
|
||||
// {
|
||||
// item.TemplatesCount = await templateService.Get().CountAsync(t => t.JobId == item.Id);
|
||||
|
||||
// var statistics = await GetStatisticsAsync(item.Id);
|
||||
// BindStatistics(item, statistics);
|
||||
// }
|
||||
// }
|
||||
|
||||
// var paginationResponse = new PagedResponse<ApplicationInWorkResponse>(response, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
// return Ok(paginationResponse);
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить задание на выполнение работ по id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
//[HttpGet(ApiRoutes.Job.Get)]
|
||||
//public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||
//{
|
||||
// var applicationInWork = await applicationsInWorkService.Get()
|
||||
// .Include(t => t.Application).ThenInclude(t => t!.ApplicationType)
|
||||
// .Include(t => t.Work)
|
||||
// //.Include(t => t.Templates)
|
||||
// .Include(t => t.WorkGroups).ThenInclude(t => t.WorkGroup)
|
||||
// .Include(t => t.JobAutoControl)
|
||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
// if (applicationInWork == null)
|
||||
// return NotFound();
|
||||
|
||||
// var response = mapper.Map<ApplicationInWorkResponse>(applicationInWork);
|
||||
// response.TemplatesCount = await templateService.Get().CountAsync(t => t.ApplicationInWorkId == id);
|
||||
|
||||
// var statistics = await GetStatisticsAsync(response.Id);
|
||||
// BindStatistics(response, statistics);
|
||||
|
||||
// return Ok(new Response<ApplicationInWorkResponse>(response, true));
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Создать задание на выполнение работ (ApplicationInWork)
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
//[HttpPost(ApiRoutes.Job.Create)]
|
||||
//public async Task<IActionResult> Create([FromBody] ApplicationInWorkRequest request)
|
||||
//{
|
||||
// var resultValidate = await validator.ValidateAsync(request);
|
||||
|
||||
// if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
// //уникальная запись по полям ApplicationId, WorkId
|
||||
// var existSameAiW = await applicationsInWorkService.GetAsync(request.ApplicationId, request.WorkId);
|
||||
// if (existSameAiW != null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Задание на выполнение работ с такими ПО и работой уже существует" } }));
|
||||
|
||||
// var applicationInWork = new ApplicationsInWork
|
||||
// {
|
||||
// Id = Guid.NewGuid(),
|
||||
// WorkId = request.WorkId,
|
||||
// ApplicationId = request.ApplicationId,
|
||||
// TemplateDuration = request.TemplateDuration,
|
||||
// ShortDescription = request.ShortDescription.Trim(),
|
||||
// FullDescription = request.FullDescription.Trim(),
|
||||
// Solution = request.Solution.Trim(),
|
||||
// //NextRun = request.NextRun,
|
||||
// IsAutoDistributionEnabled = request.IsAutoDistributionEnabled,
|
||||
// ReferenceDate = request.ReferenceDate,
|
||||
// IsAgent = request.IsAgent,
|
||||
// AgentName = request.AgentName?.Trim(),
|
||||
// AgentTimeOutSec = request.AgentTimeOutSec,
|
||||
// AgentScript = request.AgentScript?.Trim()
|
||||
// };
|
||||
|
||||
// //Добавляем настройки планировщика
|
||||
// request.Schedule.ForEach(item =>
|
||||
// {
|
||||
// applicationInWork.EsppSchValues.Add(new EsppSchValue
|
||||
// {
|
||||
// ApplicationsInWorkId = applicationInWork.Id,
|
||||
// TypeConfigId = item.TypeConfigId,
|
||||
// TypeValueId = item.TypeValueId
|
||||
// });
|
||||
// });
|
||||
|
||||
// //Добавляем рабочие группы
|
||||
// request.WorkGroups.ForEach(workGroupId =>
|
||||
// {
|
||||
// applicationInWork.WorkGroups.Add(new AppInWorkInWorkGroup
|
||||
// {
|
||||
// ApplicationsInWorkId = applicationInWork.Id,
|
||||
// WorkGroupId = workGroupId
|
||||
// });
|
||||
// });
|
||||
|
||||
// if (!await applicationsInWorkService.CreateAsync(applicationInWork) || !await applicationsInWorkService.CommitAsync())
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при созании задания на выполнение работ" } }));
|
||||
|
||||
// logger.LogInformation($"Пользователь {User.Identity?.Name} добавил задание на выполнение работ: {applicationInWork.Id}, {applicationInWork.ShortDescription}, {applicationInWork.Solution}");
|
||||
|
||||
|
||||
// var createdApplicationInWork = await applicationsInWorkService.Get()
|
||||
// .Include(t => t.Application).ThenInclude(t => t!.ApplicationType)
|
||||
// .Include(t => t.Work)
|
||||
// //.Include(t => t.Templates)
|
||||
// .Include(t => t.WorkGroups).ThenInclude(t => t.WorkGroup)
|
||||
// .Include(t => t.JobAutoControl)
|
||||
// .FirstAsync(t => t.Id == applicationInWork.Id);
|
||||
|
||||
// var locationUri = uriService.GetUri(ApiRoutes.Job.Get, ApiRoutes.Job.getParam, createdApplicationInWork.Id);
|
||||
|
||||
// var response = mapper.Map<ApplicationInWorkResponse>(createdApplicationInWork);
|
||||
// // так как мы только что создали AppInW, то у него нет шаблонов, смело ставим = 0 (ускоряем запрос)
|
||||
// response.TemplatesCount = 0;
|
||||
|
||||
// return Created(locationUri, new Response<ApplicationInWorkResponse>(response, true));
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Обновить задание на выполнение работ (ApplicationInWork)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
//[HttpPut(ApiRoutes.Job.Update)]
|
||||
//public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] ApplicationInWorkRequest request)
|
||||
//{
|
||||
// var resultValidate = await validator.ValidateAsync(request);
|
||||
// if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
// //уникальная запись по полям ApplicationId, WorkId у которой id!=[FromRoute]id
|
||||
// var existSameAiW = await applicationsInWorkService.Get()
|
||||
// .FirstOrDefaultAsync(t => t.Id != id && t.ApplicationId == request.ApplicationId && t.WorkId == request.WorkId);
|
||||
// if (existSameAiW != null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Задание на выполнение работ с такими ПО и работой уже существует" } }));
|
||||
|
||||
// var orig = await applicationsInWorkService.Get()
|
||||
// .Include(t => t.WorkGroups)
|
||||
// .Include(t => t.EsppSchValues)
|
||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
// if (orig == null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при изменении задания на выполнение работ. Не найдено задание с Id: {id}" } }));
|
||||
|
||||
// //Расписание было изменено, ниже добавим задание в очередь на обновление расписаний у связанных шаблонов
|
||||
// var isScheduleChanged = IsScheduleChanged(orig, request);
|
||||
|
||||
// orig.WorkId = request.WorkId;
|
||||
// orig.ApplicationId = request.ApplicationId;
|
||||
// orig.TemplateDuration = request.TemplateDuration;
|
||||
// orig.ShortDescription = request.ShortDescription.Trim();
|
||||
// orig.FullDescription = request.FullDescription.Trim();
|
||||
// orig.Solution = request.Solution.Trim();
|
||||
// //orig.NextRun = request.NextRun;
|
||||
// orig.ReferenceDate = request.ReferenceDate;
|
||||
// orig.IsAutoDistributionEnabled = request.IsAutoDistributionEnabled;
|
||||
// orig.IsAgent = request.IsAgent;
|
||||
// orig.AgentName = request.AgentName?.Trim();
|
||||
// orig.AgentTimeOutSec = request.AgentTimeOutSec;
|
||||
// orig.AgentScript = request.AgentScript?.Trim();
|
||||
// orig.DateModified = DateTimeOffset.UtcNow;
|
||||
|
||||
// //обновляем планировщик
|
||||
// orig.EsppSchValues.Clear();
|
||||
// request.Schedule.ForEach(item =>
|
||||
// {
|
||||
// orig.EsppSchValues.Add(new EsppSchValue
|
||||
// {
|
||||
// ApplicationsInWorkId = orig.Id,
|
||||
// TypeConfigId = item.TypeConfigId,
|
||||
// TypeValueId = item.TypeValueId
|
||||
// });
|
||||
// });
|
||||
|
||||
// //Обновляем рабочие группы
|
||||
// orig.WorkGroups.Clear();
|
||||
// request.WorkGroups.ForEach(workGroupId =>
|
||||
// {
|
||||
// orig.WorkGroups.Add(new AppInWorkInWorkGroup
|
||||
// {
|
||||
// ApplicationsInWorkId = orig.Id,
|
||||
// WorkGroupId = workGroupId
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
// if (!await applicationsInWorkService.CommitAsync())
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении задания на выполнение работ." } }));
|
||||
|
||||
// logger.LogInformation($"Пользователь {User.Identity?.Name} обновил задание на выполнение работ: {orig.Id}," +
|
||||
// $" {orig.WorkId}, {orig.ApplicationId}, {orig.TemplateDuration}, {orig.ShortDescription}," +
|
||||
// $" {orig.FullDescription}, {orig.Solution}, {nameof(orig.IsAutoDistributionEnabled)}: {orig.IsAutoDistributionEnabled}, {orig.IsAgent}, {orig.AgentName}, {orig.AgentTimeOutSec}, {orig.AgentScript}");
|
||||
|
||||
|
||||
// if (isScheduleChanged)
|
||||
// {
|
||||
// //расписание было обновлено, отправим задание в очередь на перерасчет NextRun
|
||||
// var requestToMq = new TemplateDistributorMq
|
||||
// {
|
||||
// ApplicationInWorkId = id
|
||||
// };
|
||||
|
||||
// var msg = JsonSerializer.Serialize(requestToMq);
|
||||
|
||||
// logger.LogDebug($"Расписание в РР applicationInWorkId: {id} было изменено. Отправляем задание в очередь на перерасчет NextRun");
|
||||
|
||||
// var sendResult = mqService.Send(mqSettings.TemplateDistributor, new[] { msg });
|
||||
|
||||
// if (sendResult.IsSuccess)
|
||||
// logger.LogInformation($"Задание на перерасчет NextRun успешно отправлено в очередь MQ {mqSettings.TemplateDistributor.QueueName}");
|
||||
// else
|
||||
// logger.LogError($"Ошибка при отправке задания на перерасчет NextRun в очередь MQ {mqSettings.TemplateDistributor.QueueName}");
|
||||
// }
|
||||
|
||||
// var updatedApplicationInWork = await applicationsInWorkService.Get()
|
||||
// .Include(t => t.Application).ThenInclude(t => t!.ApplicationType)
|
||||
// .Include(t => t.Work)
|
||||
// //.Include(t => t.Templates)
|
||||
// .Include(t => t.WorkGroups).ThenInclude(t => t.WorkGroup)
|
||||
// .Include(t => t.JobAutoControl)
|
||||
// .FirstAsync(t => t.Id == orig.Id);
|
||||
|
||||
// var response = mapper.Map<ApplicationInWorkResponse>(updatedApplicationInWork);
|
||||
// response.TemplatesCount = await templateService.Get().CountAsync(t => t.ApplicationInWorkId == id);
|
||||
|
||||
// var statistics = await GetStatisticsAsync(response.Id);
|
||||
// BindStatistics(response, statistics);
|
||||
|
||||
// return Ok(new Response<ApplicationInWorkResponse>(response, true));
|
||||
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Удалить задание на выполнение работ (только если нет связанных шаблонов)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
//[HttpDelete(ApiRoutes.Job.Delete)]
|
||||
//public async Task<IActionResult> Delete([FromRoute] Guid id)
|
||||
//{
|
||||
// var applicationsInWork = await applicationsInWorkService.Get()
|
||||
// //.Include(t => t.Templates)
|
||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
// if (applicationsInWork == null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||
// Message = $"Ошибка при удалении задания на выполнение работ. Не найдено задание на выполнение работ Id: {id}"
|
||||
// } }));
|
||||
|
||||
// var templateCount = await templateService.Get().CountAsync(t => t.ApplicationInWorkId == id);
|
||||
|
||||
// //if (applicationsInWork.Templates.Any())
|
||||
// if (templateCount > 0)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||
// Message = $"Ошибка при удалении задания на выполнение работ. С данным заданием связаны шаблоны: {templateCount} шт."
|
||||
// } }));
|
||||
|
||||
// if (!applicationsInWorkService.Delete(applicationsInWork) || !await applicationsInWorkService.CommitAsync())
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel {
|
||||
// Message = $"Ошибка при удалении задания на выполнение работ"
|
||||
// } }));
|
||||
|
||||
// logger.LogInformation($"Пользователь {User.Identity?.Name} удалил задание на выполнение работ: {applicationsInWork.Id},{applicationsInWork.WorkId}," +
|
||||
// $" {applicationsInWork.ApplicationId}, {applicationsInWork.TemplateDuration}, {applicationsInWork.ShortDescription}," +
|
||||
// $" {applicationsInWork.FullDescription}, {applicationsInWork.Solution}, {nameof(applicationsInWork.IsAutoDistributionEnabled)}: {applicationsInWork.IsAutoDistributionEnabled}, {applicationsInWork.IsAgent}," +
|
||||
// $" {applicationsInWork.AgentName}, {applicationsInWork.AgentTimeOutSec}, {applicationsInWork.AgentScript}");
|
||||
|
||||
// return NoContent();
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Проверка, были ли изменения в расписании
|
||||
/// </summary>
|
||||
/// <param name="orig"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
//private bool IsScheduleChanged(ApplicationsInWork orig, ApplicationInWorkRequest request)
|
||||
//{
|
||||
// var isScheduleChanged = false;
|
||||
|
||||
// if (orig.ReferenceDate != request.ReferenceDate)
|
||||
// isScheduleChanged = true;
|
||||
|
||||
// if (request.Schedule.Count() != orig.EsppSchValues.Count())
|
||||
// isScheduleChanged = true;
|
||||
|
||||
// if (request.IsAutoDistributionEnabled != orig.IsAutoDistributionEnabled)
|
||||
// isScheduleChanged = true;
|
||||
|
||||
// request.Schedule.ForEach(requestSchedule =>
|
||||
// {
|
||||
// var schExist = orig.EsppSchValues.FirstOrDefault(t => t.ApplicationsInWorkId == orig.Id
|
||||
// && t.TypeValueId == requestSchedule.TypeValueId
|
||||
// && t.TypeConfigId == requestSchedule.TypeConfigId);
|
||||
|
||||
// if (schExist == null)
|
||||
// isScheduleChanged = true;
|
||||
// });
|
||||
|
||||
// return isScheduleChanged;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка статистики
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorkId"></param>
|
||||
/// <returns></returns>
|
||||
//private async Task<AppInWorkStatModel> GetStatisticsAsync(Guid applicationInWorkId)
|
||||
//{
|
||||
// var statResult = await applicationsInWorkService.Get()
|
||||
// .Include(t => t.Templates).ThenInclude(t => t.RobotConfigurations)
|
||||
// .Where(x => x.Id == applicationInWorkId)
|
||||
// .Select(t => new
|
||||
// {
|
||||
// TemplateActivated = t.Templates.Count(x => x.IsActiveTemplate),
|
||||
// TemplateSynchronized = t.Templates.Count(x => x.RobotConfigurations.Any(c => c.TaskStatusCode == (int)TaskStatusEnum.Ok && c.RobotCode == (int)RobotsEnum.TemplateOrder)),
|
||||
// TemplateErrors = t.Templates.Count(x => x.RobotConfigurations.Any(c => c.RobotStatusCode == (int)RobotStatusEnum.Error && c.RobotCode == (int)RobotsEnum.TemplateOrder)),
|
||||
// ScheduleActivated = t.Templates.Count(x => x.IsActiveSchedule),
|
||||
// ScheduleSynchronized = t.Templates.Count(x => x.RobotConfigurations.Any(c => c.TaskStatusCode == (int)TaskStatusEnum.Ok && c.RobotCode == (int)RobotsEnum.ScheduleOrder)),
|
||||
// ScheduleErrors = t.Templates.Count(x => x.RobotConfigurations.Any(c => c.RobotStatusCode == (int)RobotStatusEnum.Error && c.RobotCode == (int)RobotsEnum.ScheduleOrder))
|
||||
|
||||
// }).FirstOrDefaultAsync();
|
||||
|
||||
// return new AppInWorkStatModel
|
||||
// {
|
||||
// ScheduleStatistics = new ScheduleStats { Activated = statResult?.ScheduleActivated ?? 0, Errors = statResult?.ScheduleErrors ?? 0, Synchronized = statResult?.ScheduleSynchronized ?? 0 },
|
||||
// TemplateStatistics = new TemplateStats { Activated = statResult?.TemplateActivated ?? 0, Errors = statResult?.TemplateErrors ?? 0, Synchronized = statResult?.TemplateSynchronized ?? 0 }
|
||||
// };
|
||||
//}
|
||||
|
||||
|
||||
private void BindStatistics(ApplicationInWorkResponse applicationsInWork, AppInWorkStatModel statistics)
|
||||
{
|
||||
applicationsInWork.TemplateStatistics = new TemplateStats { Activated = statistics.TemplateStatistics.Activated, Errors = statistics.TemplateStatistics.Errors, Synchronized = statistics.TemplateStatistics.Synchronized };
|
||||
applicationsInWork.ScheduleStatistics = new ScheduleStats { Activated = statistics.ScheduleStatistics.Activated, Errors = statistics.ScheduleStatistics.Errors, Synchronized = statistics.ScheduleStatistics.Synchronized };
|
||||
}
|
||||
}
|
||||
|
||||
public class AppInWorkStatModel
|
||||
{
|
||||
public TemplateStats TemplateStatistics { get; set; }
|
||||
|
||||
public ScheduleStats ScheduleStatistics { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -7,9 +7,9 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace PARR.API.Controllers.V1
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class DistributorController : BaseApiController
|
||||
{
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IValidator<DistributeRequest> validator;
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public DistributorController(
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings,
|
||||
IValidator<DistributeRequest> validator,
|
||||
IClientService clientService
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -7,104 +7,104 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class GeneratorTemplateController : BaseApiController
|
||||
{
|
||||
private readonly IValidator<GeneratorTemplateRequest> validator;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IClientService clientService;
|
||||
//[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
//public class GeneratorTemplateController : BaseApiController
|
||||
//{
|
||||
// private readonly IValidator<GeneratorTemplateRequest> validator;
|
||||
// private readonly IRabbitService mqService;
|
||||
// private readonly IUriService uriService;
|
||||
// private readonly MqSettings mqSettings;
|
||||
// private readonly IClientService clientService;
|
||||
|
||||
public GeneratorTemplateController(
|
||||
IValidator<GeneratorTemplateRequest> validator,
|
||||
IMqService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings,
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
this.validator = validator;
|
||||
this.mqService = mqService;
|
||||
this.uriService = uriService;
|
||||
this.mqSettings = mqSettings;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
// public GeneratorTemplateController(
|
||||
// IValidator<GeneratorTemplateRequest> validator,
|
||||
// IRabbitService mqService,
|
||||
// IUriService uriService,
|
||||
// MqSettings mqSettings,
|
||||
// IClientService clientService
|
||||
// )
|
||||
// {
|
||||
// this.validator = validator;
|
||||
// this.mqService = mqService;
|
||||
// this.uriService = uriService;
|
||||
// this.mqSettings = mqSettings;
|
||||
// this.clientService = clientService;
|
||||
// }
|
||||
|
||||
/// !!!!!!!!!! Это старый контроллер, удалить !!!!!!!!!!
|
||||
// /// !!!!!!!!!! Это старый контроллер, удалить !!!!!!!!!!
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Запрос на генерацию шаблонов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost(ApiRoutes.GeneratorTemplate.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] GeneratorTemplateRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
// /// <summary>
|
||||
// /// Запрос на генерацию шаблонов
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// [HttpPost(ApiRoutes.GeneratorTemplate.Create)]
|
||||
// public async Task<IActionResult> Create([FromBody] GeneratorTemplateRequest request)
|
||||
// {
|
||||
// var resultValidate = await validator.ValidateAsync(request);
|
||||
// if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var result = true;
|
||||
|
||||
request.Ek.ForEach(ek =>
|
||||
{
|
||||
//todo: проверить в ForEach(async status - отрабатывает ли нормально async, возможно надо переделать в обычный foreach
|
||||
request.Status.ForEach(async status =>
|
||||
{
|
||||
var obj = new GeneratorTemplateMq
|
||||
{
|
||||
Action = request.Action,
|
||||
ApplicationId = request.ApplicationId,
|
||||
Ek = ek,
|
||||
WorkId = request.WorkId,
|
||||
StatusEk = status,
|
||||
IsActiveTemplate = request.IsActiveTemplate,
|
||||
IsActiveSchedule = request.IsActiveSchedule,
|
||||
HistoryInitiator = new HistoryInitiator { InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }
|
||||
};
|
||||
|
||||
//var msg = JsonSerializer.Serialize(obj);
|
||||
|
||||
//var _result = await mqService.SendAsync(mqSettings.GenerateTemplates, new[] { msg });
|
||||
var _result = await mqService.SendAsync(mqSettings.GenerateTemplates, new List<object> { obj });
|
||||
|
||||
if (_result.IsSuccess == false)
|
||||
result = false;
|
||||
|
||||
});
|
||||
});
|
||||
// var result = true;
|
||||
|
||||
// request.Ek.ForEach(ek =>
|
||||
// {
|
||||
// //todo: проверить в ForEach(async status - отрабатывает ли нормально async, возможно надо переделать в обычный foreach
|
||||
// request.Status.ForEach(async status =>
|
||||
// {
|
||||
// var obj = new GeneratorTemplateMq
|
||||
// {
|
||||
// Action = request.Action,
|
||||
// ApplicationId = request.ApplicationId,
|
||||
// Ek = request.Ek,
|
||||
// Ek = ek,
|
||||
// WorkId = request.WorkId,
|
||||
// StatusEk = request.Status,
|
||||
// StatusEk = status,
|
||||
// IsActiveTemplate = request.IsActiveTemplate,
|
||||
// IsActiveSchedule = request.IsActiveSchedule
|
||||
// IsActiveSchedule = request.IsActiveSchedule,
|
||||
// HistoryInitiator = new HistoryInitiator { InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }
|
||||
// };
|
||||
|
||||
//var msg = JsonSerializer.Serialize(obj);
|
||||
// //var msg = JsonSerializer.Serialize(obj);
|
||||
|
||||
//var result = mqService.Send(mqSettings.GenerateTemplates, new[] { msg });
|
||||
// //var _result = await mqService.SendAsync(mqSettings.GenerateTemplates, new[] { msg });
|
||||
// var _result = await mqService.SendAsync(mqSettings.GenerateTemplates, new List<object> { obj });
|
||||
|
||||
//if (!result.IsSuccess)
|
||||
if (!result)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при отправке данных." } }));
|
||||
// if (_result.IsSuccess == false)
|
||||
// result = false;
|
||||
|
||||
var createdUri = uriService.GetAllUri(ApiRoutes.Template.GetAll);
|
||||
// });
|
||||
// });
|
||||
|
||||
return Created(createdUri, new Response<string?>(null, true, new List<ErrorModel>(), "Отправлен запрос на генерацию шаблонов."));
|
||||
}
|
||||
}
|
||||
// //var obj = new GeneratorTemplateMq
|
||||
// //{
|
||||
// // Action = request.Action,
|
||||
// // ApplicationId = request.ApplicationId,
|
||||
// // Ek = request.Ek,
|
||||
// // WorkId = request.WorkId,
|
||||
// // StatusEk = request.Status,
|
||||
// // IsActiveTemplate = request.IsActiveTemplate,
|
||||
// // IsActiveSchedule = request.IsActiveSchedule
|
||||
// //};
|
||||
|
||||
// //var msg = JsonSerializer.Serialize(obj);
|
||||
|
||||
// //var result = mqService.Send(mqSettings.GenerateTemplates, new[] { msg });
|
||||
|
||||
// //if (!result.IsSuccess)
|
||||
// if (!result)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при отправке данных." } }));
|
||||
|
||||
// var createdUri = uriService.GetAllUri(ApiRoutes.Template.GetAll);
|
||||
|
||||
// return Created(createdUri, new Response<string?>(null, true, new List<ErrorModel>(), "Отправлен запрос на генерацию шаблонов."));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -12,10 +12,8 @@ using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.DAL.DomainServices.Interfaces;
|
||||
using PARR.DAL.DomainServices.UnitFilterService;
|
||||
using PARR.DAL.Extensions;
|
||||
@@ -24,6 +22,8 @@ using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IJobService jobService;
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IValidator<JobRequest> jobValidator;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IClientService clientService;
|
||||
private readonly IJobAutoControlService jobAutoControlService;
|
||||
@@ -57,7 +57,7 @@ namespace PARR.API.Controllers.V1
|
||||
IValidator<JobRequest> jobValidator,
|
||||
IUnitFilterService unitFilterService,
|
||||
IUnitService unitService,
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings,
|
||||
IClientService clientService,
|
||||
IJobAutoControlService jobAutoControlService,
|
||||
|
||||
@@ -12,10 +12,8 @@ using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.DAL.DomainServices.Interfaces;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.Job;
|
||||
@@ -23,6 +21,8 @@ using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IJobGroupTypeService jobGroupTypeService;
|
||||
private readonly IMatchingStatusService matchingStatusService;
|
||||
private readonly IScheduleResponseAreaTimeOffsetService scheduleResponseAreaTimeOffsetService;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
|
||||
public JobGroupController(
|
||||
@@ -58,7 +58,7 @@ namespace PARR.API.Controllers.V1
|
||||
IJobGroupTypeService jobGroupTypeService,
|
||||
IMatchingStatusService matchingStatusService,
|
||||
IScheduleResponseAreaTimeOffsetService scheduleResponseAreaTimeOffsetService,
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings
|
||||
)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -5,10 +5,10 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace PARR.API.Controllers.V1
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class JobGroupUpdateNextRunController : BaseApiController
|
||||
{
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IJobGroupService jobGroupService;
|
||||
|
||||
public JobGroupUpdateNextRunController(
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings,
|
||||
IJobGroupService jobGroupService
|
||||
)
|
||||
|
||||
@@ -8,10 +8,10 @@ using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.DomainServices.UnitFilterService;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using Job = PARR.DAL.Models.Job.Job;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -8,10 +8,10 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -9,13 +9,13 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainServices.Shortcodes;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.DomainServices.Shortcodes;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.InfluxDbServices;
|
||||
using PARR.DAL.Settings;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
@@ -16,17 +16,17 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class StatRabbitMqController : BaseApiController
|
||||
{
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly ILogger<StatRabbitMqController> logger;
|
||||
private readonly IMqAdminService mqAdminService;
|
||||
private readonly IRabbitAdminService mqAdminService;
|
||||
private readonly MonitoringSettings monitoringSettings;
|
||||
|
||||
public StatRabbitMqController(
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings,
|
||||
ILogger<StatRabbitMqController> logger,
|
||||
IMqAdminService mqAdminService,
|
||||
IRabbitAdminService mqAdminService,
|
||||
MonitoringSettings monitoringSettings
|
||||
)
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -14,10 +14,11 @@ using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.InfluxDbServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Settings;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -8,9 +8,9 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
|
||||
@@ -7,8 +7,8 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -7,10 +7,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
|
||||
@@ -8,7 +8,6 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.DomainServices.Shortcodes;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.Job;
|
||||
@@ -16,6 +15,8 @@ using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -7,9 +7,9 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -6,10 +6,10 @@ using PARR.API.Contracts.V1.Requests.BaseRequests;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.NextRunServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.DAL.DomainServices.Interfaces;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PARR.API.Controllers.V1
|
||||
public class SyncTaskController : BaseApiController
|
||||
{
|
||||
private readonly ILogger<SyncTaskController> logger;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IClientService clientService;
|
||||
@@ -24,7 +24,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
public SyncTaskController(
|
||||
ILogger<SyncTaskController> logger,
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings,
|
||||
IClientService clientService,
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -7,10 +7,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.Core.Common.RabbitServices;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.Domain.Common.Rabbit.Messages;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace PARR.API.Controllers.V1
|
||||
public class TemplateActivatorController : BaseApiController
|
||||
{
|
||||
private readonly IValidator<TemplateActivatorRequest> validator;
|
||||
private readonly IMqService mqService;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IJobService jobService;
|
||||
@@ -31,7 +31,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
public TemplateActivatorController(
|
||||
IValidator<TemplateActivatorRequest> validator,
|
||||
IMqService mqService,
|
||||
IRabbitService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings,
|
||||
IJobService jobService,
|
||||
|
||||
@@ -11,13 +11,13 @@ using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainServices.Shortcodes;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Schedule;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
|
||||
@@ -11,10 +11,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -9,10 +9,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models.Unit;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -9,10 +9,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models.Unit;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -8,9 +8,9 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -11,10 +11,10 @@ using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
|
||||
@@ -8,11 +8,11 @@ using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
|
||||
@@ -3,12 +3,12 @@ using PARR.API.Authentication.Models;
|
||||
using PARR.API.Domain.InfluxDbModels;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Cache.Services.Base;
|
||||
using PARR.DAL.InfluxDbServices;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
using PARR.DAL.Settings;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Services.Implementations
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
using PARR.Domain.Enums;
|
||||
using PARR.Domain.Enums;
|
||||
using PARR.Domain.Settings;
|
||||
|
||||
namespace PARR.API.Settings
|
||||
{
|
||||
@@ -26,11 +26,11 @@ namespace PARR.API.Settings
|
||||
|
||||
public class StatMqAuth : IMqSettings
|
||||
{
|
||||
public string HostName { get; set; } = string.Empty;
|
||||
public string QueueName { get; set; } = string.Empty;
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public ushort? PrefetchCount { get; set; } = 0;
|
||||
public string HostName { get; init; } = string.Empty;
|
||||
public string QueueName { get; init; } = string.Empty;
|
||||
public string User { get; init; } = string.Empty;
|
||||
public string Password { get; init; } = string.Empty;
|
||||
public ushort? PrefetchCount { get; init; } = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,64 +1,58 @@
|
||||
using FluentValidation;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.BLL.Contracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using System.Linq;
|
||||
|
||||
namespace PARR.API.Validators
|
||||
namespace PARR.API.Validators
|
||||
{
|
||||
public class GeneratorTemplateRequestValidator : AbstractValidator<GeneratorTemplateRequest>
|
||||
{
|
||||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
//public class GeneratorTemplateRequestValidator : AbstractValidator<GeneratorTemplateRequest>
|
||||
//{
|
||||
// private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
|
||||
private bool? isValid = null;
|
||||
// private bool? isValid = null;
|
||||
|
||||
public GeneratorTemplateRequestValidator(IApplicationsInWorkService applicationsInWorkService)
|
||||
{
|
||||
this.applicationsInWorkService = applicationsInWorkService;
|
||||
// public GeneratorTemplateRequestValidator(IApplicationsInWorkService applicationsInWorkService)
|
||||
// {
|
||||
// this.applicationsInWorkService = applicationsInWorkService;
|
||||
|
||||
RuleFor(t => t.WorkId)
|
||||
.MustAsync(async (entity, value, c) => await IsApplicationContainWork(entity, entity.ApplicationId))
|
||||
.WithMessage("У данной работы нет связанных приложений");
|
||||
// RuleFor(t => t.WorkId)
|
||||
// .MustAsync(async (entity, value, c) => await IsApplicationContainWork(entity, entity.ApplicationId))
|
||||
// .WithMessage("У данной работы нет связанных приложений");
|
||||
|
||||
RuleFor(t => t.ApplicationId)
|
||||
.MustAsync(async (entity, value, c) => await IsApplicationContainWork(entity, value))
|
||||
.WithMessage("У данного приложения нет связанных работ");
|
||||
// RuleFor(t => t.ApplicationId)
|
||||
// .MustAsync(async (entity, value, c) => await IsApplicationContainWork(entity, value))
|
||||
// .WithMessage("У данного приложения нет связанных работ");
|
||||
|
||||
//TODO: возможно сделать проверку, по данному выражению есть ли ЭК
|
||||
RuleFor(t => t.Ek).NotEmpty().WithMessage("Недопустимое значение ЭК. Возможные значения: *, ВРТ-*-ДВС");
|
||||
// //TODO: возможно сделать проверку, по данному выражению есть ли ЭК
|
||||
// RuleFor(t => t.Ek).NotEmpty().WithMessage("Недопустимое значение ЭК. Возможные значения: *, ВРТ-*-ДВС");
|
||||
|
||||
RuleFor(t => t.Action)
|
||||
.Must(t => t.ToLower() == GenerateTemplateActionsEnum.create.ToString() || t.ToLower() == GenerateTemplateActionsEnum.deactivate.ToString())
|
||||
.WithMessage($"Допустимые значения: {GenerateTemplateActionsEnum.create}, {GenerateTemplateActionsEnum.deactivate}");
|
||||
// RuleFor(t => t.Action)
|
||||
// .Must(t => t.ToLower() == GenerateTemplateActionsEnum.create.ToString() || t.ToLower() == GenerateTemplateActionsEnum.deactivate.ToString())
|
||||
// .WithMessage($"Допустимые значения: {GenerateTemplateActionsEnum.create}, {GenerateTemplateActionsEnum.deactivate}");
|
||||
|
||||
//0 - все статусы, 1,2,3,4,5,6,7,9
|
||||
var ekStatuses = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 9 };
|
||||
//RuleFor(t => t.Status).Must(t => ekStatuses.Contains(t)).WithMessage("Допустимые значения: 0 - все статусы, 1,2,3,4,5,6,7,9");
|
||||
RuleFor(t => t.Status).Must((statuses) =>
|
||||
{
|
||||
if (statuses.Count < 1)
|
||||
return false;
|
||||
// //0 - все статусы, 1,2,3,4,5,6,7,9
|
||||
// var ekStatuses = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 9 };
|
||||
// //RuleFor(t => t.Status).Must(t => ekStatuses.Contains(t)).WithMessage("Допустимые значения: 0 - все статусы, 1,2,3,4,5,6,7,9");
|
||||
// RuleFor(t => t.Status).Must((statuses) =>
|
||||
// {
|
||||
// if (statuses.Count < 1)
|
||||
// return false;
|
||||
|
||||
var isContains = true;
|
||||
statuses.ForEach(status =>
|
||||
{
|
||||
if (ekStatuses.Contains(status) == false)
|
||||
isContains = false;
|
||||
});
|
||||
// var isContains = true;
|
||||
// statuses.ForEach(status =>
|
||||
// {
|
||||
// if (ekStatuses.Contains(status) == false)
|
||||
// isContains = false;
|
||||
// });
|
||||
|
||||
return isContains;
|
||||
}).WithMessage("Допустимые значения: 0 - все статусы, 1,2,3,4,5,6,7,9");
|
||||
}
|
||||
|
||||
private async Task<bool> IsApplicationContainWork(GeneratorTemplateRequest request, Guid applicationId)
|
||||
{
|
||||
//чтобы не делать 2 раза валидацию
|
||||
if (isValid.HasValue)
|
||||
return isValid.Value;
|
||||
|
||||
isValid = await applicationsInWorkService.GetAsync(applicationId, request.WorkId) != null;
|
||||
|
||||
return isValid.Value;
|
||||
}
|
||||
}
|
||||
// return isContains;
|
||||
// }).WithMessage("Допустимые значения: 0 - все статусы, 1,2,3,4,5,6,7,9");
|
||||
// }
|
||||
|
||||
// private async Task<bool> IsApplicationContainWork(GeneratorTemplateRequest request, Guid applicationId)
|
||||
// {
|
||||
// //чтобы не делать 2 раза валидацию
|
||||
// if (isValid.HasValue)
|
||||
// return isValid.Value;
|
||||
|
||||
// isValid = await applicationsInWorkService.GetAsync(applicationId, request.WorkId) != null;
|
||||
|
||||
// return isValid.Value;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using FluentValidation;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Validators
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using FluentValidation;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Validators
|
||||
{
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace PARR.BLL.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Действия при генерации шаблонов
|
||||
/// </summary>
|
||||
public enum GenerateTemplateActionsEnum
|
||||
{
|
||||
create,
|
||||
deactivate
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
namespace PARR.BLL.Contracts.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Поля настроек MQ, используется для appsettings.json
|
||||
/// </summary>
|
||||
public interface IMqSettings
|
||||
{
|
||||
string HostName { get; set; }
|
||||
string QueueName { get; set; }
|
||||
string User { get; set; }
|
||||
string Password { get; set; }
|
||||
/// <summary>
|
||||
/// Кол-во сообщений которые может принимать consumer за один раз. 0 или null - без ограничений
|
||||
/// </summary>
|
||||
ushort? PrefetchCount { get; set; }
|
||||
}
|
||||
|
||||
public class MqSettingsBase : IMqSettings
|
||||
{
|
||||
public string HostName { get; set; } = string.Empty;
|
||||
public string QueueName { get; set; } = string.Empty;
|
||||
public string User { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public ushort? PrefetchCount { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace PARR.BLL.Domain.Mq
|
||||
{
|
||||
/// <summary>
|
||||
/// Ответ от API RabbitMQ
|
||||
/// </summary>
|
||||
public class MqApiResult
|
||||
{
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
public object? Response { get; set; }
|
||||
|
||||
public Exception? Exception { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@ namespace PARR.BLL
|
||||
services.AddTransient<IFileService, FileService>();
|
||||
|
||||
//services.AddTransient<IMqService, MqService>();
|
||||
services.AddTransient<IMqService, MqServiceV2>();
|
||||
//services.AddTransient<IMqService, MqServiceV2>();
|
||||
|
||||
services.AddHttpClient<IMqAdminService, MqAdminService>();
|
||||
//services.AddHttpClient<IMqAdminService, MqAdminService>();
|
||||
services.AddTransient<ITransformService, TransformService>();
|
||||
services.AddTransient<IIntervalService, IntervalService>();
|
||||
services.AddTransient<ICalendarService, CalendarService>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Common;
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.BLL.Services.Implementations
|
||||
{
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Text;
|
||||
|
||||
namespace PARR.BLL.Services.Implementations
|
||||
{
|
||||
|
||||
// RabbitMqClient 6.5.0
|
||||
|
||||
internal class MqService// : IMqService
|
||||
{
|
||||
private readonly ILogger<MqService> logger;
|
||||
|
||||
private IConnection? connection;
|
||||
//private IModel? channel;
|
||||
|
||||
public MqService(ILogger<MqService> logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public MqSendResult Send(IMqSettings mqSettings, string[] msgList)
|
||||
{
|
||||
return new MqSendResult { IsSuccess = false, NotSendMessages = new string[0] };
|
||||
|
||||
//var factory = new ConnectionFactory
|
||||
//{
|
||||
// HostName = mqSettings.HostName,
|
||||
// UserName = mqSettings.User,
|
||||
// Password = mqSettings.Password
|
||||
//};
|
||||
|
||||
//// индекс текущей отправки в очередь из массива msgList
|
||||
//// нужен для формирования списка неотправленных сообщений
|
||||
//var sendIdx = 0;
|
||||
|
||||
//try
|
||||
//{
|
||||
// using (var connection = factory.CreateConnection())
|
||||
// using (var channel = connection.CreateModel())
|
||||
// {
|
||||
// //https://www.rabbitmq.com/lazy-queues.html
|
||||
// //Рекомендовано при работе порциями использовать ленивые очереди. сообщения не используют память
|
||||
// //Формируем соответствующий аргумент
|
||||
// var args = new Dictionary<string, object> { { "x-queue-mode", "lazy" } };
|
||||
|
||||
// //Объявляем очередь с которой будем работать.
|
||||
// //Если такой очереди ещё нет, то создатся.
|
||||
// //Если нет, нужно параметры типа durable должны совпадать иначе будет ошибка.
|
||||
// //В целом эти параметры можно посмотреть в админке RabbitMQ
|
||||
|
||||
// channel.QueueDeclare(
|
||||
// queue: mqSettings.QueueName,
|
||||
// durable: true,
|
||||
// exclusive: false,
|
||||
// autoDelete: false,
|
||||
// arguments: args
|
||||
// );
|
||||
|
||||
// var props = channel.CreateBasicProperties();
|
||||
// //храним на диске
|
||||
// props.DeliveryMode = 2;
|
||||
// //время жизни, мс
|
||||
// //props.Expiration = "60000";
|
||||
|
||||
// foreach (var msg in msgList)
|
||||
// {
|
||||
// var body = Encoding.UTF8.GetBytes(msg);
|
||||
// channel.BasicPublish(exchange: "", routingKey: mqSettings.QueueName, basicProperties: props, body: body);
|
||||
|
||||
// sendIdx++;
|
||||
// logger.LogDebug($"Отправлено сообщение в очередь: {mqSettings.HostName} {mqSettings.QueueName}, {msg}");
|
||||
// }
|
||||
// }
|
||||
|
||||
// return new MqSendResult { IsSuccess = true };
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// var notSendMsg = new List<string>();
|
||||
|
||||
// // формируем список неотправленных элементов
|
||||
// for (int i = sendIdx; i < msgList.Length; i++)
|
||||
// notSendMsg.Add(msgList[i]);
|
||||
|
||||
// logger.LogError(ex, $"Ошибка при отправке сообщения в очередь {mqSettings.HostName} {mqSettings.QueueName}, {string.Join(',', notSendMsg)}");
|
||||
|
||||
// return new MqSendResult { IsSuccess = false, NotSendMessages = notSendMsg.ToArray() };
|
||||
//}
|
||||
}
|
||||
|
||||
public bool InitConsumer(IMqSettings mqSettings, MqMessageHandlerDelegate messageHandler)
|
||||
{
|
||||
logger.LogInformation($"Устанавливаю соединение с RabbitMQ: {mqSettings.HostName}, {mqSettings.QueueName}");
|
||||
|
||||
return false;
|
||||
|
||||
//var facory = new ConnectionFactory
|
||||
//{
|
||||
// HostName = mqSettings.HostName,
|
||||
// UserName = mqSettings.User,
|
||||
// Password = mqSettings.Password,
|
||||
// AutomaticRecoveryEnabled = true,
|
||||
// DispatchConsumersAsync = true
|
||||
//};
|
||||
|
||||
//try
|
||||
//{
|
||||
// //using var connection = facory.CreateConnection();
|
||||
// //using var channel = connection.CreateModel();
|
||||
|
||||
// connection = facory.CreateConnection();
|
||||
// channel = connection.CreateModel();
|
||||
|
||||
// var args = new Dictionary<string, object> { { "x-queue-mode", "lazy" } };
|
||||
|
||||
// channel.QueueDeclare(
|
||||
// queue: mqSettings.QueueName,
|
||||
// durable: true,
|
||||
// exclusive: false,
|
||||
// autoDelete: false,
|
||||
// arguments: args
|
||||
// );
|
||||
|
||||
// logger.LogInformation($"Соединение с RabbitMQ установлено: {mqSettings.HostName}, {mqSettings.QueueName}");
|
||||
|
||||
// channel.CallbackException += (ch, ea) =>
|
||||
// {
|
||||
// var _channel = (IModel?)ch;
|
||||
// // может тут если канал упал переоткрывать его
|
||||
// logger.LogError(ea.Exception, $"Ошибка при обработке очереди MqService сообщений из очереди. Канал открыт: {_channel?.IsOpen}");
|
||||
// };
|
||||
|
||||
// var consumer = new AsyncEventingBasicConsumer(channel);
|
||||
// consumer.Received += async (ch, ea) =>
|
||||
// {
|
||||
// var content = Encoding.UTF8.GetString(ea.Body.ToArray());
|
||||
// logger.LogDebug($"Получено сообщение: {content}");
|
||||
|
||||
// await messageHandler.Invoke(content);
|
||||
|
||||
// channel.BasicAck(ea.DeliveryTag, false);
|
||||
// await Task.Yield();
|
||||
// };
|
||||
|
||||
// string consumerTag = channel.BasicConsume(mqSettings.QueueName, false, consumer);
|
||||
|
||||
// return true;
|
||||
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// logger.LogError(ex, $"Ошибка при получении сообщений из очереди: {mqSettings.HostName}, {mqSettings.QueueName}");
|
||||
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
//channel?.Close();
|
||||
//connection?.Close();
|
||||
|
||||
//channel?.Dispose();
|
||||
//connection?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.BLL.Services.Interfaces
|
||||
{
|
||||
|
||||
@@ -6,8 +6,4 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PARR.Constants\PARR.Constants.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.DTOs.RabbitApi;
|
||||
using PARR.Domain.Settings;
|
||||
|
||||
namespace PARR.BLL.Services.Interfaces
|
||||
namespace PARR.Core.Common.RabbitServices
|
||||
{
|
||||
public interface IMqAdminService
|
||||
public interface IRabbitAdminService
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить статистику соединений из RabbitMQ
|
||||
/// </summary>
|
||||
/// <param name="mqSettings"></param>
|
||||
/// <returns></returns>
|
||||
Task<MqApiResult> GetConnectionsAsync(IMqSettings mqSettings);
|
||||
Task<RabbitApiResult> GetConnectionsAsync(IMqSettings mqSettings);
|
||||
|
||||
/// <summary>
|
||||
/// Получить статистику по очередям из RabbitMQ
|
||||
/// </summary>
|
||||
/// <param name="mqSettings"></param>
|
||||
/// <returns></returns>
|
||||
Task<MqApiResult> GetQueuesAsync(IMqSettings mqSettings);
|
||||
Task<RabbitApiResult> GetQueuesAsync(IMqSettings mqSettings);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
using PARR.BLL.Contracts.Interfaces;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.Domain.Common.Rabbit;
|
||||
using PARR.Domain.Settings;
|
||||
|
||||
namespace PARR.BLL.Services.Interfaces
|
||||
namespace PARR.Core.Common.RabbitServices
|
||||
{
|
||||
public delegate Task MqMessageHandlerDelegate(string msg);
|
||||
|
||||
public interface IMqService : IAsyncDisposable // IDisposable
|
||||
public interface IRabbitService : IAsyncDisposable
|
||||
{
|
||||
Task<bool> InitConsumerAsync(IMqSettings mqSettings, MqMessageHandlerDelegate messageHandler);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PARR.BLL.Services.Interfaces
|
||||
/// <param name="mqSettings"></param>
|
||||
/// <param name="msgList"></param>
|
||||
/// <returns></returns>
|
||||
Task<MqSendResult> SendAsync(IMqSettings mqSettings, string[] msgList);
|
||||
Task<RabbitSendResult> SendAsync(IMqSettings mqSettings, string[] msgList);
|
||||
|
||||
/// <summary>
|
||||
/// Отправить сообщение в очередь используя список объектов
|
||||
@@ -24,6 +24,6 @@ namespace PARR.BLL.Services.Interfaces
|
||||
/// <param name="mqSettings"></param>
|
||||
/// <param name="msgObjectList"></param>
|
||||
/// <returns></returns>
|
||||
Task<MqSendResult> SendAsync(IMqSettings mqSettings, List<object> msgObjectList);
|
||||
Task<RabbitSendResult> SendAsync(IMqSettings mqSettings, List<object> msgObjectList);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Infrastructure\" />
|
||||
<Folder Include="Common\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Cache.Models.Base;
|
||||
using PARR.DAL.Cache.Models.Base;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.DAL.Cache.Models
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user