Add operation kind

This commit is contained in:
2025-11-16 17:41:58 +09:00
parent 6abff9cc7e
commit a4055bee7e
10 changed files with 129 additions and 8 deletions

View File

@ -1,6 +1,34 @@
namespace Hcs.WebApp.BackgroundServices
using Hcs.WebApp.BackgroundServices.DataParsers;
using Hcs.WebApp.Services;
namespace Hcs.WebApp.BackgroundServices
{
public class DataParsingService
public class DataParsingService(
DataParsingState state,
DataParserFactory dataParserFactory,
IServiceScopeFactory scopeFactory) : BackgroundService
{
private readonly DataParsingState state = state;
private readonly DataParserFactory dataParserFactory = dataParserFactory;
private readonly IServiceScopeFactory scopeFactory = scopeFactory;
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await InitializeStateAsync();
}
private async Task InitializeStateAsync()
{
using var scope = scopeFactory.CreateScope();
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
var operations = await headquartersService.GetResultWaitingOperationsAsync();
foreach (var operation in operations)
{
state.EnqueueOperation(operation);
}
state.Ready = true;
}
}
}