diff --git a/PARR.API/Contracts/V1/Requests/Queries/RobotHistoryQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/RobotHistoryQuery.cs index 9c060738..1f68b7cd 100644 --- a/PARR.API/Contracts/V1/Requests/Queries/RobotHistoryQuery.cs +++ b/PARR.API/Contracts/V1/Requests/Queries/RobotHistoryQuery.cs @@ -1,4 +1,5 @@ -using PARR.DAL.Contracts; +using PARR.Constants; +using PARR.DAL.Contracts; namespace PARR.API.Contracts.V1.Requests.Queries { diff --git a/PARR.API/Controllers/V1/RobotTaskController.cs b/PARR.API/Controllers/V1/RobotTaskController.cs index dde23f19..ccdd2d17 100644 --- a/PARR.API/Controllers/V1/RobotTaskController.cs +++ b/PARR.API/Controllers/V1/RobotTaskController.cs @@ -5,6 +5,7 @@ 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.Models; using PARR.DAL.Services.Interfaces; diff --git a/PARR.API/Controllers/V1/TemplateController.cs b/PARR.API/Controllers/V1/TemplateController.cs index 335a8d00..7e4cbc0b 100644 --- a/PARR.API/Controllers/V1/TemplateController.cs +++ b/PARR.API/Controllers/V1/TemplateController.cs @@ -9,6 +9,7 @@ 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.Contracts; using PARR.DAL.DomainModels; using PARR.DAL.Models; diff --git a/PARR.DAL/Contracts/RobotsEnum.cs b/PARR.Constants/RobotsEnum.cs similarity index 93% rename from PARR.DAL/Contracts/RobotsEnum.cs rename to PARR.Constants/RobotsEnum.cs index d81e5543..3aa6da9a 100644 --- a/PARR.DAL/Contracts/RobotsEnum.cs +++ b/PARR.Constants/RobotsEnum.cs @@ -1,4 +1,4 @@ -namespace PARR.DAL.Contracts +namespace PARR.Constants { /// /// Список роботов diff --git a/PARR.DAL/Services/Implementations/RobotConfigurationService.cs b/PARR.DAL/Services/Implementations/RobotConfigurationService.cs index ddfca2a0..edc58728 100644 --- a/PARR.DAL/Services/Implementations/RobotConfigurationService.cs +++ b/PARR.DAL/Services/Implementations/RobotConfigurationService.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using PARR.Constants; using PARR.DAL.Context; using PARR.DAL.Contracts; using PARR.DAL.Models; diff --git a/PARR.DAL/Services/Implementations/TemplateService.cs b/PARR.DAL/Services/Implementations/TemplateService.cs index 34b7ef45..8a85860a 100644 --- a/PARR.DAL/Services/Implementations/TemplateService.cs +++ b/PARR.DAL/Services/Implementations/TemplateService.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using PARR.Constants; using PARR.DAL.Context; using PARR.DAL.Contracts; using PARR.DAL.Models; diff --git a/PARR.DAL/Services/Interfaces/IRobotConfigurationService.cs b/PARR.DAL/Services/Interfaces/IRobotConfigurationService.cs index a2f37b68..f5540a9d 100644 --- a/PARR.DAL/Services/Interfaces/IRobotConfigurationService.cs +++ b/PARR.DAL/Services/Interfaces/IRobotConfigurationService.cs @@ -1,4 +1,5 @@ -using PARR.DAL.Contracts; +using PARR.Constants; +using PARR.DAL.Contracts; using PARR.DAL.Models; using PARR.DAL.Services.Interfaces.Base; diff --git a/PARR.EsppSync/EsppSyncInstaller.cs b/PARR.EsppSync/EsppSyncInstaller.cs new file mode 100644 index 00000000..afba32c0 --- /dev/null +++ b/PARR.EsppSync/EsppSyncInstaller.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using PARR.DAL; + +namespace PARR.EsppSync +{ + public static class EsppSyncInstaller + { + public static void InstallEsppSyncServices(this IServiceCollection services, IConfiguration configuration) where EsppObject : class, IEsppObject + { + services.InstallDalServices(configuration); + + services.AddTransient, SyncService>(); + } + } +} diff --git a/PARR.EsppSync/IEsppObject.cs b/PARR.EsppSync/IEsppObject.cs index c1f410fc..64f3f877 100644 --- a/PARR.EsppSync/IEsppObject.cs +++ b/PARR.EsppSync/IEsppObject.cs @@ -1,7 +1,11 @@ -namespace PARR.EsppSync +using PARR.Constants; + +namespace PARR.EsppSync { public interface IEsppObject { public string TemplateName { get; set; } + + public RobotsEnum Robot { get; set; } } } diff --git a/PARR.EsppSync/ISyncService.cs b/PARR.EsppSync/ISyncService.cs index f8a092a7..6c46d060 100644 --- a/PARR.EsppSync/ISyncService.cs +++ b/PARR.EsppSync/ISyncService.cs @@ -1,4 +1,4 @@ -using PARR.DAL.Contracts; +using PARR.Constants; using PARR.DAL.Models; namespace PARR.EsppSync @@ -21,6 +21,6 @@ namespace PARR.EsppSync public interface ISyncService where EsppObject : class, IEsppObject { - Task SyncEsppObjectAsync(string str, ParserHandlerDelegate parser, ConvertDbObjToComparisonObjHandlerDelegate converterToEsppObject, RobotsEnum robot); + Task SyncEsppObjectAsync(string str, ParserHandlerDelegate parser, ConvertDbObjToComparisonObjHandlerDelegate converterToEsppObject); } } \ No newline at end of file diff --git a/PARR.EsppSync/SyncService.cs b/PARR.EsppSync/SyncService.cs index f2986e87..d6ff6a68 100644 --- a/PARR.EsppSync/SyncService.cs +++ b/PARR.EsppSync/SyncService.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using PARR.Constants; using PARR.DAL.Contracts; using PARR.DAL.Models; using PARR.DAL.Services.Interfaces; @@ -24,8 +25,7 @@ namespace PARR.EsppSync public async Task SyncEsppObjectAsync( string str, ParserHandlerDelegate parser, - ConvertDbObjToComparisonObjHandlerDelegate converterToEsppObject, - RobotsEnum robot + ConvertDbObjToComparisonObjHandlerDelegate converterToEsppObject ) { logger.LogDebug($"Получил строку. Начинаю работать. Строка: {str}"); @@ -65,25 +65,25 @@ namespace PARR.EsppSync if (isChanged) { - SetUpdateStatus(ref template, robotConfigurationService, robot); + SetUpdateStatus(ref template, robotConfigurationService, esppObject.Robot); if (!await templateService.CommitAsync()) - logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {robot}"); + logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {esppObject.Robot}"); else - logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Updating}, Template {template.Name}, Robot: {robot}"); + logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Updating}, Template {template.Name}, Robot: {esppObject.Robot}"); }//надо ли проверять если не изменился, но был статус Updating не понятно. Доверяем роботу пока, что после окончания работ он точно сообщит else { //если все поля совпали //проверяем, какой был статус предыдущий статус в БД, если он был не Ок, то ставим ему ОК - var robotConfig = robotConfigurationService.GetFromTemplateByRobotCode(robot, ref template); + var robotConfig = robotConfigurationService.GetFromTemplateByRobotCode(esppObject.Robot, ref template); if (robotConfig.TaskStatusCode != (int)TaskStatusEnum.Ok) { robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Ok, ref robotConfig); if (!await templateService.CommitAsync()) - logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {robot}"); + logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {esppObject.Robot}"); else - logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Ok}, Template {template.Name}, Robot: {robot}"); + logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Ok}, Template {template.Name}, Robot: {esppObject.Robot}"); } } } diff --git a/PARR.EsppTemplateSync/PARR.EsppTemplateSync.csproj b/PARR.EsppTemplateSync/PARR.EsppTemplateSync.csproj index 3737e35b..09175082 100644 --- a/PARR.EsppTemplateSync/PARR.EsppTemplateSync.csproj +++ b/PARR.EsppTemplateSync/PARR.EsppTemplateSync.csproj @@ -14,6 +14,7 @@ + diff --git a/PARR.EsppTemplateSync/Services/Manager.cs b/PARR.EsppTemplateSync/Services/Manager.cs index 4dc4b864..f3d30a0e 100644 --- a/PARR.EsppTemplateSync/Services/Manager.cs +++ b/PARR.EsppTemplateSync/Services/Manager.cs @@ -1,6 +1,7 @@ using AutoMapper; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using PARR.Constants; using PARR.DAL.Contracts; using PARR.DAL.Models; using PARR.DAL.Services.Interfaces; diff --git a/PARR.GeneratorTemplates/Services/TemplateManager.cs b/PARR.GeneratorTemplates/Services/TemplateManager.cs index fbf70405..7f4633ef 100644 --- a/PARR.GeneratorTemplates/Services/TemplateManager.cs +++ b/PARR.GeneratorTemplates/Services/TemplateManager.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging; using PARR.BLL.Domain.Mq; using PARR.BLL.Helpers; +using PARR.Constants; using PARR.DAL.Contracts; using PARR.DAL.Models; using PARR.DAL.Services.Interfaces;