feat(espptemplatesync): метод обновление статуса Manager адаптирован на работу с RobotConfigurationService
This commit is contained in:
@@ -25,7 +25,9 @@ namespace PARR.DAL.Services.Implementations
|
||||
|
||||
public async Task<Template?> GetTemplateByNameAsync(string name)
|
||||
{
|
||||
return await GetWithIncludes().FirstOrDefaultAsync(t => t.Name == name);
|
||||
return await GetWithIncludes()
|
||||
.Include(t=>t.RobotConfigurations)
|
||||
.FirstOrDefaultAsync(t => t.Name == name);
|
||||
}
|
||||
|
||||
public IQueryable<Template> GetWithIncludes()
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PARR.EsppTemplateSync.Domain
|
||||
namespace PARR.EsppTemplateSync.Domain
|
||||
{
|
||||
internal class EsppTemplate
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ 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
|
||||
@@ -17,13 +16,15 @@ namespace PARR.EsppTemplateSync.Services
|
||||
private readonly IParserService parserService;
|
||||
private readonly GlobalSettings globalSettings;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IRobotConfigurationService robotConfigurationService;
|
||||
|
||||
public Manager(
|
||||
ILogger<Manager> logger,
|
||||
IServiceProvider serviceProvider,
|
||||
IParserService parserService,
|
||||
GlobalSettings globalSettings,
|
||||
IMapper mapper
|
||||
IMapper mapper,
|
||||
IRobotConfigurationService robotConfigurationService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
@@ -31,6 +32,7 @@ namespace PARR.EsppTemplateSync.Services
|
||||
this.parserService = parserService;
|
||||
this.globalSettings = globalSettings;
|
||||
this.mapper = mapper;
|
||||
this.robotConfigurationService = robotConfigurationService;
|
||||
}
|
||||
|
||||
public Task<bool> ManageFileAsync(string path)
|
||||
@@ -110,7 +112,7 @@ namespace PARR.EsppTemplateSync.Services
|
||||
|
||||
if (isChanged)
|
||||
{
|
||||
SetUpdateStatus(templateService, template);
|
||||
SetUpdateStatus(template);
|
||||
|
||||
if (!await templateService.CommitAsync())
|
||||
{
|
||||
@@ -125,12 +127,10 @@ namespace PARR.EsppTemplateSync.Services
|
||||
return;
|
||||
}
|
||||
|
||||
private void SetUpdateStatus(ITemplateService templateService, Template template)
|
||||
private void SetUpdateStatus(Template template)
|
||||
{
|
||||
//TODO: ChangeRobotStatus
|
||||
//template.StatusCode = (int)TaskStatusEnum.Updating;
|
||||
//templateService.ChangeRobotStatus(RobotStatusEnum.Wait, ref template);
|
||||
throw new NotImplementedException("ChangeRobotStatus");
|
||||
var robotConfig = robotConfigurationService.GetFromTemplateByRobotCode(RobotsEnum.TemplateOrder, ref template);
|
||||
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, ref robotConfig);
|
||||
}
|
||||
|
||||
private bool IsChanged(EsppTemplate template, EsppTemplate esppTemplate)
|
||||
|
||||
@@ -117,4 +117,54 @@ namespace PARR.EsppTemplateSync.Services
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// dll
|
||||
|
||||
//public delegate Dt CustomParserHandlerDelegate<Dt>(string str);
|
||||
|
||||
//public class Converter
|
||||
//{
|
||||
// public T ParseString<T>(string str, CustomParserHandlerDelegate<T> customParser)
|
||||
// {
|
||||
// var obj = customParser(str);
|
||||
|
||||
// return obj;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public class RunConverter
|
||||
//{
|
||||
// public void Run<T>(CustomParserHandlerDelegate<T> customParser)
|
||||
// {
|
||||
// var conv = new Converter();
|
||||
// //var obj = conv.ParseString("sdfsdfsdf", SuperParser);
|
||||
// var obj = conv.ParseString("sdfsdfsdf", customParser);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
////---
|
||||
//public class Xxx
|
||||
//{
|
||||
// void Test()
|
||||
// {
|
||||
// var rc = new RunConverter();
|
||||
// rc.Run(SuperParser);
|
||||
// }
|
||||
|
||||
|
||||
// Model1 SuperParser(string str)
|
||||
// {
|
||||
// // custom logic
|
||||
|
||||
// return new Model1 { Field = str };
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//public class Model1
|
||||
//{
|
||||
// public string Field { get; set; } = "111";
|
||||
//}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user