feat(templateDistributor): заготовка
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Models.Job;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
|
||||
namespace PARR.TemplateDistributor.Services
|
||||
{
|
||||
@@ -17,32 +19,30 @@ namespace PARR.TemplateDistributor.Services
|
||||
this.serviceProvider = serviceProvider;
|
||||
this.logger = logger;
|
||||
}
|
||||
public async Task<bool> IsValidApplicationAndWorksAsync(Guid applicationInWorkId)
|
||||
public async Task<bool> IsValidJobGroupAsync(Guid jobGroupId)
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
//TODO Migratin to Job
|
||||
//var service = scope.ServiceProvider.GetService<IApplicationsInWorkService>();
|
||||
|
||||
//if (service == null)
|
||||
// throw new Exception($"Не найден сервис: {nameof(IApplicationsInWorkService)}");
|
||||
var service = scope.ServiceProvider.GetService<IJobGroupService>();
|
||||
|
||||
//var appInWork = await service.Get()//TODO Migratin to Job
|
||||
// //.Include(aiw => aiw.EsppSchValues)
|
||||
// .FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
|
||||
if (service == null)
|
||||
throw new Exception($"Не найден сервис: {nameof(IJobGroupService)}");
|
||||
|
||||
//if (appInWork == null)
|
||||
//{
|
||||
// logger.LogError($"Не найдена регалментная работа {nameof(applicationInWorkId)}: {applicationInWorkId}");
|
||||
// return false;
|
||||
//}
|
||||
var jobGroup = await service.Get().Include(t => t.DistributionConfig).FirstOrDefaultAsync(t => t.Id == jobGroupId);
|
||||
|
||||
//if (appInWork.IsAutoDistributionEnabled && appInWork.EsppSchValues.Count !=1)
|
||||
//{
|
||||
// logger.LogError($"Регалментная работа {nameof(applicationInWorkId)}: {applicationInWorkId} должна иметь только одно значение EsppSchTypeValue" +
|
||||
// $", соответствующее режиму равномерного распределения по периоду");
|
||||
// return false;
|
||||
//}
|
||||
if (jobGroup == null)
|
||||
{
|
||||
logger.LogError($"Не найдена группа работ с Id: {jobGroupId}", jobGroupId);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!jobGroup.IsAutoDistributionEnabled || jobGroup.DistributionConfig == null)
|
||||
{
|
||||
logger.LogError("Для группы работ {jobGroupId} отсутствуют настройки автораспределения. " +
|
||||
"IsAutoDistributionEnabled: {IsAutoDistributionEnabled}, есть настройки в таблице {DistributionConfig}, {existConfig}", jobGroupId, jobGroup.IsAutoDistributionEnabled, nameof(JobGroupDistributionConfig), jobGroup.DistributionConfig != null);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user