Added worker app.
This commit is contained in:
28
JSMR.Worker/Services/ScanJob.cs
Normal file
28
JSMR.Worker/Services/ScanJob.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using JSMR.Application.Enums;
|
||||
using JSMR.Application.Scanning;
|
||||
using JSMR.Worker.Options;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace JSMR.Worker.Services;
|
||||
|
||||
public sealed class ScanJob(ILogger<ScanJob> log, IOptions<ScanOptions> options, ScanVoiceWorksHandler scanVoiceWorksHandler)
|
||||
{
|
||||
private readonly ScanOptions _options = options.Value;
|
||||
|
||||
public async Task RunOnceAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
log.LogInformation("Starting scan: Locale={Locale}, Start Page={StartPage}, EndPage={EndPage}",
|
||||
_options.Locale, _options.StartPage, _options.EndPage);
|
||||
|
||||
ScanVoiceWorksRequest request = new(
|
||||
PageNumber: 1,
|
||||
PageSize: 100,
|
||||
Locale: Enum.Parse<Locale>(_options.Locale, true)
|
||||
);
|
||||
|
||||
await scanVoiceWorksHandler.HandleAsync(request, cancellationToken);
|
||||
|
||||
log.LogInformation("Scan completed.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user