feat(api, bll, dal, generatorTemplates, templateActivator): запись истории изменения шаблонов
This commit is contained in:
@@ -9,6 +9,7 @@ using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using System.Text.Json;
|
||||
|
||||
@@ -21,18 +22,21 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IMqService mqService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public GeneratorTemplateController(
|
||||
IValidator<GeneratorTemplateRequest> validator,
|
||||
IMqService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings
|
||||
MqSettings mqSettings,
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
this.validator = validator;
|
||||
this.mqService = mqService;
|
||||
this.uriService = uriService;
|
||||
this.mqSettings = mqSettings;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,7 +64,8 @@ namespace PARR.API.Controllers.V1
|
||||
WorkId = request.WorkId,
|
||||
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);
|
||||
|
||||
@@ -9,6 +9,7 @@ using PARR.API.Services.Interfaces;
|
||||
using PARR.API.Settings;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using System.Text.Json;
|
||||
@@ -26,13 +27,15 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public TemplateActivatorController(
|
||||
IValidator<TemplateActivatorRequest> validator,
|
||||
IMqService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings,
|
||||
IApplicationsInWorkService applicationsInWorkService
|
||||
IApplicationsInWorkService applicationsInWorkService,
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
this.validator = validator;
|
||||
@@ -40,6 +43,7 @@ namespace PARR.API.Controllers.V1
|
||||
this.uriService = uriService;
|
||||
this.mqSettings = mqSettings;
|
||||
this.applicationsInWorkService = applicationsInWorkService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +68,8 @@ namespace PARR.API.Controllers.V1
|
||||
var mqRequest = new TemplateActivatorMq
|
||||
{
|
||||
ApplicationInWorkId = applicationInWorkId,
|
||||
Action = request.Action
|
||||
Action = request.Action,
|
||||
HistoryInitiator = new HistoryInitiator { InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }
|
||||
};
|
||||
|
||||
var msg = JsonSerializer.Serialize(mqRequest);
|
||||
|
||||
@@ -11,6 +11,7 @@ using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainModels;
|
||||
@@ -143,7 +144,7 @@ namespace PARR.API.Controllers.V1
|
||||
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, ref config);
|
||||
}
|
||||
|
||||
if (!await templateService.CommitAsync(new DAL.Models.Base.History.Base.HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
|
||||
if (!await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении шаблона." } }));
|
||||
|
||||
var templateToResponse = await templateService.GetWithIncludes()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace PARR.BLL.Domain.Mq
|
||||
using PARR.Common.Domain;
|
||||
|
||||
namespace PARR.BLL.Domain.Mq
|
||||
{
|
||||
/// <summary>
|
||||
/// Модель в MQ, запрос на генерацию шаблона
|
||||
@@ -39,5 +41,10 @@
|
||||
/// Активировать расписание
|
||||
/// </summary>
|
||||
public bool? IsActiveSchedule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Инициатор запроса к генератору
|
||||
/// </summary>
|
||||
public IHistoryInitiator? HistoryInitiator { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
|
||||
namespace PARR.BLL.Domain.Mq
|
||||
{
|
||||
@@ -16,5 +17,10 @@ namespace PARR.BLL.Domain.Mq
|
||||
/// Действие по активации/деактивации
|
||||
/// </summary>
|
||||
public TemplateActivatorActionsEnum Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Инициатор изменений
|
||||
/// </summary>
|
||||
public IHistoryInitiator? HistoryInitiator { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using PARR.Constants;
|
||||
|
||||
namespace PARR.DAL.Models.Base.History.Base
|
||||
namespace PARR.Common.Domain
|
||||
{
|
||||
public class HistoryInitiator : IHistoryInitiator
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using PARR.Constants;
|
||||
|
||||
namespace PARR.DAL.Models.Base.History.Base
|
||||
namespace PARR.Common.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// Инициатор изменений, ведение истории
|
||||
@@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PARR.Constants\PARR.Constants.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace PARR.DAL.Context
|
||||
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
|
||||
|
||||
public DbSet<Template> Templates { get; set; }
|
||||
//public DbSet<TemplateHistory> TemplateHistories { get; set; }
|
||||
public DbSet<TemplateHistory> TemplateHistories { get; set; }
|
||||
public DbSet<Models.TaskStatus> TaskStatuses { get; set; }
|
||||
public DbSet<RobotStatus> RobotStatuses { get; set; }
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("TemplateId");
|
||||
|
||||
b.ToTable("AgentHistories");
|
||||
b.ToTable("AgentHistories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.AgentHistoryLevel", b =>
|
||||
@@ -72,7 +72,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AgentHistoryLevels");
|
||||
b.ToTable("AgentHistoryLevels", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -101,7 +101,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("WorkGroupId");
|
||||
|
||||
b.ToTable("AppInWorkInWorkGroups");
|
||||
b.ToTable("AppInWorkInWorkGroups", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
|
||||
@@ -130,7 +130,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("Name", "ApplicationTypeId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Applications");
|
||||
b.ToTable("Applications", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b =>
|
||||
@@ -157,7 +157,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.ToTable("ApplicationsInHost");
|
||||
b.ToTable("ApplicationsInHost", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b =>
|
||||
@@ -181,7 +181,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ApplicationTypes");
|
||||
b.ToTable("ApplicationTypes", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -294,7 +294,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("WorkId", "ApplicationId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ApplicationsInWorks");
|
||||
b.ToTable("ApplicationsInWorks", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.DistributionPeriod", b =>
|
||||
@@ -319,7 +319,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("Type");
|
||||
|
||||
b.ToTable("DistributionPeriods");
|
||||
b.ToTable("DistributionPeriods", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -349,7 +349,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Type");
|
||||
|
||||
b.ToTable("DistributionPeriodTypes");
|
||||
b.ToTable("DistributionPeriodTypes", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -383,7 +383,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Code");
|
||||
|
||||
b.ToTable("EkStatuses");
|
||||
b.ToTable("EkStatuses", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -446,7 +446,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("EsppSchTypes");
|
||||
b.ToTable("EsppSchTypes", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -515,7 +515,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("TypeScheduleId", "TypeId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("EsppSchTypeConfigs");
|
||||
b.ToTable("EsppSchTypeConfigs", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -618,7 +618,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("EsppSchTypeSchedules");
|
||||
b.ToTable("EsppSchTypeSchedules", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -691,7 +691,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("TypeId");
|
||||
|
||||
b.ToTable("EsppSchTypeValues");
|
||||
b.ToTable("EsppSchTypeValues", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -1492,7 +1492,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("TypeValueId");
|
||||
|
||||
b.ToTable("EsppSchValues");
|
||||
b.ToTable("EsppSchValues", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
@@ -1539,7 +1539,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("WorkGroupId");
|
||||
|
||||
b.ToTable("Hosts");
|
||||
b.ToTable("Hosts", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.JobAutoControl", b =>
|
||||
@@ -1583,7 +1583,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("ApplicationInWorkId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("JobAutoControls");
|
||||
b.ToTable("JobAutoControls", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.JobAutoControlInEkStatus", b =>
|
||||
@@ -1598,7 +1598,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("EkStatusCode");
|
||||
|
||||
b.ToTable("JobAutoControlInEkStatus");
|
||||
b.ToTable("JobAutoControlInEkStatus", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.JobEkMask", b =>
|
||||
@@ -1622,7 +1622,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("JobAutoControlId", "Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("JobEkMasks");
|
||||
b.ToTable("JobEkMasks", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Order", b =>
|
||||
@@ -1674,7 +1674,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("TemplateId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
b.ToTable("Orders", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.OrderStatus", b =>
|
||||
@@ -1695,7 +1695,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Code");
|
||||
|
||||
b.ToTable("OrderStatuses");
|
||||
b.ToTable("OrderStatuses", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -1748,7 +1748,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ParrComponents");
|
||||
b.ToTable("ParrComponents", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -1855,7 +1855,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("EsppId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Processes");
|
||||
b.ToTable("Processes", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ResponseArea", b =>
|
||||
@@ -1872,7 +1872,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Code");
|
||||
|
||||
b.ToTable("ResponseAreas");
|
||||
b.ToTable("ResponseAreas", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -1998,7 +1998,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Robots");
|
||||
b.ToTable("Robots", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -2053,7 +2053,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("TemplateId", "RobotCode")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RobotConfigurations");
|
||||
b.ToTable("RobotConfigurations", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.RobotHistory", b =>
|
||||
@@ -2091,7 +2091,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("TaskStatusCode");
|
||||
|
||||
b.ToTable("RobotHistories");
|
||||
b.ToTable("RobotHistories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.RobotHistoryLevel", b =>
|
||||
@@ -2112,7 +2112,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Level");
|
||||
|
||||
b.ToTable("RobotHistoryLevels");
|
||||
b.ToTable("RobotHistoryLevels", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -2159,7 +2159,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Code");
|
||||
|
||||
b.ToTable("RobotStatuses");
|
||||
b.ToTable("RobotStatuses", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -2207,7 +2207,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
b.ToTable("Roles", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -2241,7 +2241,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Name");
|
||||
|
||||
b.ToTable("Settings");
|
||||
b.ToTable("Settings", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -2347,7 +2347,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("ProcessId");
|
||||
|
||||
b.ToTable("Subprocesses");
|
||||
b.ToTable("Subprocesses", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.TaskStatus", b =>
|
||||
@@ -2368,7 +2368,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Code");
|
||||
|
||||
b.ToTable("TaskStatuses");
|
||||
b.ToTable("TaskStatuses", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
@@ -2446,7 +2446,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Templates");
|
||||
b.ToTable("Templates", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.TemplateHistory", b =>
|
||||
@@ -2493,7 +2493,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.ToTable("TemplateHistories");
|
||||
b.ToTable("TemplateHistories", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
||||
@@ -2525,7 +2525,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("SubprocessId");
|
||||
|
||||
b.ToTable("Tnks");
|
||||
b.ToTable("Tnks", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.User", b =>
|
||||
@@ -2556,7 +2556,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("Ip")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Users");
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.UsersInRole", b =>
|
||||
@@ -2571,7 +2571,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UsersInRoles");
|
||||
b.ToTable("UsersInRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.WeekendDay", b =>
|
||||
@@ -2588,7 +2588,7 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("Date")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("WeekendDays");
|
||||
b.ToTable("WeekendDays", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
|
||||
@@ -2623,7 +2623,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("TnkId");
|
||||
|
||||
b.ToTable("Works");
|
||||
b.ToTable("Works", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
|
||||
@@ -2646,7 +2646,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("ResponseAreaCode");
|
||||
|
||||
b.ToTable("WorkGroups");
|
||||
b.ToTable("WorkGroups", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.AgentHistory", b =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models.Base;
|
||||
using PARR.DAL.Models.Base.History;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Models.Base;
|
||||
using PARR.DAL.Models.Base.History;
|
||||
using PARR.DAL.Models.Base.History.Base;
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace PARR.DAL
|
||||
services.AddTransient<IResponseAreaService, ResponseAreaService>();
|
||||
services.AddTransient<IJobAutoControlService, JobAutoControlService>();
|
||||
services.AddTransient<IJobEkMaskService, JobEkMaskService>();
|
||||
services.AddTransient<ITemplateHistoryService, TemplateHistoryService>();
|
||||
|
||||
|
||||
// TransformServices
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.Base;
|
||||
@@ -38,7 +39,7 @@ namespace PARR.DAL.Services.Abstracts
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> CommitAsync(HistoryInitiator? initiator = null)
|
||||
public async Task<bool> CommitAsync(IHistoryInitiator? initiator = null)
|
||||
{
|
||||
#region Изменения
|
||||
var modifiedEntrities = EntitiContext.ChangeTracker.Entries()
|
||||
|
||||
23
PARR.DAL/Services/Implementations/TemplateHistoryService.cs
Normal file
23
PARR.DAL/Services/Implementations/TemplateHistoryService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class TemplateHistoryService : BaseService<TemplateHistory>, ITemplateHistoryService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
protected override DbSet<TemplateHistory> EntitySet => dataContext.TemplateHistories;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public TemplateHistoryService(DataContext dataContext, ILogger<TemplateHistoryService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.Base;
|
||||
using PARR.DAL.Models.Base.History.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.Base
|
||||
{
|
||||
@@ -17,6 +17,6 @@ namespace PARR.DAL.Services.Interfaces.Base
|
||||
bool Delete(T obj);
|
||||
|
||||
//Task<bool> CommitAsync();
|
||||
Task<bool> CommitAsync(HistoryInitiator? initiator = null);
|
||||
Task<bool> CommitAsync(IHistoryInitiator? initiator = null);
|
||||
}
|
||||
}
|
||||
|
||||
9
PARR.DAL/Services/Interfaces/ITemplateHistoryService.cs
Normal file
9
PARR.DAL/Services/Interfaces/ITemplateHistoryService.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface ITemplateHistoryService : IBaseService<TemplateHistory>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ namespace PARR.GeneratorTemplates.Services
|
||||
// сохраняем
|
||||
foreach (var template in templates)
|
||||
{
|
||||
if (!await templateService.CreateAsync(template) || !await templateService.CommitAsync())
|
||||
if (!await templateService.CreateAsync(template) || !await templateService.CommitAsync(query.HistoryInitiator))
|
||||
{
|
||||
logger.LogError($"Ошибка при создании шаблона: Name: {template.Name}, ApplicationInWorkId: {template.ApplicationInWorkId}, HostId: {template.HostId}");
|
||||
}
|
||||
@@ -318,7 +318,7 @@ namespace PARR.GeneratorTemplates.Services
|
||||
}
|
||||
});
|
||||
|
||||
if (await templateService.CommitAsync())
|
||||
if (await templateService.CommitAsync(query.HistoryInitiator))
|
||||
existTemplates.ForEach(item => logger.LogInformation($"Деактивирован шаблон: {item.Name}"));
|
||||
else
|
||||
existTemplates.ForEach(item => logger.LogError($"Ошибка при дактивации шаблона: {item.Name}"));
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.BLL.Domain.Mq;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.JobAutoControl.Settings;
|
||||
@@ -96,7 +97,8 @@ namespace PARR.JobAutoControl
|
||||
WorkId = job.ApplicationsInWork!.WorkId,
|
||||
StatusEk = ekStatus.EkStatusCode,
|
||||
IsActiveTemplate = job.OnTemplateIsActive,
|
||||
IsActiveSchedule = job.OnScheduleIsActive
|
||||
IsActiveSchedule = job.OnScheduleIsActive,
|
||||
HistoryInitiator = new HistoryInitiator { InitiatorComment = "Запрос на генерацию с авто-контроля", InitiatorParrComponentId = ParrComponentsEnum.JobAutoControl }
|
||||
};
|
||||
|
||||
var msg = JsonSerializer.Serialize(request);
|
||||
@@ -138,7 +140,8 @@ namespace PARR.JobAutoControl
|
||||
var request = new TemplateActivatorMq
|
||||
{
|
||||
Action = TemplateActivatorActionsEnum.DeactivateAllForAutoControl,
|
||||
ApplicationInWorkId = applicationInWorkId
|
||||
ApplicationInWorkId = applicationInWorkId,
|
||||
HistoryInitiator = new HistoryInitiator { InitiatorComment = "Запрос на деактивацию с авто-контроля", InitiatorParrComponentId = ParrComponentsEnum.JobAutoControl }
|
||||
};
|
||||
|
||||
var msg = JsonSerializer.Serialize(request);
|
||||
@@ -176,7 +179,8 @@ namespace PARR.JobAutoControl
|
||||
var request = new TemplateActivatorMq
|
||||
{
|
||||
Action = TemplateActivatorActionsEnum.ActivateAllForAutoControl,
|
||||
ApplicationInWorkId = applicationInWorkId
|
||||
ApplicationInWorkId = applicationInWorkId,
|
||||
HistoryInitiator = new HistoryInitiator { InitiatorComment = "Запрос на активацию с авто-контроля", InitiatorParrComponentId = ParrComponentsEnum.JobAutoControl }
|
||||
};
|
||||
|
||||
var msg = JsonSerializer.Serialize(request);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PARR.Constants;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
|
||||
namespace PARR.TemplateActivator;
|
||||
|
||||
@@ -10,5 +11,5 @@ public interface ITemplateActivator
|
||||
/// <param name="applicationInWorkId"></param>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
Task ChangeStateAsync(Guid applicationInWorkId, TemplateActivatorActionsEnum action);
|
||||
Task ChangeStateAsync(Guid applicationInWorkId, TemplateActivatorActionsEnum action, IHistoryInitiator? historyInitiator);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ internal class MqTemplateActivator : IMqTemplateActivator
|
||||
if (service == null)
|
||||
throw new Exception($"{this.GetType().Name}. Не найден сервис: {nameof(service.GetType)}");
|
||||
|
||||
await service.ChangeStateAsync(query.ApplicationInWorkId, query.Action);
|
||||
await service.ChangeStateAsync(query.ApplicationInWorkId, query.Action, query.HistoryInitiator);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.Common.Domain;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
@@ -34,7 +35,7 @@ internal class TemplateActivator : ITemplateActivator
|
||||
}
|
||||
|
||||
|
||||
public async Task ChangeStateAsync(Guid applicationInWorkId, TemplateActivatorActionsEnum action)
|
||||
public async Task ChangeStateAsync(Guid applicationInWorkId, TemplateActivatorActionsEnum action, IHistoryInitiator? historyInitiator)
|
||||
{
|
||||
var query = templateService.Get()
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
@@ -103,7 +104,10 @@ internal class TemplateActivator : ITemplateActivator
|
||||
break;
|
||||
}
|
||||
|
||||
if (changes > 0 && !await templateService.CommitAsync())
|
||||
if (historyInitiator != null)
|
||||
historyInitiator.InitiatorComment += $" Action: {action.ToString()}";
|
||||
|
||||
if (changes > 0 && !await templateService.CommitAsync(historyInitiator))
|
||||
logger.LogError($"{GetType().Name} не удалось записать измения в БД о новых состояниях шаблонов и расписаний регламентной работы Id {applicationInWorkId}");
|
||||
|
||||
logger.LogDebug($"{GetType().Name} изменил состояние шаблонов/расписаний({changes}) регламентной работы Id {applicationInWorkId}");
|
||||
|
||||
Reference in New Issue
Block a user