Refactor ChannelEndpoints and ScheduleGenerator: consolidate endpoint logic into partial files, remove unused methods, and enhance dependency injection for scheduling. Update ChannelDetail component to streamline imports and improve UI structure.
This commit is contained in:
@@ -0,0 +1,343 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Broadcast;
|
||||
using TeleWave.Application.Broadcast.Bumpers;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
using TeleWave.Infrastructure.Media;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
/// <summary>Эндпоинты ТВ-заставок канала: блоки (стиль/аудио/фон), подблоки и рендер превью.</summary>
|
||||
public static partial class ChannelEndpoints
|
||||
{
|
||||
private static readonly Regex BumperSegmentFileName = new(
|
||||
@"^seg\d{1,6}\.ts$",
|
||||
RegexOptions.Compiled
|
||||
);
|
||||
|
||||
private static async Task<IResult> AddBumperTemplate(
|
||||
Guid id,
|
||||
AddBumperTemplateBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddBumperTemplateCommand(id, body.Name),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateBumperTemplate(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
UpdateBumperTemplateBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateBumperTemplateCommand(
|
||||
id,
|
||||
templateId,
|
||||
body.Name,
|
||||
body.BackgroundColor,
|
||||
body.BackgroundColor2,
|
||||
body.AccentColor,
|
||||
body.TextColor
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveBumperTemplate(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveBumperTemplateCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UploadTemplateAudio(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
string fileName,
|
||||
HttpRequest request,
|
||||
IBumperTemplateStorage storage,
|
||||
IAudioProbe probe,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
if (ResolveBumperExtension(fileName, request, BumperFiles.AudioExtensions) is not { } ext)
|
||||
return ChannelErrors.InvalidBumperFile.ToProblem();
|
||||
|
||||
await storage.SaveAudioAsync(templateId, ext, request.Body, cancellationToken);
|
||||
|
||||
// Длина заставки идёт по длине звука — замеряем ffprobe (при неудаче 0 → дефолтная длина).
|
||||
var path = storage.AudioPath(templateId, ext);
|
||||
var duration = path is null
|
||||
? null
|
||||
: await probe.TryGetDurationAsync(path, cancellationToken);
|
||||
|
||||
var result = await sender.Send(
|
||||
new SetBumperTemplateAudioCommand(id, templateId, ext, duration?.TotalSeconds ?? 0),
|
||||
cancellationToken
|
||||
);
|
||||
if (!result.IsSuccess)
|
||||
storage.DeleteAudio(templateId);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ClearTemplateAudio(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new ClearBumperTemplateAudioCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> SetTemplateBackground(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
SetBumperTemplateBackgroundBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new SetBumperTemplateBackgroundCommand(id, templateId, body.ImageId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ClearTemplateBackground(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new ClearBumperTemplateBackgroundCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
AddBumperVariantBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddBumperTextVariantCommand(id, templateId, body.Name),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
UpdateBumperVariantBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateBumperTextVariantCommand(
|
||||
id,
|
||||
templateId,
|
||||
variantId,
|
||||
body.Name,
|
||||
body.Kind,
|
||||
body.NowLabel,
|
||||
body.NextLabel,
|
||||
body.Line1,
|
||||
body.Line2,
|
||||
body.Trigger,
|
||||
body.Weight
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveBumperTextVariantCommand(id, templateId, variantId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
/// <summary>Синхронно рендерит пример заставки блока (несколько секунд ffmpeg).</summary>
|
||||
private static async Task<IResult> RenderPreview(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RenderBumperPreviewQuery(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess ? Results.NoContent() : result.ToHttpResult();
|
||||
}
|
||||
|
||||
/// <summary>Плейлист превью подблока: переписываем ffmpeg-index.m3u8, направляя сегменты на admin-роут.</summary>
|
||||
private static IResult PreviewPlaylist(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
MediaPathResolver paths
|
||||
)
|
||||
{
|
||||
var previewId = BumperPreview.AssetId(variantId);
|
||||
string indexPath;
|
||||
try
|
||||
{
|
||||
indexPath = paths.SegmentPath(previewId, "index.m3u8");
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
if (!File.Exists(indexPath))
|
||||
return Results.NotFound();
|
||||
|
||||
var baseUrl =
|
||||
$"/api/admin/channels/{id}/bumper/templates/{templateId}/preview/{variantId}/";
|
||||
var sb = new StringBuilder();
|
||||
foreach (var line in File.ReadLines(indexPath))
|
||||
{
|
||||
var trimmed = line.Trim();
|
||||
if (trimmed.Length == 0)
|
||||
continue;
|
||||
// Комментарии/директивы — как есть; строки-сегменты (абсолютный путь от ffmpeg) → admin-URL.
|
||||
sb.Append(trimmed.StartsWith('#') ? trimmed : baseUrl + Path.GetFileName(trimmed))
|
||||
.Append('\n');
|
||||
}
|
||||
|
||||
return Results.Text(sb.ToString(), "application/vnd.apple.mpegurl");
|
||||
}
|
||||
|
||||
private static IResult PreviewSegment(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
string file,
|
||||
MediaPathResolver paths
|
||||
)
|
||||
{
|
||||
if (!BumperSegmentFileName.IsMatch(file))
|
||||
return Results.NotFound();
|
||||
|
||||
var previewId = BumperPreview.AssetId(variantId);
|
||||
string path;
|
||||
try
|
||||
{
|
||||
path = paths.SegmentPath(previewId, file);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
if (!File.Exists(path))
|
||||
return Results.NotFound();
|
||||
|
||||
return Results.File(path, "video/mp2t", enableRangeProcessing: true);
|
||||
}
|
||||
|
||||
/// <summary>Проверяет расширение файла (по allowlist) и размер (Content-Length). Возвращает
|
||||
/// нормализованное расширение (с точкой, нижний регистр) или null при отказе.</summary>
|
||||
private static string? ResolveBumperExtension(
|
||||
string fileName,
|
||||
HttpRequest request,
|
||||
IReadOnlySet<string> allowedExtensions
|
||||
)
|
||||
{
|
||||
if (request.ContentLength is > BumperFiles.MaxBytes or 0 or null)
|
||||
return null;
|
||||
var ext = Path.GetExtension(fileName).ToLowerInvariant();
|
||||
return allowedExtensions.Contains(ext) ? ext : null;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record AddBumperTemplateBody(string Name);
|
||||
|
||||
public sealed record UpdateBumperTemplateBody(
|
||||
string Name,
|
||||
string BackgroundColor,
|
||||
string BackgroundColor2,
|
||||
string AccentColor,
|
||||
string TextColor
|
||||
);
|
||||
|
||||
public sealed record SetBumperTemplateBackgroundBody(Guid ImageId);
|
||||
|
||||
public sealed record AddBumperVariantBody(string Name);
|
||||
|
||||
public sealed record UpdateBumperVariantBody(
|
||||
string Name,
|
||||
BumperTextKind Kind,
|
||||
string NowLabel,
|
||||
string NextLabel,
|
||||
string Line1,
|
||||
string Line2,
|
||||
BumperTrigger Trigger,
|
||||
int Weight
|
||||
);
|
||||
|
||||
/// <summary>Ограничения на загружаемый звук блока заставки (фон-картинка — через общий реестр).</summary>
|
||||
internal static class BumperFiles
|
||||
{
|
||||
public const long MaxBytes = 200L * 1024 * 1024; // 200 МБ
|
||||
|
||||
public static readonly IReadOnlySet<string> AudioExtensions = new HashSet<string>(
|
||||
StringComparer.OrdinalIgnoreCase
|
||||
)
|
||||
{
|
||||
".mp3",
|
||||
".m4a",
|
||||
".aac",
|
||||
".ogg",
|
||||
".opus",
|
||||
".wav",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Broadcast.CreateOverride;
|
||||
using TeleWave.Application.Broadcast.DeleteOverride;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
/// <summary>Эндпоинты временных override'ов / марафонов канала (разовые и еженедельные).</summary>
|
||||
public static partial class ChannelEndpoints
|
||||
{
|
||||
private static async Task<IResult> CreateOverride(
|
||||
Guid id,
|
||||
CreateOverrideBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new CreateProgrammingOverrideCommand(
|
||||
id,
|
||||
body.Mode,
|
||||
body.Recurrence,
|
||||
body.StartsAtUtc,
|
||||
body.EndsAtUtc,
|
||||
body.DayOfWeek,
|
||||
body.StartMinute,
|
||||
body.EndMinute,
|
||||
body.Shows
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> DeleteOverride(
|
||||
Guid id,
|
||||
Guid overrideId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new DeleteProgrammingOverrideCommand(id, overrideId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record CreateOverrideBody(
|
||||
OverrideMode Mode,
|
||||
OverrideRecurrence Recurrence,
|
||||
DateTimeOffset? StartsAtUtc,
|
||||
DateTimeOffset? EndsAtUtc,
|
||||
int? DayOfWeek,
|
||||
int? StartMinute,
|
||||
int? EndMinute,
|
||||
IReadOnlyList<OverrideShowInput> Shows
|
||||
);
|
||||
@@ -0,0 +1,122 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Broadcast.AddChannelAd;
|
||||
using TeleWave.Application.Broadcast.AddChannelShow;
|
||||
using TeleWave.Application.Broadcast.RemoveChannelAd;
|
||||
using TeleWave.Application.Broadcast.RemoveChannelShow;
|
||||
using TeleWave.Application.Broadcast.UpdateChannelShow;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
/// <summary>Эндпоинты канала: шоу в ротации и рекламный пул.</summary>
|
||||
public static partial class ChannelEndpoints
|
||||
{
|
||||
private static async Task<IResult> AddShow(
|
||||
Guid id,
|
||||
AddChannelShowBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddChannelShowCommand(
|
||||
id,
|
||||
body.ShowId,
|
||||
body.Weight,
|
||||
body.BlockMode,
|
||||
body.BlockValue
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateShow(
|
||||
Guid id,
|
||||
Guid channelShowId,
|
||||
UpdateChannelShowBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateChannelShowCommand(
|
||||
id,
|
||||
channelShowId,
|
||||
body.Weight,
|
||||
body.BlockMode,
|
||||
body.BlockValue,
|
||||
body.IsEnabled,
|
||||
body.PreferredWeightMultiplier,
|
||||
body.PreferredHours ?? []
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveShow(
|
||||
Guid id,
|
||||
Guid channelShowId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveChannelShowCommand(id, channelShowId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddAd(
|
||||
Guid id,
|
||||
AddChannelAdBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddChannelAdCommand(id, body.MediaAssetId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveAd(
|
||||
Guid id,
|
||||
Guid channelAdId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveChannelAdCommand(id, channelAdId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record AddChannelShowBody(
|
||||
Guid ShowId,
|
||||
int Weight,
|
||||
BlockMode BlockMode,
|
||||
int BlockValue
|
||||
);
|
||||
|
||||
public sealed record UpdateChannelShowBody(
|
||||
int Weight,
|
||||
BlockMode BlockMode,
|
||||
int BlockValue,
|
||||
bool IsEnabled,
|
||||
int PreferredWeightMultiplier,
|
||||
IReadOnlyList<HourWindowInput> PreferredHours
|
||||
);
|
||||
|
||||
public sealed record AddChannelAdBody(Guid MediaAssetId);
|
||||
@@ -1,36 +1,25 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using LiteCqrs;
|
||||
using TeleWave.Api.Common;
|
||||
using TeleWave.Application.Broadcast;
|
||||
using TeleWave.Application.Broadcast.AddChannelAd;
|
||||
using TeleWave.Application.Broadcast.AddChannelShow;
|
||||
using TeleWave.Application.Broadcast.Bumpers;
|
||||
using TeleWave.Application.Broadcast.CreateChannel;
|
||||
using TeleWave.Application.Broadcast.CreateOverride;
|
||||
using TeleWave.Application.Broadcast.DeleteOverride;
|
||||
using TeleWave.Application.Broadcast.GetChannel;
|
||||
using TeleWave.Application.Broadcast.GetSchedule;
|
||||
using TeleWave.Application.Broadcast.ListChannels;
|
||||
using TeleWave.Application.Broadcast.RegenerateSchedule;
|
||||
using TeleWave.Application.Broadcast.RemoveChannelAd;
|
||||
using TeleWave.Application.Broadcast.RemoveChannelShow;
|
||||
using TeleWave.Application.Broadcast.UpdateChannelSettings;
|
||||
using TeleWave.Application.Broadcast.UpdateChannelShow;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
using TeleWave.Infrastructure.Media;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
|
||||
public static class ChannelEndpoints
|
||||
/// <summary>
|
||||
/// Админ-эндпоинты канала. Реализация разнесена по partial-файлам под-ресурсов:
|
||||
/// <c>ChannelEndpoints.Shows.cs</c> (шоу+реклама), <c>ChannelEndpoints.Bumpers.cs</c>
|
||||
/// (блоки/подблоки/файлы/preview), <c>ChannelEndpoints.Overrides.cs</c> (override'ы). Здесь —
|
||||
/// регистрация всех маршрутов и хендлеры уровня канала (создание/список/настройки/расписание).
|
||||
/// </summary>
|
||||
public static partial class ChannelEndpoints
|
||||
{
|
||||
private static readonly Regex BumperSegmentFileName = new(
|
||||
@"^seg\d{1,6}\.ts$",
|
||||
RegexOptions.Compiled
|
||||
);
|
||||
|
||||
public static IEndpointRouteBuilder MapChannelEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var admin = app.MapGroup("/api/admin/channels")
|
||||
@@ -189,416 +178,6 @@ public static class ChannelEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddShow(
|
||||
Guid id,
|
||||
AddChannelShowBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddChannelShowCommand(
|
||||
id,
|
||||
body.ShowId,
|
||||
body.Weight,
|
||||
body.BlockMode,
|
||||
body.BlockValue
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateShow(
|
||||
Guid id,
|
||||
Guid channelShowId,
|
||||
UpdateChannelShowBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateChannelShowCommand(
|
||||
id,
|
||||
channelShowId,
|
||||
body.Weight,
|
||||
body.BlockMode,
|
||||
body.BlockValue,
|
||||
body.IsEnabled,
|
||||
body.PreferredWeightMultiplier,
|
||||
body.PreferredHours ?? []
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveShow(
|
||||
Guid id,
|
||||
Guid channelShowId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveChannelShowCommand(id, channelShowId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddAd(
|
||||
Guid id,
|
||||
AddChannelAdBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddChannelAdCommand(id, body.MediaAssetId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveAd(
|
||||
Guid id,
|
||||
Guid channelAdId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveChannelAdCommand(id, channelAdId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddBumperTemplate(
|
||||
Guid id,
|
||||
AddBumperTemplateBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddBumperTemplateCommand(id, body.Name),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateBumperTemplate(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
UpdateBumperTemplateBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateBumperTemplateCommand(
|
||||
id,
|
||||
templateId,
|
||||
body.Name,
|
||||
body.BackgroundColor,
|
||||
body.BackgroundColor2,
|
||||
body.AccentColor,
|
||||
body.TextColor
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveBumperTemplate(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveBumperTemplateCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UploadTemplateAudio(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
string fileName,
|
||||
HttpRequest request,
|
||||
IBumperTemplateStorage storage,
|
||||
IAudioProbe probe,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
if (ResolveBumperExtension(fileName, request, BumperFiles.AudioExtensions) is not { } ext)
|
||||
return ChannelErrors.InvalidBumperFile.ToProblem();
|
||||
|
||||
await storage.SaveAudioAsync(templateId, ext, request.Body, cancellationToken);
|
||||
|
||||
// Длина заставки идёт по длине звука — замеряем ffprobe (при неудаче 0 → дефолтная длина).
|
||||
var path = storage.AudioPath(templateId, ext);
|
||||
var duration = path is null
|
||||
? null
|
||||
: await probe.TryGetDurationAsync(path, cancellationToken);
|
||||
|
||||
var result = await sender.Send(
|
||||
new SetBumperTemplateAudioCommand(id, templateId, ext, duration?.TotalSeconds ?? 0),
|
||||
cancellationToken
|
||||
);
|
||||
if (!result.IsSuccess)
|
||||
storage.DeleteAudio(templateId);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ClearTemplateAudio(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new ClearBumperTemplateAudioCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> SetTemplateBackground(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
SetBumperTemplateBackgroundBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new SetBumperTemplateBackgroundCommand(id, templateId, body.ImageId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> AddBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
AddBumperVariantBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new AddBumperTextVariantCommand(id, templateId, body.Name),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdateBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
UpdateBumperVariantBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateBumperTextVariantCommand(
|
||||
id,
|
||||
templateId,
|
||||
variantId,
|
||||
body.Name,
|
||||
body.Kind,
|
||||
body.NowLabel,
|
||||
body.NextLabel,
|
||||
body.Line1,
|
||||
body.Line2,
|
||||
body.Trigger,
|
||||
body.Weight
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RemoveBumperVariant(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RemoveBumperTextVariantCommand(id, templateId, variantId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ClearTemplateBackground(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new ClearBumperTemplateBackgroundCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
/// <summary>Синхронно рендерит пример заставки блока (несколько секунд ffmpeg).</summary>
|
||||
private static async Task<IResult> RenderPreview(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RenderBumperPreviewQuery(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess ? Results.NoContent() : result.ToHttpResult();
|
||||
}
|
||||
|
||||
/// <summary>Плейлист превью подблока: переписываем ffmpeg-index.m3u8, направляя сегменты на admin-роут.</summary>
|
||||
private static IResult PreviewPlaylist(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
MediaPathResolver paths
|
||||
)
|
||||
{
|
||||
var previewId = BumperPreview.AssetId(variantId);
|
||||
string indexPath;
|
||||
try
|
||||
{
|
||||
indexPath = paths.SegmentPath(previewId, "index.m3u8");
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
if (!File.Exists(indexPath))
|
||||
return Results.NotFound();
|
||||
|
||||
var baseUrl =
|
||||
$"/api/admin/channels/{id}/bumper/templates/{templateId}/preview/{variantId}/";
|
||||
var sb = new StringBuilder();
|
||||
foreach (var line in File.ReadLines(indexPath))
|
||||
{
|
||||
var trimmed = line.Trim();
|
||||
if (trimmed.Length == 0)
|
||||
continue;
|
||||
// Комментарии/директивы — как есть; строки-сегменты (абсолютный путь от ffmpeg) → admin-URL.
|
||||
sb.Append(trimmed.StartsWith('#') ? trimmed : baseUrl + Path.GetFileName(trimmed))
|
||||
.Append('\n');
|
||||
}
|
||||
|
||||
return Results.Text(sb.ToString(), "application/vnd.apple.mpegurl");
|
||||
}
|
||||
|
||||
private static IResult PreviewSegment(
|
||||
Guid id,
|
||||
Guid templateId,
|
||||
Guid variantId,
|
||||
string file,
|
||||
MediaPathResolver paths
|
||||
)
|
||||
{
|
||||
if (!BumperSegmentFileName.IsMatch(file))
|
||||
return Results.NotFound();
|
||||
|
||||
var previewId = BumperPreview.AssetId(variantId);
|
||||
string path;
|
||||
try
|
||||
{
|
||||
path = paths.SegmentPath(previewId, file);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
if (!File.Exists(path))
|
||||
return Results.NotFound();
|
||||
|
||||
return Results.File(path, "video/mp2t", enableRangeProcessing: true);
|
||||
}
|
||||
|
||||
/// <summary>Проверяет расширение файла (по allowlist) и размер (Content-Length). Возвращает
|
||||
/// нормализованное расширение (с точкой, нижний регистр) или null при отказе.</summary>
|
||||
private static string? ResolveBumperExtension(
|
||||
string fileName,
|
||||
HttpRequest request,
|
||||
IReadOnlySet<string> allowedExtensions
|
||||
)
|
||||
{
|
||||
if (request.ContentLength is > BumperFiles.MaxBytes or 0 or null)
|
||||
return null;
|
||||
var ext = Path.GetExtension(fileName).ToLowerInvariant();
|
||||
return allowedExtensions.Contains(ext) ? ext : null;
|
||||
}
|
||||
|
||||
private static async Task<IResult> CreateOverride(
|
||||
Guid id,
|
||||
CreateOverrideBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new CreateProgrammingOverrideCommand(
|
||||
id,
|
||||
body.Mode,
|
||||
body.Recurrence,
|
||||
body.StartsAtUtc,
|
||||
body.EndsAtUtc,
|
||||
body.DayOfWeek,
|
||||
body.StartMinute,
|
||||
body.EndMinute,
|
||||
body.Shows
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess
|
||||
? Results.Created($"/api/admin/channels/{id}", new CreatedIdResponse(result.Value))
|
||||
: result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> DeleteOverride(
|
||||
Guid id,
|
||||
Guid overrideId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new DeleteProgrammingOverrideCommand(id, overrideId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> Regenerate(
|
||||
Guid id,
|
||||
ISender sender,
|
||||
@@ -636,75 +215,3 @@ public sealed record UpdateChannelSettingsBody(
|
||||
BumperSettingsInput Bumper,
|
||||
Guid? FillerAssetId
|
||||
);
|
||||
|
||||
public sealed record AddChannelShowBody(
|
||||
Guid ShowId,
|
||||
int Weight,
|
||||
BlockMode BlockMode,
|
||||
int BlockValue
|
||||
);
|
||||
|
||||
public sealed record UpdateChannelShowBody(
|
||||
int Weight,
|
||||
BlockMode BlockMode,
|
||||
int BlockValue,
|
||||
bool IsEnabled,
|
||||
int PreferredWeightMultiplier,
|
||||
IReadOnlyList<HourWindowInput> PreferredHours
|
||||
);
|
||||
|
||||
public sealed record AddChannelAdBody(Guid MediaAssetId);
|
||||
|
||||
public sealed record AddBumperTemplateBody(string Name);
|
||||
|
||||
public sealed record SetBumperTemplateBackgroundBody(Guid ImageId);
|
||||
|
||||
public sealed record AddBumperVariantBody(string Name);
|
||||
|
||||
public sealed record UpdateBumperVariantBody(
|
||||
string Name,
|
||||
BumperTextKind Kind,
|
||||
string NowLabel,
|
||||
string NextLabel,
|
||||
string Line1,
|
||||
string Line2,
|
||||
BumperTrigger Trigger,
|
||||
int Weight
|
||||
);
|
||||
|
||||
public sealed record UpdateBumperTemplateBody(
|
||||
string Name,
|
||||
string BackgroundColor,
|
||||
string BackgroundColor2,
|
||||
string AccentColor,
|
||||
string TextColor
|
||||
);
|
||||
|
||||
/// <summary>Ограничения на загружаемый звук блока заставки (фон-картинка — через общий реестр).</summary>
|
||||
internal static class BumperFiles
|
||||
{
|
||||
public const long MaxBytes = 200L * 1024 * 1024; // 200 МБ
|
||||
|
||||
public static readonly IReadOnlySet<string> AudioExtensions = new HashSet<string>(
|
||||
StringComparer.OrdinalIgnoreCase
|
||||
)
|
||||
{
|
||||
".mp3",
|
||||
".m4a",
|
||||
".aac",
|
||||
".ogg",
|
||||
".opus",
|
||||
".wav",
|
||||
};
|
||||
}
|
||||
|
||||
public sealed record CreateOverrideBody(
|
||||
OverrideMode Mode,
|
||||
OverrideRecurrence Recurrence,
|
||||
DateTimeOffset? StartsAtUtc,
|
||||
DateTimeOffset? EndsAtUtc,
|
||||
int? DayOfWeek,
|
||||
int? StartMinute,
|
||||
int? EndMinute,
|
||||
IReadOnlyList<OverrideShowInput> Shows
|
||||
);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using TeleWave.Domain.Broadcast;
|
||||
|
||||
namespace TeleWave.Application.Broadcast.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Длительность заставки блока: по длине загруженного звука (иначе дефолт для синтеза), выровненная
|
||||
/// вверх до кратности длине сегмента — ключевой инвариант эфирной математики. Общая для генератора
|
||||
/// (слоты в плане) и резолвера заставок (рендер).
|
||||
/// </summary>
|
||||
internal static class BumperDuration
|
||||
{
|
||||
/// <summary>Длительность заставки без загруженного звука (сек) — синтезированный джингл.</summary>
|
||||
private const int DefaultSeconds = 8;
|
||||
|
||||
/// <summary>Длина заставки блока (сек): по загруженному звуку либо дефолт для синтеза.</summary>
|
||||
public static double TemplateSeconds(BumperTemplate template) =>
|
||||
template.AudioDurationSeconds is { } d and > 0 ? d : DefaultSeconds;
|
||||
|
||||
/// <summary>Секунды, выровненные вверх до кратности длине сегмента.</summary>
|
||||
public static int Aligned(double seconds, int segmentSeconds)
|
||||
{
|
||||
var requested = Math.Max(segmentSeconds, seconds);
|
||||
return (int)(Math.Ceiling(requested / segmentSeconds) * segmentSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using TeleWave.Application.Broadcast.Bumpers;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Streaming;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
using TeleWave.Domain.Broadcast.Scheduling;
|
||||
using TeleWave.Domain.Media;
|
||||
|
||||
namespace TeleWave.Application.Broadcast.Scheduling;
|
||||
|
||||
/// <summary>
|
||||
/// Резолвит ассеты ТВ-заставок для запланированных переходов: для каждой уникальной тройки
|
||||
/// «из→в→подблок» возвращает id готового ассета — из кэша (<see cref="BumperAsset"/>) либо
|
||||
/// свежесгенерированного ffmpeg-рендером. Работает через тот же scoped <see cref="IAppDbContext"/>,
|
||||
/// что и <see cref="ScheduleGenerator"/>: добавленные ассеты сохраняются его общим SaveChanges.
|
||||
/// </summary>
|
||||
public sealed class ScheduleBumperResolver(
|
||||
IAppDbContext dbContext,
|
||||
IBumperRenderer bumperRenderer,
|
||||
IBumperTemplateStorage bumperStorage,
|
||||
IImageStore imageStore,
|
||||
IOptions<BumperOptions> bumperOptions,
|
||||
IOptions<StreamingOptions> streamingOptions,
|
||||
ILogger<ScheduleBumperResolver> logger
|
||||
)
|
||||
{
|
||||
private readonly BumperOptions _bumper = bumperOptions.Value;
|
||||
private readonly int _segmentSeconds = Math.Max(1, streamingOptions.Value.SegmentSeconds);
|
||||
|
||||
/// <summary>
|
||||
/// Для каждой уникальной тройки «из→в→подблок» из запланированных заставок возвращает id готового
|
||||
/// ассета-заставки: из кэша либо свежесгенерированного.
|
||||
/// </summary>
|
||||
public async Task<Dictionary<(Guid From, Guid To, Guid Variant), Guid>> ResolveAsync(
|
||||
Channel channel,
|
||||
IReadOnlyList<PlannedEntry> entries,
|
||||
IReadOnlyDictionary<Guid, string> showNames,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = new Dictionary<(Guid, Guid, Guid), Guid>();
|
||||
var variantsById = channel
|
||||
.BumperTemplates.SelectMany(t => t.Variants.Select(v => (Variant: v, Template: t)))
|
||||
.ToDictionary(x => x.Variant.Id);
|
||||
var combos = entries
|
||||
.Where(e =>
|
||||
e.Kind == ScheduleEntryKind.Bumper
|
||||
&& e.FromShowId is not null
|
||||
&& e.ToShowId is not null
|
||||
&& e.BumperVariantId is not null
|
||||
)
|
||||
.Select(e =>
|
||||
(
|
||||
From: e.FromShowId!.Value,
|
||||
To: e.ToShowId!.Value,
|
||||
Variant: e.BumperVariantId!.Value
|
||||
)
|
||||
)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
if (combos.Count == 0)
|
||||
return result;
|
||||
|
||||
var fromIds = combos.Select(c => c.From).Distinct().ToList();
|
||||
var toIds = combos.Select(c => c.To).Distinct().ToList();
|
||||
|
||||
// Постеры шоу-получателей (из реестра изображений) — как фон заставки, если у блока нет
|
||||
// своей фон-картинки. Резолвим id постера → расширение → абсолютный путь.
|
||||
var showIds = fromIds.Concat(toIds).Distinct().ToList();
|
||||
var posterShows = await dbContext
|
||||
.Shows.AsNoTracking()
|
||||
.Where(s => showIds.Contains(s.Id) && s.PosterImageId != null)
|
||||
.Select(s => new { s.Id, ImageId = s.PosterImageId!.Value })
|
||||
.ToListAsync(cancellationToken);
|
||||
var posterImageIds = posterShows.Select(p => p.ImageId).Distinct().ToList();
|
||||
var posterExtById = await dbContext
|
||||
.Images.AsNoTracking()
|
||||
.Where(i => posterImageIds.Contains(i.Id))
|
||||
.Select(i => new { i.Id, i.FileExtension })
|
||||
.ToDictionaryAsync(i => i.Id, i => i.FileExtension, cancellationToken);
|
||||
var posterByShow = new Dictionary<Guid, (Guid ImageId, string AbsPath)>();
|
||||
foreach (var p in posterShows)
|
||||
if (
|
||||
posterExtById.TryGetValue(p.ImageId, out var ext)
|
||||
&& imageStore.ResolvePath(p.ImageId, ext) is { } abs
|
||||
)
|
||||
posterByShow[p.Id] = (p.ImageId, abs);
|
||||
|
||||
// Фон-картинки блоков (из реестра) — абсолютные пути по id.
|
||||
var bgImageIds = channel
|
||||
.BumperTemplates.Where(t => t.BackgroundImageId != null)
|
||||
.Select(t => t.BackgroundImageId!.Value)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var bgExtById = await dbContext
|
||||
.Images.AsNoTracking()
|
||||
.Where(i => bgImageIds.Contains(i.Id))
|
||||
.Select(i => new { i.Id, i.FileExtension })
|
||||
.ToDictionaryAsync(i => i.Id, i => i.FileExtension, cancellationToken);
|
||||
var bgByTemplate = new Dictionary<Guid, string>();
|
||||
foreach (var t in channel.BumperTemplates)
|
||||
if (
|
||||
t.BackgroundImageId is { } bgId
|
||||
&& bgExtById.TryGetValue(bgId, out var bgExt)
|
||||
&& imageStore.ResolvePath(bgId, bgExt) is { } bgAbs
|
||||
)
|
||||
bgByTemplate[t.Id] = bgAbs;
|
||||
|
||||
// Кандидаты из кэша + статусы их ассетов (годятся только Ready — файлы могли удалить).
|
||||
var cached = await dbContext
|
||||
.BumperAssets.AsNoTracking()
|
||||
.Where(b => fromIds.Contains(b.FromShowId) && toIds.Contains(b.ToShowId))
|
||||
.Select(b => new
|
||||
{
|
||||
b.FromShowId,
|
||||
b.ToShowId,
|
||||
b.Signature,
|
||||
b.MediaAssetId,
|
||||
})
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var cachedAssetIds = cached.Select(c => c.MediaAssetId).Distinct().ToList();
|
||||
var readyAssetIds = await dbContext
|
||||
.MediaAssets.AsNoTracking()
|
||||
.Where(a => cachedAssetIds.Contains(a.Id) && a.Status == MediaAssetStatus.Ready)
|
||||
.Select(a => a.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var readySet = readyAssetIds.ToHashSet();
|
||||
|
||||
foreach (var combo in combos)
|
||||
{
|
||||
if (!variantsById.TryGetValue(combo.Variant, out var pair))
|
||||
continue;
|
||||
var (variant, template) = pair;
|
||||
|
||||
var fromName = showNames.GetValueOrDefault(combo.From, "…");
|
||||
var toName = showNames.GetValueOrDefault(combo.To, "…");
|
||||
// Постер шоу-получателя как фон — только для «Сейчас/Далее» (свободный текст шоу не упоминает).
|
||||
var usePoster = variant.Kind == BumperTextKind.NowNext;
|
||||
var poster = usePoster && posterByShow.TryGetValue(combo.To, out var pr) ? pr : default;
|
||||
var posterToken = poster.ImageId == Guid.Empty ? "-" : poster.ImageId.ToString();
|
||||
var posterAbs = poster.ImageId == Guid.Empty ? null : poster.AbsPath;
|
||||
var bgAbs = bgByTemplate.GetValueOrDefault(template.Id);
|
||||
var aligned = BumperDuration.Aligned(
|
||||
BumperDuration.TemplateSeconds(template),
|
||||
_segmentSeconds
|
||||
);
|
||||
var signature = ComputeSignature(
|
||||
channel,
|
||||
template,
|
||||
variant,
|
||||
fromName,
|
||||
toName,
|
||||
aligned,
|
||||
posterToken
|
||||
);
|
||||
|
||||
var hit = cached.FirstOrDefault(c =>
|
||||
c.FromShowId == combo.From
|
||||
&& c.ToShowId == combo.To
|
||||
&& c.Signature == signature
|
||||
&& readySet.Contains(c.MediaAssetId)
|
||||
);
|
||||
if (hit is not null)
|
||||
{
|
||||
result[combo] = hit.MediaAssetId;
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var assetId = await RenderAsync(
|
||||
channel,
|
||||
template,
|
||||
variant,
|
||||
combo.From,
|
||||
combo.To,
|
||||
fromName,
|
||||
toName,
|
||||
aligned,
|
||||
signature,
|
||||
posterAbs,
|
||||
bgAbs,
|
||||
cancellationToken
|
||||
);
|
||||
result[combo] = assetId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(
|
||||
ex,
|
||||
"Не удалось отрендерить заставку {From} → {To}",
|
||||
fromName,
|
||||
toName
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<Guid> RenderAsync(
|
||||
Channel channel,
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
Guid fromShowId,
|
||||
Guid toShowId,
|
||||
string fromName,
|
||||
string toName,
|
||||
int alignedDurationSeconds,
|
||||
string signature,
|
||||
string? posterAbsolutePath,
|
||||
string? backgroundAbsolutePath,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var asset = MediaAsset.RegisterGenerated($"Заставка: {fromName} → {toName}");
|
||||
var render = await bumperRenderer.RenderAsync(
|
||||
asset.Id,
|
||||
BuildSpec(
|
||||
channel,
|
||||
template,
|
||||
variant,
|
||||
alignedDurationSeconds,
|
||||
fromName,
|
||||
toName,
|
||||
posterAbsolutePath,
|
||||
backgroundAbsolutePath
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
asset.MarkReady(
|
||||
render.Duration,
|
||||
render.SegmentSeconds,
|
||||
render.SegmentCount,
|
||||
render.Width,
|
||||
render.Height,
|
||||
"h264",
|
||||
"aac",
|
||||
render.RelativePath
|
||||
);
|
||||
|
||||
dbContext.MediaAssets.Add(asset);
|
||||
dbContext.BumperAssets.Add(BumperAsset.Create(fromShowId, toShowId, signature, asset.Id));
|
||||
return asset.Id;
|
||||
}
|
||||
|
||||
private BumperRenderSpec BuildSpec(
|
||||
Channel channel,
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
int alignedDurationSeconds,
|
||||
string fromName,
|
||||
string toName,
|
||||
string? posterAbsolutePath,
|
||||
string? backgroundAbsolutePath
|
||||
)
|
||||
{
|
||||
var free = variant.Kind == BumperTextKind.Free;
|
||||
return new BumperRenderSpec(
|
||||
alignedDurationSeconds,
|
||||
_bumper.Width,
|
||||
_bumper.Height,
|
||||
template.BackgroundColor,
|
||||
template.BackgroundColor2,
|
||||
template.AccentColor,
|
||||
template.TextColor,
|
||||
FontPath(channel.BumperFont),
|
||||
free ? "" : variant.NowLabel,
|
||||
free ? "" : fromName,
|
||||
free ? "" : variant.NextLabel,
|
||||
free ? "" : toName,
|
||||
backgroundAbsolutePath,
|
||||
bumperStorage.AudioPath(template.Id, template.AudioExtension),
|
||||
posterAbsolutePath,
|
||||
free,
|
||||
variant.Line1,
|
||||
variant.Line2
|
||||
);
|
||||
}
|
||||
|
||||
private string FontPath(BumperFont font) =>
|
||||
font == BumperFont.Serif ? _bumper.FontFileSerif : _bumper.FontFileSans;
|
||||
|
||||
/// <summary>
|
||||
/// Сигнатура рендера = хэш всех входов заставки: общие настройки канала (шрифт/подписи/версия
|
||||
/// шаблона), оформление и файлы блока (цвета/фон/звук/ревизия), названия шоу и постер. Меняется —
|
||||
/// заставка пересобирается. Разделитель — unit separator (U+001F), чтобы поля не слипались.
|
||||
/// </summary>
|
||||
private string ComputeSignature(
|
||||
Channel channel,
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
string fromName,
|
||||
string toName,
|
||||
int alignedDurationSeconds,
|
||||
string poster
|
||||
)
|
||||
{
|
||||
var raw = string.Join(
|
||||
'',
|
||||
_bumper.TemplateVersion,
|
||||
_bumper.Width,
|
||||
_bumper.Height,
|
||||
alignedDurationSeconds,
|
||||
channel.BumperFont,
|
||||
variant.Kind,
|
||||
variant.NowLabel,
|
||||
variant.NextLabel,
|
||||
variant.Line1,
|
||||
variant.Line2,
|
||||
template.BackgroundColor,
|
||||
template.BackgroundColor2,
|
||||
template.AccentColor,
|
||||
template.TextColor,
|
||||
template.Revision,
|
||||
template.BackgroundImageId?.ToString() ?? "-",
|
||||
template.AudioExtension ?? "-",
|
||||
fromName,
|
||||
toName,
|
||||
poster
|
||||
);
|
||||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(raw));
|
||||
return Convert.ToHexString(hash);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using TeleWave.Application.Broadcast.Bumpers;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Streaming;
|
||||
using TeleWave.Domain.Broadcast;
|
||||
@@ -16,28 +12,19 @@ namespace TeleWave.Application.Broadcast.Scheduling;
|
||||
/// Оркестратор планирования: загружает конфигурацию канала и готовые ассеты, вызывает чистый
|
||||
/// <see cref="SchedulePlanner"/>, материализует записи и двигает курсоры. Используется фоновым
|
||||
/// планировщиком (расширение горизонта) и командой перегенерации (правка конфигурации канала).
|
||||
/// Заставки-переходы, отмеченные планировщиком, здесь рендерятся (или берутся из кэша) по выбранному
|
||||
/// блоку и подставляются как обычные ассеты.
|
||||
/// Ассеты заставок-переходов резолвит/рендерит <see cref="ScheduleBumperResolver"/> (общий контекст).
|
||||
/// </summary>
|
||||
public sealed class ScheduleGenerator(
|
||||
IAppDbContext dbContext,
|
||||
IRandomSource random,
|
||||
IBumperRenderer bumperRenderer,
|
||||
IBumperTemplateStorage bumperStorage,
|
||||
IImageStore imageStore,
|
||||
ScheduleBumperResolver bumperResolver,
|
||||
IOptions<SchedulerOptions> options,
|
||||
IOptions<BumperOptions> bumperOptions,
|
||||
IOptions<StreamingOptions> streamingOptions,
|
||||
ILogger<ScheduleGenerator> logger
|
||||
IOptions<StreamingOptions> streamingOptions
|
||||
)
|
||||
{
|
||||
private readonly SchedulerOptions _options = options.Value;
|
||||
private readonly BumperOptions _bumper = bumperOptions.Value;
|
||||
private readonly int _segmentSeconds = Math.Max(1, streamingOptions.Value.SegmentSeconds);
|
||||
|
||||
/// <summary>Длительность заставки без загруженного звука (сек) — синтезированный джингл.</summary>
|
||||
private const int DefaultBumperDurationSeconds = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Достраивает (или, при <paramref name="regenerate"/>, перестраивает будущий хвост) расписание
|
||||
/// канала до горизонта. Возвращает число добавленных записей (-1 — канал не найден/выключен).
|
||||
@@ -97,8 +84,8 @@ public sealed class ScheduleGenerator(
|
||||
var input = await BuildInputAsync(channel, startTime, horizonEnd, cancellationToken);
|
||||
var result = SchedulePlanner.Plan(input, random);
|
||||
|
||||
// Рендерим/достаём из кэша ассеты заставок для всех переходов плана (по паре шоу + блоку).
|
||||
var bumperAssets = await ResolveBumperAssetsAsync(
|
||||
// Рендерим/достаём из кэша ассеты заставок для всех переходов плана (по паре шоу + подблоку).
|
||||
var bumperAssets = await bumperResolver.ResolveAsync(
|
||||
channel,
|
||||
result.Entries,
|
||||
showNames,
|
||||
@@ -172,315 +159,6 @@ public sealed class ScheduleGenerator(
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Для каждой уникальной тройки «из→в→подблок» из запланированных заставок возвращает id готового
|
||||
/// ассета-заставки: из кэша (<see cref="BumperAsset"/>) либо свежесгенерированного.
|
||||
/// </summary>
|
||||
private async Task<
|
||||
Dictionary<(Guid From, Guid To, Guid Variant), Guid>
|
||||
> ResolveBumperAssetsAsync(
|
||||
Channel channel,
|
||||
IReadOnlyList<PlannedEntry> entries,
|
||||
IReadOnlyDictionary<Guid, string> showNames,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = new Dictionary<(Guid, Guid, Guid), Guid>();
|
||||
var templatesById = channel.BumperTemplates.ToDictionary(t => t.Id);
|
||||
var variantsById = channel
|
||||
.BumperTemplates.SelectMany(t => t.Variants.Select(v => (Variant: v, Template: t)))
|
||||
.ToDictionary(x => x.Variant.Id);
|
||||
var combos = entries
|
||||
.Where(e =>
|
||||
e.Kind == ScheduleEntryKind.Bumper
|
||||
&& e.FromShowId is not null
|
||||
&& e.ToShowId is not null
|
||||
&& e.BumperVariantId is not null
|
||||
)
|
||||
.Select(e =>
|
||||
(
|
||||
From: e.FromShowId!.Value,
|
||||
To: e.ToShowId!.Value,
|
||||
Variant: e.BumperVariantId!.Value
|
||||
)
|
||||
)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
if (combos.Count == 0)
|
||||
return result;
|
||||
|
||||
var fromIds = combos.Select(c => c.From).Distinct().ToList();
|
||||
var toIds = combos.Select(c => c.To).Distinct().ToList();
|
||||
|
||||
// Постеры шоу-получателей (из реестра изображений) — как фон заставки, если у блока нет
|
||||
// своей фон-картинки. Резолвим id постера → расширение → абсолютный путь.
|
||||
var showIds = fromIds.Concat(toIds).Distinct().ToList();
|
||||
var posterShows = await dbContext
|
||||
.Shows.AsNoTracking()
|
||||
.Where(s => showIds.Contains(s.Id) && s.PosterImageId != null)
|
||||
.Select(s => new { s.Id, ImageId = s.PosterImageId!.Value })
|
||||
.ToListAsync(cancellationToken);
|
||||
var posterImageIds = posterShows.Select(p => p.ImageId).Distinct().ToList();
|
||||
var posterExtById = await dbContext
|
||||
.Images.AsNoTracking()
|
||||
.Where(i => posterImageIds.Contains(i.Id))
|
||||
.Select(i => new { i.Id, i.FileExtension })
|
||||
.ToDictionaryAsync(i => i.Id, i => i.FileExtension, cancellationToken);
|
||||
var posterByShow = new Dictionary<Guid, (Guid ImageId, string AbsPath)>();
|
||||
foreach (var p in posterShows)
|
||||
if (
|
||||
posterExtById.TryGetValue(p.ImageId, out var ext)
|
||||
&& imageStore.ResolvePath(p.ImageId, ext) is { } abs
|
||||
)
|
||||
posterByShow[p.Id] = (p.ImageId, abs);
|
||||
|
||||
// Фон-картинки блоков (из реестра) — абсолютные пути по id.
|
||||
var bgImageIds = channel
|
||||
.BumperTemplates.Where(t => t.BackgroundImageId != null)
|
||||
.Select(t => t.BackgroundImageId!.Value)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var bgExtById = await dbContext
|
||||
.Images.AsNoTracking()
|
||||
.Where(i => bgImageIds.Contains(i.Id))
|
||||
.Select(i => new { i.Id, i.FileExtension })
|
||||
.ToDictionaryAsync(i => i.Id, i => i.FileExtension, cancellationToken);
|
||||
var bgByTemplate = new Dictionary<Guid, string>();
|
||||
foreach (var t in channel.BumperTemplates)
|
||||
if (
|
||||
t.BackgroundImageId is { } bgId
|
||||
&& bgExtById.TryGetValue(bgId, out var bgExt)
|
||||
&& imageStore.ResolvePath(bgId, bgExt) is { } bgAbs
|
||||
)
|
||||
bgByTemplate[t.Id] = bgAbs;
|
||||
|
||||
// Кандидаты из кэша + статусы их ассетов (годятся только Ready — файлы могли удалить).
|
||||
var cached = await dbContext
|
||||
.BumperAssets.AsNoTracking()
|
||||
.Where(b => fromIds.Contains(b.FromShowId) && toIds.Contains(b.ToShowId))
|
||||
.Select(b => new
|
||||
{
|
||||
b.FromShowId,
|
||||
b.ToShowId,
|
||||
b.Signature,
|
||||
b.MediaAssetId,
|
||||
})
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var cachedAssetIds = cached.Select(c => c.MediaAssetId).Distinct().ToList();
|
||||
var readyAssetIds = await dbContext
|
||||
.MediaAssets.AsNoTracking()
|
||||
.Where(a => cachedAssetIds.Contains(a.Id) && a.Status == MediaAssetStatus.Ready)
|
||||
.Select(a => a.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var readySet = readyAssetIds.ToHashSet();
|
||||
|
||||
foreach (var combo in combos)
|
||||
{
|
||||
if (!variantsById.TryGetValue(combo.Variant, out var pair))
|
||||
continue;
|
||||
var (variant, template) = pair;
|
||||
|
||||
var fromName = showNames.GetValueOrDefault(combo.From, "…");
|
||||
var toName = showNames.GetValueOrDefault(combo.To, "…");
|
||||
// Постер шоу-получателя как фон — только для «Сейчас/Далее» (свободный текст шоу не упоминает).
|
||||
var usePoster = variant.Kind == BumperTextKind.NowNext;
|
||||
var poster = usePoster && posterByShow.TryGetValue(combo.To, out var pr) ? pr : default;
|
||||
var posterToken = poster.ImageId == Guid.Empty ? "-" : poster.ImageId.ToString();
|
||||
var posterAbs = poster.ImageId == Guid.Empty ? null : poster.AbsPath;
|
||||
var bgAbs = bgByTemplate.GetValueOrDefault(template.Id);
|
||||
var aligned = AlignedDurationSeconds(TemplateDurationSeconds(template));
|
||||
var signature = ComputeSignature(
|
||||
channel,
|
||||
template,
|
||||
variant,
|
||||
fromName,
|
||||
toName,
|
||||
aligned,
|
||||
posterToken
|
||||
);
|
||||
|
||||
var hit = cached.FirstOrDefault(c =>
|
||||
c.FromShowId == combo.From
|
||||
&& c.ToShowId == combo.To
|
||||
&& c.Signature == signature
|
||||
&& readySet.Contains(c.MediaAssetId)
|
||||
);
|
||||
if (hit is not null)
|
||||
{
|
||||
result[combo] = hit.MediaAssetId;
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var assetId = await RenderBumperAsync(
|
||||
channel,
|
||||
template,
|
||||
variant,
|
||||
combo.From,
|
||||
combo.To,
|
||||
fromName,
|
||||
toName,
|
||||
aligned,
|
||||
signature,
|
||||
posterAbs,
|
||||
bgAbs,
|
||||
cancellationToken
|
||||
);
|
||||
result[combo] = assetId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(
|
||||
ex,
|
||||
"Не удалось отрендерить заставку {From} → {To}",
|
||||
fromName,
|
||||
toName
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<Guid> RenderBumperAsync(
|
||||
Channel channel,
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
Guid fromShowId,
|
||||
Guid toShowId,
|
||||
string fromName,
|
||||
string toName,
|
||||
int alignedDurationSeconds,
|
||||
string signature,
|
||||
string? posterAbsolutePath,
|
||||
string? backgroundAbsolutePath,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var asset = MediaAsset.RegisterGenerated($"Заставка: {fromName} → {toName}");
|
||||
var render = await bumperRenderer.RenderAsync(
|
||||
asset.Id,
|
||||
BuildSpec(
|
||||
channel,
|
||||
template,
|
||||
variant,
|
||||
alignedDurationSeconds,
|
||||
fromName,
|
||||
toName,
|
||||
posterAbsolutePath,
|
||||
backgroundAbsolutePath
|
||||
),
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
asset.MarkReady(
|
||||
render.Duration,
|
||||
render.SegmentSeconds,
|
||||
render.SegmentCount,
|
||||
render.Width,
|
||||
render.Height,
|
||||
"h264",
|
||||
"aac",
|
||||
render.RelativePath
|
||||
);
|
||||
|
||||
dbContext.MediaAssets.Add(asset);
|
||||
dbContext.BumperAssets.Add(BumperAsset.Create(fromShowId, toShowId, signature, asset.Id));
|
||||
return asset.Id;
|
||||
}
|
||||
|
||||
private BumperRenderSpec BuildSpec(
|
||||
Channel channel,
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
int alignedDurationSeconds,
|
||||
string fromName,
|
||||
string toName,
|
||||
string? posterAbsolutePath,
|
||||
string? backgroundAbsolutePath
|
||||
)
|
||||
{
|
||||
var free = variant.Kind == BumperTextKind.Free;
|
||||
return new BumperRenderSpec(
|
||||
alignedDurationSeconds,
|
||||
_bumper.Width,
|
||||
_bumper.Height,
|
||||
template.BackgroundColor,
|
||||
template.BackgroundColor2,
|
||||
template.AccentColor,
|
||||
template.TextColor,
|
||||
FontPath(channel.BumperFont),
|
||||
free ? "" : variant.NowLabel,
|
||||
free ? "" : fromName,
|
||||
free ? "" : variant.NextLabel,
|
||||
free ? "" : toName,
|
||||
backgroundAbsolutePath,
|
||||
bumperStorage.AudioPath(template.Id, template.AudioExtension),
|
||||
posterAbsolutePath,
|
||||
free,
|
||||
variant.Line1,
|
||||
variant.Line2
|
||||
);
|
||||
}
|
||||
|
||||
private string FontPath(BumperFont font) =>
|
||||
font == BumperFont.Serif ? _bumper.FontFileSerif : _bumper.FontFileSans;
|
||||
|
||||
/// <summary>Длина заставки блока (сек): по загруженному звуку либо дефолт для синтеза.</summary>
|
||||
private static double TemplateDurationSeconds(BumperTemplate template) =>
|
||||
template.AudioDurationSeconds is { } d and > 0 ? d : DefaultBumperDurationSeconds;
|
||||
|
||||
/// <summary>Длительность, выровненная вверх до кратности длине сегмента (инвариант раздачи).</summary>
|
||||
private int AlignedDurationSeconds(double seconds)
|
||||
{
|
||||
var requested = Math.Max(_segmentSeconds, seconds);
|
||||
return (int)(Math.Ceiling(requested / _segmentSeconds) * _segmentSeconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Сигнатура рендера = хэш всех входов заставки: общие настройки канала (шрифт/подписи/версия
|
||||
/// шаблона), оформление и файлы блока (цвета/фон/звук/ревизия), названия шоу и постер. Меняется —
|
||||
/// заставка пересобирается.
|
||||
/// </summary>
|
||||
private string ComputeSignature(
|
||||
Channel channel,
|
||||
BumperTemplate template,
|
||||
BumperTextVariant variant,
|
||||
string fromName,
|
||||
string toName,
|
||||
int alignedDurationSeconds,
|
||||
string poster
|
||||
)
|
||||
{
|
||||
var raw = string.Join(
|
||||
'',
|
||||
_bumper.TemplateVersion,
|
||||
_bumper.Width,
|
||||
_bumper.Height,
|
||||
alignedDurationSeconds,
|
||||
channel.BumperFont,
|
||||
variant.Kind,
|
||||
variant.NowLabel,
|
||||
variant.NextLabel,
|
||||
variant.Line1,
|
||||
variant.Line2,
|
||||
template.BackgroundColor,
|
||||
template.BackgroundColor2,
|
||||
template.AccentColor,
|
||||
template.TextColor,
|
||||
template.Revision,
|
||||
template.BackgroundImageId?.ToString() ?? "-",
|
||||
template.AudioExtension ?? "-",
|
||||
fromName,
|
||||
toName,
|
||||
poster
|
||||
);
|
||||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(raw));
|
||||
return Convert.ToHexString(hash);
|
||||
}
|
||||
|
||||
private async Task<Dictionary<Guid, string>> LoadShowNamesAsync(
|
||||
Channel channel,
|
||||
CancellationToken cancellationToken
|
||||
@@ -569,7 +247,9 @@ public sealed class ScheduleGenerator(
|
||||
.BumperTemplates.OrderBy(t => t.Position)
|
||||
.SelectMany(t =>
|
||||
{
|
||||
var dur = TimeSpan.FromSeconds(AlignedDurationSeconds(TemplateDurationSeconds(t)));
|
||||
var dur = TimeSpan.FromSeconds(
|
||||
BumperDuration.Aligned(BumperDuration.TemplateSeconds(t), _segmentSeconds)
|
||||
);
|
||||
return t
|
||||
.Variants.OrderBy(v => v.Position)
|
||||
.Select(v => new PlannerBumperVariant(v.Id, t.Id, dur, v.Trigger, v.Weight));
|
||||
|
||||
@@ -126,6 +126,7 @@ public static class DependencyInjection
|
||||
services.AddSingleton<IRandomSource, SystemRandomSource>();
|
||||
services.AddSingleton<StreamTokenService>();
|
||||
services.AddSingleton<IBumperRenderer, FfmpegBumperRenderer>();
|
||||
services.AddScoped<ScheduleBumperResolver>();
|
||||
services.AddScoped<ScheduleGenerator>();
|
||||
services.AddHostedService<SchedulingBackgroundService>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user