Files
parr_api/PARR.TemplateDistributor/TemplateDistributor.cs
2026-01-21 16:28:17 +10:00

43 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.BLL.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.Models;
using PARR.DAL.NextRunServices;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.TransformServices;
using System.Reflection.Metadata.Ecma335;
namespace PARR.TemplateDistributor
{
internal class TemplateDistributor : ITemplateDistributor
{
private readonly ILogger<TemplateDistributor> logger;
private readonly INextRunService nextRunService;
public TemplateDistributor(
ILogger<TemplateDistributor> logger,
INextRunService nextRunService
)
{
this.logger = logger;
this.nextRunService = nextRunService;
}
public async Task DistributeAsync(Guid jobGroupId)
{
// вызвать метод распределения, и получить новые даты
var distributedTemplates = await nextRunService.GetNextRunForJobGroupWithAutoDistributionAsync(jobGroupId);
if (distributedTemplates == null)
{
logger.LogWarning("При распределении шаблонов по jobGroupId {jobGroupId} вернулся null. Это ошибка. Прекращаю распределение.", jobGroupId);
return;
}
// получить список шаблонов, сравнить их с распределенными, обновить даты, сохранить
}
}
}