feat(EsppSync): доработка логики
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using PARR.DAL.Contracts;
|
using PARR.Constants;
|
||||||
|
using PARR.DAL.Contracts;
|
||||||
|
|
||||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using PARR.API.Contracts.V1;
|
|||||||
using PARR.API.Contracts.V1.Responses;
|
using PARR.API.Contracts.V1.Responses;
|
||||||
using PARR.API.Contracts.V1.Responses.Base;
|
using PARR.API.Contracts.V1.Responses.Base;
|
||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using PARR.API.Contracts.V1.Responses.Base;
|
|||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Extensions;
|
using PARR.API.Extensions;
|
||||||
using PARR.BLL.Helpers;
|
using PARR.BLL.Helpers;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.DomainModels;
|
using PARR.DAL.DomainModels;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PARR.DAL.Contracts
|
namespace PARR.Constants
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Список роботов
|
/// Список роботов
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Context;
|
using PARR.DAL.Context;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PARR.DAL.Contracts;
|
using PARR.Constants;
|
||||||
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces.Base;
|
using PARR.DAL.Services.Interfaces.Base;
|
||||||
|
|
||||||
|
|||||||
16
PARR.EsppSync/EsppSyncInstaller.cs
Normal file
16
PARR.EsppSync/EsppSyncInstaller.cs
Normal file
@@ -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<EsppObject>(this IServiceCollection services, IConfiguration configuration) where EsppObject : class, IEsppObject
|
||||||
|
{
|
||||||
|
services.InstallDalServices(configuration);
|
||||||
|
|
||||||
|
services.AddTransient<ISyncService<EsppObject>, SyncService<EsppObject>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
namespace PARR.EsppSync
|
using PARR.Constants;
|
||||||
|
|
||||||
|
namespace PARR.EsppSync
|
||||||
{
|
{
|
||||||
public interface IEsppObject
|
public interface IEsppObject
|
||||||
{
|
{
|
||||||
public string TemplateName { get; set; }
|
public string TemplateName { get; set; }
|
||||||
|
|
||||||
|
public RobotsEnum Robot { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using PARR.DAL.Contracts;
|
using PARR.Constants;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
|
|
||||||
namespace PARR.EsppSync
|
namespace PARR.EsppSync
|
||||||
@@ -21,6 +21,6 @@ namespace PARR.EsppSync
|
|||||||
|
|
||||||
public interface ISyncService<EsppObject> where EsppObject : class, IEsppObject
|
public interface ISyncService<EsppObject> where EsppObject : class, IEsppObject
|
||||||
{
|
{
|
||||||
Task SyncEsppObjectAsync(string str, ParserHandlerDelegate<EsppObject> parser, ConvertDbObjToComparisonObjHandlerDelegate<EsppObject> converterToEsppObject, RobotsEnum robot);
|
Task SyncEsppObjectAsync(string str, ParserHandlerDelegate<EsppObject> parser, ConvertDbObjToComparisonObjHandlerDelegate<EsppObject> converterToEsppObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
@@ -24,8 +25,7 @@ namespace PARR.EsppSync
|
|||||||
public async Task SyncEsppObjectAsync(
|
public async Task SyncEsppObjectAsync(
|
||||||
string str,
|
string str,
|
||||||
ParserHandlerDelegate<EsppObject> parser,
|
ParserHandlerDelegate<EsppObject> parser,
|
||||||
ConvertDbObjToComparisonObjHandlerDelegate<EsppObject> converterToEsppObject,
|
ConvertDbObjToComparisonObjHandlerDelegate<EsppObject> converterToEsppObject
|
||||||
RobotsEnum robot
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
logger.LogDebug($"Получил строку. Начинаю работать. Строка: {str}");
|
logger.LogDebug($"Получил строку. Начинаю работать. Строка: {str}");
|
||||||
@@ -65,25 +65,25 @@ namespace PARR.EsppSync
|
|||||||
|
|
||||||
if (isChanged)
|
if (isChanged)
|
||||||
{
|
{
|
||||||
SetUpdateStatus(ref template, robotConfigurationService, robot);
|
SetUpdateStatus(ref template, robotConfigurationService, esppObject.Robot);
|
||||||
|
|
||||||
if (!await templateService.CommitAsync())
|
if (!await templateService.CommitAsync())
|
||||||
logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {robot}");
|
logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {esppObject.Robot}");
|
||||||
else
|
else
|
||||||
logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Updating}, Template {template.Name}, Robot: {robot}");
|
logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Updating}, Template {template.Name}, Robot: {esppObject.Robot}");
|
||||||
}//надо ли проверять если не изменился, но был статус Updating не понятно. Доверяем роботу пока, что после окончания работ он точно сообщит
|
}//надо ли проверять если не изменился, но был статус Updating не понятно. Доверяем роботу пока, что после окончания работ он точно сообщит
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//если все поля совпали
|
//если все поля совпали
|
||||||
//проверяем, какой был статус предыдущий статус в БД, если он был не Ок, то ставим ему ОК
|
//проверяем, какой был статус предыдущий статус в БД, если он был не Ок, то ставим ему ОК
|
||||||
var robotConfig = robotConfigurationService.GetFromTemplateByRobotCode(robot, ref template);
|
var robotConfig = robotConfigurationService.GetFromTemplateByRobotCode(esppObject.Robot, ref template);
|
||||||
if (robotConfig.TaskStatusCode != (int)TaskStatusEnum.Ok)
|
if (robotConfig.TaskStatusCode != (int)TaskStatusEnum.Ok)
|
||||||
{
|
{
|
||||||
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Ok, ref robotConfig);
|
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Ok, ref robotConfig);
|
||||||
if (!await templateService.CommitAsync())
|
if (!await templateService.CommitAsync())
|
||||||
logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {robot}");
|
logger.LogError($"Не удалось изменить запись Template {template.Name}, Robot: {esppObject.Robot}");
|
||||||
else
|
else
|
||||||
logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Ok}, Template {template.Name}, Robot: {robot}");
|
logger.LogInformation($"Установлен принудительный статус {TaskStatusEnum.Ok}, Template {template.Name}, Robot: {esppObject.Robot}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
|
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
|
||||||
<ProjectReference Include="..\PARR.DAL\PARR.DAL.csproj" />
|
<ProjectReference Include="..\PARR.DAL\PARR.DAL.csproj" />
|
||||||
|
<ProjectReference Include="..\PARR.EsppSync\PARR.EsppSync.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.BLL.Domain.Mq;
|
using PARR.BLL.Domain.Mq;
|
||||||
using PARR.BLL.Helpers;
|
using PARR.BLL.Helpers;
|
||||||
|
using PARR.Constants;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|||||||
Reference in New Issue
Block a user