Name Message Date
📁 Properties Add web dashboard for viewing monitor status and detections. 2 hours ago
📁 Protos Initialize project 1 month ago
📁 wwwroot Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 .containerfile Containerize 10 days ago
📄 .dockerignore Containerize 10 days ago
📄 .editorconfig Initialize project 1 month ago
📄 .gitignore Remove database file from repository 10 days ago
📄 AppSettings.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 appsettings.Development.json Fix Claudes mess 11 days ago
📄 appsettings.json Fix Claudes mess 11 days ago
📄 BfiMonitor.csproj Add web dashboard for viewing monitor status and detections. 2 hours ago
📄 BfiMonitor.slnx Initialize project 1 month ago
📄 CheckMonitoringJob.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 dotnet-tools.json Initialize project 1 month ago
📄 global.json Fix Claudes mess 11 days ago
📄 IntervalScheduler.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 MonitoringCheckScheduler.cs Add multi-monitoring management with scan triggers and editing. 2 hours ago
📄 MonitorOptions.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 OpenTelemetryExtensions.cs Add web dashboard for viewing monitor status and detections. 2 hours ago
📄 packages.lock.json Add web dashboard for viewing monitor status and detections. 2 hours ago
📄 PlaywrightBrowserService.cs Use Playwright settings from Lukas 10 days ago
📄 Program.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 ScheduleMonitoringChecksJob.cs Add multi-monitoring management with scan triggers and editing. 2 hours ago
📄 ScreeningRepository.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 SendSmsJob.cs Add tracing 10 days ago
📄 Tracing.cs Add configurable settings and per-monitoring SMS recipients. 1 hour ago
📄 IntervalScheduler.cs
using Quartz;

internal static class QuartzScheduling
{
    public static readonly JobKey ScheduleMonitoringChecksJobKey = JobKey.Create(nameof(ScheduleMonitoringChecksJob));

    public static readonly TriggerKey ScheduleMonitoringChecksTriggerKey = new(
        "interval",
        nameof(ScheduleMonitoringChecksJob)
    );
}

internal sealed class IntervalScheduler(ISchedulerFactory schedulerFactory, ScreeningRepository repository)
{
    public async Task ApplyStoredIntervalAsync(CancellationToken cancellationToken = default)
    {
        var settings = await repository.GetAppSettingsAsync(cancellationToken);
        await RescheduleAsync(settings.IntervalSeconds, cancellationToken);
    }

    public async Task RescheduleAsync(int intervalSeconds, CancellationToken cancellationToken = default)
    {
        var scheduler = await schedulerFactory.GetScheduler(cancellationToken);
        var seconds = Math.Max(60, intervalSeconds);
        var trigger = TriggerBuilder
            .Create()
            .ForJob(QuartzScheduling.ScheduleMonitoringChecksJobKey)
            .WithIdentity(QuartzScheduling.ScheduleMonitoringChecksTriggerKey)
            .StartNow()
            .WithSimpleSchedule(s => s.WithIntervalInSeconds(seconds).RepeatForever())
            .Build();

        if (await scheduler.CheckExists(QuartzScheduling.ScheduleMonitoringChecksTriggerKey, cancellationToken))
        {
            await scheduler.RescheduleJob(
                QuartzScheduling.ScheduleMonitoringChecksTriggerKey,
                trigger,
                cancellationToken
            );
        }
    }
}