refactor(api): Удалены лишние таблицы связанные со старой логикой получения заданий роботом.
This commit is contained in:
@@ -63,23 +63,15 @@
|
||||
public const string getParam = "{id}";
|
||||
}
|
||||
|
||||
public static class TemplateRobotStatus
|
||||
{
|
||||
public const string Get = Base + "/templates/" + templateId + "/robot-statuses";
|
||||
public const string Update = Base + "/templates/" + templateId + "/robot-statuses";
|
||||
|
||||
public const string templateId = "{templateId}";
|
||||
}
|
||||
|
||||
public static class RobotHistory
|
||||
{
|
||||
//public const string GetAll = Base + "/robot-histories/";
|
||||
public const string Create = Base + "/robot-histories/";
|
||||
}
|
||||
|
||||
public static class StatusTemplate
|
||||
public static class TaskStatus
|
||||
{
|
||||
public const string GetAll = Base + "/template-statuses/";
|
||||
public const string GetAll = Base + "/task-statuses/";
|
||||
}
|
||||
|
||||
public static class GeneratorTemplate
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class StatusTemplateResponse
|
||||
{
|
||||
public int Code { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class TemplateRobotStatusResponse : RobotStatusResponse
|
||||
{
|
||||
public int RobotAttemptsNumber { get; set; }
|
||||
public DateTimeOffset? RobotLastStatusUpdated { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.BLL.Services.Interfaces;
|
||||
using PARR.BLL.Settings;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
public class EsppDataController : BaseApiController
|
||||
{
|
||||
private readonly ILogger<EsppDataController> logger;
|
||||
private readonly IFileService fileService;
|
||||
private readonly StorageSettings storageSettings;
|
||||
|
||||
public EsppDataController(
|
||||
ILogger<EsppDataController> logger,
|
||||
IFileService fileService,
|
||||
StorageSettings storageSettings
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.fileService = fileService;
|
||||
this.storageSettings = storageSettings;
|
||||
}
|
||||
|
||||
// UploadTemplates - неактуально, так как стали брать данные с RabbitMQ
|
||||
|
||||
///// <summary>
|
||||
///// Загрузить файл списка шаблонов полученных из ЕСПП в формате csv
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpPost(ApiRoutes.EsppData.UploadTemplates)]
|
||||
//public async Task<IActionResult> UploadTemplates([BindRequired] IFormFile file)
|
||||
//{
|
||||
// if (!fileService.IsExtensionAllowed(file, storageSettings.EsppTemplates!.AllowedExtensions))
|
||||
// return BadRequest(
|
||||
// new Response(false,
|
||||
// new List<ErrorModel> {
|
||||
// new ErrorModel {
|
||||
// Message = $"Недопустимое расширение файла. Разрешенные расширения: {string.Join(", ", storageSettings.EsppTemplates.AllowedExtensions)}"
|
||||
// } }));
|
||||
|
||||
// if (!fileService.IsNotExceededLimit(file, storageSettings.EsppTemplates.MaxFileSizeMb))
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(file), Message = $"Размер файла превышает {storageSettings.EsppTemplates.MaxFileSizeMb} МБайт" } }));
|
||||
|
||||
// var uploadResult = await fileService.UploadAsync(file, storageSettings.EsppTemplates.TemplatePath);
|
||||
// if (uploadResult == null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при сохранении файла" } }));
|
||||
|
||||
// return Ok(new Response<string>("", true, new List<ErrorModel>(), $"Файл загружен."));
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,7 @@ namespace PARR.API.Controllers.V1
|
||||
public class RobotHistoryController : BaseApiController
|
||||
{
|
||||
private readonly IValidator<RobotHistoryRequest> validator;
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IRobotTemplateHistoryService historyService;
|
||||
|
||||
private readonly IMapper mapper;
|
||||
private readonly IUriService uriService;
|
||||
private readonly IRobotHistoryService robotHistoryService;
|
||||
@@ -25,8 +24,6 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
public RobotHistoryController(
|
||||
IValidator<RobotHistoryRequest> validator,
|
||||
ITemplateService templateService,
|
||||
IRobotTemplateHistoryService historyService,
|
||||
IMapper mapper,
|
||||
IUriService uriService,
|
||||
IRobotHistoryService robotHistoryService,
|
||||
@@ -34,8 +31,6 @@ namespace PARR.API.Controllers.V1
|
||||
)
|
||||
{
|
||||
this.validator = validator;
|
||||
this.templateService = templateService;
|
||||
this.historyService = historyService;
|
||||
this.mapper = mapper;
|
||||
this.uriService = uriService;
|
||||
this.robotHistoryService = robotHistoryService;
|
||||
|
||||
@@ -9,12 +9,12 @@ using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
public class StatusTemplateController : BaseApiController
|
||||
public class TaskStatusController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IStatusTemplateService statusTemplateService;
|
||||
|
||||
public StatusTemplateController(
|
||||
public TaskStatusController(
|
||||
IMapper mapper,
|
||||
IStatusTemplateService statusTemplateService
|
||||
)
|
||||
@@ -24,19 +24,19 @@ namespace PARR.API.Controllers.V1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получить список статусов
|
||||
/// Получить список статусов заданий
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.StatusTemplate.GetAll)]
|
||||
[HttpGet(ApiRoutes.TaskStatus.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var statusList = await statusTemplateService.Get()
|
||||
.OrderBy(t => t.Code)
|
||||
.ToListAsync();
|
||||
|
||||
var response = mapper.Map<List<StatusTemplateResponse>>(statusList);
|
||||
var response = mapper.Map<List<TaskStatusResponse>>(statusList);
|
||||
|
||||
return Ok(new Response<List<StatusTemplateResponse>>(response, true));
|
||||
return Ok(new Response<List<TaskStatusResponse>>(response, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,23 +47,25 @@ namespace PARR.API.Controllers.V1
|
||||
.OrderBy(t => t.Name)
|
||||
.AsSplitQuery();
|
||||
|
||||
if (filter.StatusCode.HasValue)
|
||||
{
|
||||
switch (filter.StatusCode.Value)
|
||||
{
|
||||
case (int)TaskStatusEnum.Ok:
|
||||
query = query.Where(t => t.StatusCode == (int)TaskStatusEnum.Ok);
|
||||
break;
|
||||
case (int)TaskStatusEnum.Creating:
|
||||
query = query.Where(t => t.StatusCode == (int)TaskStatusEnum.Creating);
|
||||
break;
|
||||
case (int)TaskStatusEnum.Updating:
|
||||
query = query.Where(t => t.StatusCode == (int)TaskStatusEnum.Updating);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//TODO:!!!
|
||||
|
||||
//if (filter.StatusCode.HasValue)
|
||||
//{
|
||||
// switch (filter.StatusCode.Value)
|
||||
// {
|
||||
// case (int)TaskStatusEnum.Ok:
|
||||
// query = query.Where(t => t.StatusCode == (int)TaskStatusEnum.Ok);
|
||||
// break;
|
||||
// case (int)TaskStatusEnum.Creating:
|
||||
// query = query.Where(t => t.StatusCode == (int)TaskStatusEnum.Creating);
|
||||
// break;
|
||||
// case (int)TaskStatusEnum.Updating:
|
||||
// query = query.Where(t => t.StatusCode == (int)TaskStatusEnum.Updating);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Mask))
|
||||
query = query.Where(t => EF.Functions.Like(t.Name.ToLower(), SqlHelpers.RegexToLike(filter.Mask)));
|
||||
@@ -84,75 +86,75 @@ namespace PARR.API.Controllers.V1
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Template.Get)]
|
||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||
{
|
||||
var template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
//[HttpGet(ApiRoutes.Template.Get)]
|
||||
//public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||
//{
|
||||
// var template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (template == null)
|
||||
return NotFound();
|
||||
// if (template == null)
|
||||
// return NotFound();
|
||||
|
||||
var response = mapper.Map<TemplateResponse>(template);
|
||||
// var response = mapper.Map<TemplateResponse>(template);
|
||||
|
||||
return Ok(new Response<TemplateResponse>(response, true));
|
||||
}
|
||||
// return Ok(new Response<TemplateResponse>(response, true));
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Получить один шаблон по заданному статусу
|
||||
/// </summary>
|
||||
/// <param name="statusCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Template.GetByStatusCode)]
|
||||
public async Task<IActionResult> GetByStatus([FromRoute] int statusCode, [FromQuery] RobinQuery query)
|
||||
{
|
||||
Template? template = null;
|
||||
//[HttpGet(ApiRoutes.Template.GetByStatusCode)]
|
||||
//public async Task<IActionResult> GetByStatus([FromRoute] int statusCode, [FromQuery] RobinQuery query)
|
||||
//{
|
||||
// Template? template = null;
|
||||
|
||||
//1.Ищем `RobotStatusCode` = 22 и `RobotLastStatusUpdated` истекло и `RobotAttemptsNumber` >= допустимого значения из настроек,
|
||||
//ставим всем этим записям `RobotStatusCode`= 33
|
||||
//2.Поиск шаблонов со `StatusCode` 10 или 20 и `RobotStatusCode` = 11.Находим, **выбрали эту запись, конец**.
|
||||
//3.Поиск шаблонов со `StatusCode` 10 или 20 и `RobotStatusCode` = 22.
|
||||
//Далее проверяется `RobotLastStatusUpdated`, что время последнего смены статуса не превышает допустимого(берется из настроек, поле `RobotWaitTime`)
|
||||
//и что текущая попытка не больше разрешенной(берется из настроек, поле `RobotAttemptsNumber`) - если это так, берется эта запись.
|
||||
// //1.Ищем `RobotStatusCode` = 22 и `RobotLastStatusUpdated` истекло и `RobotAttemptsNumber` >= допустимого значения из настроек,
|
||||
// //ставим всем этим записям `RobotStatusCode`= 33
|
||||
// //2.Поиск шаблонов со `StatusCode` 10 или 20 и `RobotStatusCode` = 11.Находим, **выбрали эту запись, конец**.
|
||||
// //3.Поиск шаблонов со `StatusCode` 10 или 20 и `RobotStatusCode` = 22.
|
||||
// //Далее проверяется `RobotLastStatusUpdated`, что время последнего смены статуса не превышает допустимого(берется из настроек, поле `RobotWaitTime`)
|
||||
// //и что текущая попытка не больше разрешенной(берется из настроек, поле `RobotAttemptsNumber`) - если это так, берется эта запись.
|
||||
|
||||
//1.
|
||||
await templateService.CheckAndSetErrorRobotStatusAsync(settingsFromDb.RobotAttemptsNumber, settingsFromDb.RobotWaitTime);
|
||||
// //1.
|
||||
// await templateService.CheckAndSetErrorRobotStatusAsync(settingsFromDb.RobotAttemptsNumber, settingsFromDb.RobotWaitTime);
|
||||
|
||||
|
||||
//2.
|
||||
template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.StatusCode == statusCode && t.RobotStatusCode == (int)RobotStatusEnum.Wait);
|
||||
// //2.
|
||||
// template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t => t.StatusCode == statusCode && t.RobotStatusCode == (int)RobotStatusEnum.Wait);
|
||||
|
||||
//3.
|
||||
if (template == null)
|
||||
{
|
||||
var endDate = DateTimeOffset.UtcNow.Add(-settingsFromDb.RobotWaitTime);
|
||||
template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t =>
|
||||
t.StatusCode == statusCode
|
||||
&& t.RobotStatusCode == (int)RobotStatusEnum.InProgress
|
||||
&& t.RobotAttemptsNumber < settingsFromDb.RobotAttemptsNumber
|
||||
&& t.RobotLastStatusUpdated < endDate
|
||||
);
|
||||
}
|
||||
// //3.
|
||||
// if (template == null)
|
||||
// {
|
||||
// var endDate = DateTimeOffset.UtcNow.Add(-settingsFromDb.RobotWaitTime);
|
||||
// template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t =>
|
||||
// t.StatusCode == statusCode
|
||||
// && t.RobotStatusCode == (int)RobotStatusEnum.InProgress
|
||||
// && t.RobotAttemptsNumber < settingsFromDb.RobotAttemptsNumber
|
||||
// && t.RobotLastStatusUpdated < endDate
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
if (template == null)
|
||||
return NotFound();
|
||||
// if (template == null)
|
||||
// return NotFound();
|
||||
|
||||
var response = mapper.Map<TemplateResponse>(template);
|
||||
// var response = mapper.Map<TemplateResponse>(template);
|
||||
|
||||
if (query.Robin == true)
|
||||
{
|
||||
var stringResponse = mapper.Map<TemplateStringResponse>(response);
|
||||
return Ok(stringResponse);
|
||||
}
|
||||
// if (query.Robin == true)
|
||||
// {
|
||||
// var stringResponse = mapper.Map<TemplateStringResponse>(response);
|
||||
// return Ok(stringResponse);
|
||||
// }
|
||||
|
||||
return Ok(new Response<TemplateResponse>(response, true));
|
||||
}
|
||||
// return Ok(new Response<TemplateResponse>(response, true));
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -160,25 +162,25 @@ namespace PARR.API.Controllers.V1
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut(ApiRoutes.Template.SetOkStatus)]
|
||||
public async Task<IActionResult> SetOkStatus([FromRoute] Guid id)
|
||||
{
|
||||
var template = await templateService.GetWithIncludes()
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
//[HttpPut(ApiRoutes.Template.SetOkStatus)]
|
||||
//public async Task<IActionResult> SetOkStatus([FromRoute] Guid id)
|
||||
//{
|
||||
// var template = await templateService.GetWithIncludes()
|
||||
// .AsSplitQuery()
|
||||
// .FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (template == null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не найден шаблон с id: {id}" } }));
|
||||
// if (template == null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не найден шаблон с id: {id}" } }));
|
||||
|
||||
template.StatusCode = (int)TaskStatusEnum.Ok;
|
||||
// template.StatusCode = (int)TaskStatusEnum.Ok;
|
||||
|
||||
if (!await templateService.CommitAsync())
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при изменении статуса у шаблона с id: {id}" } }));
|
||||
// if (!await templateService.CommitAsync())
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при изменении статуса у шаблона с id: {id}" } }));
|
||||
|
||||
var response = mapper.Map<TemplateResponse>(template);
|
||||
// var response = mapper.Map<TemplateResponse>(template);
|
||||
|
||||
return Ok(new Response<TemplateResponse>(response, true));
|
||||
}
|
||||
// return Ok(new Response<TemplateResponse>(response, true));
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
using AutoMapper;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
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.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
public class TemplateRobotStatusController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IValidator<TemplateRobotStatusRequest> validator;
|
||||
|
||||
public TemplateRobotStatusController(
|
||||
IMapper mapper,
|
||||
ITemplateService templateService,
|
||||
IValidator<TemplateRobotStatusRequest> validator
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.templateService = templateService;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить статус робота по Id шаблона
|
||||
/// </summary>
|
||||
/// <param name="templateId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.TemplateRobotStatus.Get)]
|
||||
public async Task<IActionResult> Get([FromRoute] Guid templateId)
|
||||
{
|
||||
var template = await templateService.Get()
|
||||
.Include(t => t.RobotStatus)
|
||||
.FirstOrDefaultAsync(t => t.Id == templateId);
|
||||
|
||||
if (template == null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не найден шаблон с id: {templateId}" } }));
|
||||
|
||||
var response = mapper.Map<TemplateRobotStatusResponse>(template);
|
||||
|
||||
return Ok(new Response<TemplateRobotStatusResponse>(response, true));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Обновить статус робота по Id шаблона
|
||||
/// </summary>
|
||||
/// <param name="templateId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut(ApiRoutes.TemplateRobotStatus.Update)]
|
||||
public async Task<IActionResult> UpdateStatus([FromRoute] Guid templateId, [FromBody] TemplateRobotStatusRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var template = await templateService.Get()
|
||||
.FirstOrDefaultAsync(t => t.Id == templateId);
|
||||
|
||||
if (template == null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не найден шаблон с id: {templateId}" } }));
|
||||
|
||||
var enumStatus = (RobotStatusEnum)request.Code;
|
||||
|
||||
// изменение статуса
|
||||
templateService.ChangeRobotStatus(enumStatus, ref template);
|
||||
|
||||
if (!await templateService.CommitAsync())
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при изменении статуса шаблону {templateId}" } }));
|
||||
|
||||
var templateToResponse = await templateService.Get()
|
||||
.Include(t => t.RobotStatus)
|
||||
.FirstOrDefaultAsync(t => t.Id == templateId);
|
||||
|
||||
var response = mapper.Map<TemplateRobotStatusResponse>(templateToResponse);
|
||||
|
||||
return Ok(new Response<TemplateRobotStatusResponse>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -63,12 +63,7 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
// === Template ===
|
||||
|
||||
CreateMap<DAL.Models.TaskStatus, StatusTemplateResponse>();
|
||||
|
||||
CreateMap<Template, TemplateRobotStatusResponse>()
|
||||
.ForMember(d => d.Code, o => o.MapFrom(s => s.RobotStatus!.Code))
|
||||
.ForMember(d => d.Name, o => o.MapFrom(s => s.RobotStatus!.Name))
|
||||
.ForMember(d => d.Description, o => o.MapFrom(s => s.RobotStatus!.Description));
|
||||
CreateMap<DAL.Models.TaskStatus, TaskStatusResponse>();
|
||||
|
||||
|
||||
CreateMap<Process, ProcessResponse>();
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace PARR.DAL.Context
|
||||
public DbSet<Models.Setting> Setting { get; set; }
|
||||
|
||||
public DbSet<RobotHistoryLevel> RobotHistoryLevels { get; set; }
|
||||
public DbSet<RobotTemplateHistory> RobotTemplateHistories { get; set; }
|
||||
|
||||
public DbSet<Robot> Robots { get; set; }
|
||||
public DbSet<RobotConfiguration> RobotConfigurations { get; set; }
|
||||
|
||||
1950
PARR.DAL/Migrations/20231006042130_TblTemplatesUpdate.Designer.cs
generated
Normal file
1950
PARR.DAL/Migrations/20231006042130_TblTemplatesUpdate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
135
PARR.DAL/Migrations/20231006042130_TblTemplatesUpdate.cs
Normal file
135
PARR.DAL/Migrations/20231006042130_TblTemplatesUpdate.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class TblTemplatesUpdate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Templates_TaskStatuses_StatusCode",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RobotTemplateHistories");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RobotAttemptsNumber",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RobotLastStatusUpdated",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "StatusCode",
|
||||
table: "Templates",
|
||||
newName: "TaskStatusCode");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_Templates_StatusCode",
|
||||
table: "Templates",
|
||||
newName: "IX_Templates_TaskStatusCode");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Templates_TaskStatuses_TaskStatusCode",
|
||||
table: "Templates",
|
||||
column: "TaskStatusCode",
|
||||
principalTable: "TaskStatuses",
|
||||
principalColumn: "Code");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Templates_TaskStatuses_TaskStatusCode",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "TaskStatusCode",
|
||||
table: "Templates",
|
||||
newName: "StatusCode");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_Templates_TaskStatusCode",
|
||||
table: "Templates",
|
||||
newName: "IX_Templates_StatusCode");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "RobotAttemptsNumber",
|
||||
table: "Templates",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||
name: "RobotLastStatusUpdated",
|
||||
table: "Templates",
|
||||
type: "timestamp with time zone",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RobotTemplateHistories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
HistoryLevel = table.Column<int>(type: "integer", nullable: false),
|
||||
TemplateId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
TemplateStatusCode = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
EsppMessage = table.Column<string>(type: "text", nullable: true),
|
||||
IdSeries = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
RobotMessage = table.Column<string>(type: "text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RobotTemplateHistories", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RobotTemplateHistories_RobotHistoryLevels_HistoryLevel",
|
||||
column: x => x.HistoryLevel,
|
||||
principalTable: "RobotHistoryLevels",
|
||||
principalColumn: "Level",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RobotTemplateHistories_TaskStatuses_TemplateStatusCode",
|
||||
column: x => x.TemplateStatusCode,
|
||||
principalTable: "TaskStatuses",
|
||||
principalColumn: "Code",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RobotTemplateHistories_Templates_TemplateId",
|
||||
column: x => x.TemplateId,
|
||||
principalTable: "Templates",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RobotTemplateHistories_HistoryLevel",
|
||||
table: "RobotTemplateHistories",
|
||||
column: "HistoryLevel");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RobotTemplateHistories_TemplateId",
|
||||
table: "RobotTemplateHistories",
|
||||
column: "TemplateId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RobotTemplateHistories_TemplateStatusCode",
|
||||
table: "RobotTemplateHistories",
|
||||
column: "TemplateStatusCode");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Templates_TaskStatuses_StatusCode",
|
||||
table: "Templates",
|
||||
column: "StatusCode",
|
||||
principalTable: "TaskStatuses",
|
||||
principalColumn: "Code");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -946,44 +946,6 @@ namespace PARR.DAL.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.RobotTemplateHistory", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("EsppMessage")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("HistoryLevel")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("IdSeries")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("RobotMessage")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("TemplateId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("TemplateStatusCode")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HistoryLevel");
|
||||
|
||||
b.HasIndex("TemplateId");
|
||||
|
||||
b.HasIndex("TemplateStatusCode");
|
||||
|
||||
b.ToTable("RobotTemplateHistories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Setting", b =>
|
||||
{
|
||||
b.Property<string>("Name")
|
||||
@@ -1138,16 +1100,10 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("RobotAttemptsNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset?>("RobotLastStatusUpdated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("RobotStatusCode")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("StatusCode")
|
||||
b.Property<int?>("TaskStatusCode")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
@@ -1161,7 +1117,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("RobotStatusCode");
|
||||
|
||||
b.HasIndex("StatusCode");
|
||||
b.HasIndex("TaskStatusCode");
|
||||
|
||||
b.ToTable("Templates");
|
||||
});
|
||||
@@ -1701,33 +1657,6 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("StatusTask");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.RobotTemplateHistory", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.RobotHistoryLevel", "RobotHistoryLevel")
|
||||
.WithMany("robotTemplateHistories")
|
||||
.HasForeignKey("HistoryLevel")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Template", "Template")
|
||||
.WithMany("RobotTemplateHistories")
|
||||
.HasForeignKey("TemplateId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.TaskStatus", "StatusTemplate")
|
||||
.WithMany("RobotTemplateHistories")
|
||||
.HasForeignKey("TemplateStatusCode")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RobotHistoryLevel");
|
||||
|
||||
b.Navigation("StatusTemplate");
|
||||
|
||||
b.Navigation("Template");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Subprocess", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Process", "Process")
|
||||
@@ -1753,21 +1682,17 @@ namespace PARR.DAL.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.RobotStatus", "RobotStatus")
|
||||
b.HasOne("PARR.DAL.Models.RobotStatus", null)
|
||||
.WithMany("Templates")
|
||||
.HasForeignKey("RobotStatusCode");
|
||||
|
||||
b.HasOne("PARR.DAL.Models.TaskStatus", "StatusTask")
|
||||
b.HasOne("PARR.DAL.Models.TaskStatus", null)
|
||||
.WithMany("Templates")
|
||||
.HasForeignKey("StatusCode");
|
||||
.HasForeignKey("TaskStatusCode");
|
||||
|
||||
b.Navigation("ApplicationsInWork");
|
||||
|
||||
b.Navigation("Host");
|
||||
|
||||
b.Navigation("RobotStatus");
|
||||
|
||||
b.Navigation("StatusTask");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
||||
@@ -1943,8 +1868,6 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.RobotHistoryLevel", b =>
|
||||
{
|
||||
b.Navigation("RobotHistories");
|
||||
|
||||
b.Navigation("robotTemplateHistories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.RobotStatus", b =>
|
||||
@@ -1959,16 +1882,12 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.TaskStatus", b =>
|
||||
{
|
||||
b.Navigation("RobotTemplateHistories");
|
||||
|
||||
b.Navigation("Templates");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
|
||||
{
|
||||
b.Navigation("RobotConfigurations");
|
||||
|
||||
b.Navigation("RobotTemplateHistories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace PARR.DAL.Models
|
||||
public required string Description { get; set; }
|
||||
|
||||
|
||||
public ICollection<RobotTemplateHistory> robotTemplateHistories { get; set; } = new HashSet<RobotTemplateHistory>();
|
||||
|
||||
public ICollection<RobotHistory> RobotHistories { get; set; } = new HashSet<RobotHistory>();
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// История работы робота по управлению шаблонами в ЕСПП
|
||||
/// </summary>
|
||||
[Table("RobotTemplateHistories")]
|
||||
public class RobotTemplateHistory : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public int HistoryLevel { get; set; }
|
||||
|
||||
public string? RobotMessage { get; set; }
|
||||
|
||||
public string? EsppMessage { get; set; }
|
||||
|
||||
public Guid TemplateId { get; set; }
|
||||
|
||||
public int TemplateStatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Уникальный идентификатор серии выполнения, нужен для сопоставления истории
|
||||
/// </summary>
|
||||
public Guid IdSeries { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(HistoryLevel))]
|
||||
public RobotHistoryLevel? RobotHistoryLevel { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TemplateId))]
|
||||
public Template? Template { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TemplateStatusCode))]
|
||||
public TaskStatus? StatusTemplate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,5 @@ namespace PARR.DAL.Models
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
|
||||
public ICollection<RobotTemplateHistory> RobotTemplateHistories { get; set; } = new HashSet<RobotTemplateHistory>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,31 +27,31 @@ namespace PARR.DAL.Models
|
||||
/// <summary>
|
||||
/// Статус шаблона. Что нужно сделать роботу в ЕСПП
|
||||
/// </summary>
|
||||
public int? StatusCode { get; set; }
|
||||
//public int? StatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статус работы робота
|
||||
/// </summary>
|
||||
public int? RobotStatusCode { get; set; }
|
||||
//public int? RobotStatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Количество попыток выполнения задания роботом
|
||||
/// </summary>
|
||||
public int? RobotAttemptsNumber { get; set; }
|
||||
//public int? RobotAttemptsNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Последняя дата обновления статуса RobotStatusCode роботом
|
||||
/// </summary>
|
||||
public DateTimeOffset? RobotLastStatusUpdated { get; set; }
|
||||
//public DateTimeOffset? RobotLastStatusUpdated { get; set; }
|
||||
|
||||
|
||||
[ForeignKey(nameof(StatusCode))]
|
||||
public TaskStatus? StatusTask { get; set; }
|
||||
//[ForeignKey(nameof(StatusCode))]
|
||||
//public TaskStatus? StatusTask { get; set; }
|
||||
|
||||
[ForeignKey(nameof(RobotStatusCode))]
|
||||
public RobotStatus? RobotStatus { get; set; }
|
||||
//[ForeignKey(nameof(RobotStatusCode))]
|
||||
//public RobotStatus? RobotStatus { get; set; }
|
||||
|
||||
public ICollection<RobotTemplateHistory> RobotTemplateHistories { get; set; } = new HashSet<RobotTemplateHistory>();
|
||||
//public ICollection<RobotTemplateHistory> RobotTemplateHistories { get; set; } = new HashSet<RobotTemplateHistory>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace PARR.DAL
|
||||
services.AddTransient<IStatusTemplateService, StatusTemplateService>();
|
||||
services.AddTransient<IRobotHistoryLevelService, RobotHistoryLevelService>();
|
||||
services.AddTransient<IRobotStatusService, RobotStatusService>();
|
||||
services.AddTransient<IRobotTemplateHistoryService, RobotTemplateHistoryService>();
|
||||
services.AddTransient<IRobotService, RobotService>();
|
||||
services.AddTransient<IRobotConfigurationService, RobotConfigurationService>();
|
||||
services.AddTransient<IRobotHistoryService, RobotHistoryService>();
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
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 RobotTemplateHistoryService : BaseService<RobotTemplateHistory>, IRobotTemplateHistoryService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
public RobotTemplateHistoryService(DataContext dataContext, ILogger<RobotTemplateHistoryService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
protected override DbSet<RobotTemplateHistory> EntitySet => dataContext.RobotTemplateHistories;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ namespace PARR.DAL.Services.Implementations
|
||||
.ThenInclude(t => t!.ResponseArea)
|
||||
.Include(h => h.Host)
|
||||
.ThenInclude(t => t!.EkStatus)
|
||||
.Include(r => r.RobotStatus)
|
||||
.Include(a => a.ApplicationsInWork)
|
||||
.ThenInclude(w => w!.Work)
|
||||
.ThenInclude(t => t!.Tnk)
|
||||
@@ -43,65 +42,6 @@ namespace PARR.DAL.Services.Implementations
|
||||
.ThenInclude(p => p!.Process);
|
||||
}
|
||||
|
||||
//TODO: удалить этот метод
|
||||
#region delete
|
||||
public async Task CheckAndSetErrorRobotStatusAsync(int robotAttemptsNumber, TimeSpan robotWaitTime)
|
||||
{
|
||||
//Ищем `RobotStatusCode` = 22 и `RobotLastStatusUpdated` истекло и `RobotAttemptsNumber` >= допустимого значения из настроек,
|
||||
//ставим всем этим записям `RobotStatusCode`= 33
|
||||
|
||||
var endDate = DateTimeOffset.UtcNow.Add(-robotWaitTime);
|
||||
|
||||
var templates = await EntitySet.Where(t =>
|
||||
t.RobotStatusCode == (int)RobotStatusEnum.InProgress
|
||||
&& t.RobotAttemptsNumber >= robotAttemptsNumber
|
||||
&& t.RobotLastStatusUpdated <= endDate
|
||||
)
|
||||
.ToListAsync();
|
||||
|
||||
if (!templates.Any())
|
||||
return;
|
||||
|
||||
foreach (var template in templates)
|
||||
{
|
||||
template.RobotStatusCode = (int)RobotStatusEnum.Error;
|
||||
template.DateModified = DateTimeOffset.UtcNow;
|
||||
logger.LogInformation($"Устанавливаю RobotStatus: {RobotStatusEnum.Error} для шаблона {template.Name}");
|
||||
}
|
||||
|
||||
|
||||
var result = await CommitAsync();
|
||||
|
||||
if (!result)
|
||||
logger.LogError($"Ошибка при сохранении изменений RobotStatus у шаблонов на {RobotStatusEnum.Error}");
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void ChangeRobotStatus(RobotStatusEnum status, ref Template template)
|
||||
{
|
||||
template.RobotStatusCode = (int)status;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case RobotStatusEnum.InProgress:
|
||||
template.RobotAttemptsNumber++;
|
||||
template.RobotLastStatusUpdated = DateTimeOffset.UtcNow;
|
||||
break;
|
||||
//case RobotStatusEnum.Error:
|
||||
// break;
|
||||
case RobotStatusEnum.Complete:
|
||||
template.RobotLastStatusUpdated = DateTimeOffset.UtcNow;
|
||||
break;
|
||||
case RobotStatusEnum.Wait:
|
||||
template.RobotLastStatusUpdated = null;
|
||||
template.RobotAttemptsNumber = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override Task<bool> CreateAsync(Template obj)
|
||||
{
|
||||
// добавление роботов для шаблона
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IRobotTemplateHistoryService : IBaseService<RobotTemplateHistory>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,6 @@ namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface ITemplateService : IBaseService<Template>
|
||||
{
|
||||
/// <summary>
|
||||
/// Изменение статуса отработки робота (без коммита)
|
||||
/// </summary>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="template"></param>
|
||||
void ChangeRobotStatus(RobotStatusEnum status, ref Template template);
|
||||
|
||||
/// <summary>
|
||||
/// Поиск шаблонов с просроченным временем выполнения роботом и превышенным кол-вом попыток. Установка им ошибочного статуса
|
||||
/// </summary>
|
||||
/// <param name="robotAttemptsNumber">Максимальное кол-во ошибок</param>
|
||||
/// <param name="robotWaitTime">Максимальное время выполнения</param>
|
||||
/// <returns></returns>
|
||||
Task CheckAndSetErrorRobotStatusAsync(int robotAttemptsNumber, TimeSpan robotWaitTime);
|
||||
|
||||
Task<Template?> GetTemplateByNameAsync(string name);
|
||||
|
||||
IQueryable<Template> GetWithIncludes();
|
||||
|
||||
@@ -5,6 +5,7 @@ using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.EsppTemplateSync.Domain;
|
||||
using PARR.EsppTemplateSync.MappingProfiles;
|
||||
using PARR.EsppTemplateSync.Settings;
|
||||
|
||||
namespace PARR.EsppTemplateSync.Services
|
||||
@@ -126,8 +127,10 @@ namespace PARR.EsppTemplateSync.Services
|
||||
|
||||
private void SetUpdateStatus(ITemplateService templateService, Template template)
|
||||
{
|
||||
template.StatusCode = (int)TaskStatusEnum.Updating;
|
||||
templateService.ChangeRobotStatus(RobotStatusEnum.Wait, ref template);
|
||||
//TODO: ChangeRobotStatus
|
||||
//template.StatusCode = (int)TaskStatusEnum.Updating;
|
||||
//templateService.ChangeRobotStatus(RobotStatusEnum.Wait, ref template);
|
||||
throw new NotImplementedException("ChangeRobotStatus");
|
||||
}
|
||||
|
||||
private bool IsChanged(EsppTemplate template, EsppTemplate esppTemplate)
|
||||
|
||||
@@ -89,12 +89,8 @@ namespace PARR.GeneratorTemplates.Services
|
||||
Name = TemplateHelpers.GenerateTemplateName(settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name),
|
||||
IsActiveTemplate = true,
|
||||
IsActiveSchedule = true,
|
||||
StatusCode = (int)TaskStatusEnum.Creating,
|
||||
ApplicationInWorkId = appInWork.Id,
|
||||
HostId = host.Id,
|
||||
RobotAttemptsNumber = 0,
|
||||
RobotLastStatusUpdated = null,
|
||||
RobotStatusCode = (int)RobotStatusEnum.Wait
|
||||
HostId = host.Id
|
||||
};
|
||||
|
||||
if (!await templateService.CreateAsync(template) || !await templateService.CommitAsync())
|
||||
@@ -104,7 +100,7 @@ namespace PARR.GeneratorTemplates.Services
|
||||
else
|
||||
{
|
||||
logger.LogInformation($"Создан шаблон: Name: {template.Name}, ApplicationInWorkId: {template.ApplicationInWorkId}, " +
|
||||
$"HostId: {template.HostId}, IsActive: {template.IsActiveTemplate}, StatusCode: {template.StatusCode}");
|
||||
$"HostId: {template.HostId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user