using FabApprovalWorkerService.Services; using FabApprovalWorkerService.Workers; using Microsoft.Data.Sqlite; using NLog.Extensions.Logging; using Quartz; using System.Data; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Logging.ClearProviders(); builder.Logging.SetMinimumLevel(LogLevel.Trace); builder.Logging.AddNLog(); builder.Services.AddHttpClient(); #if DEBUG builder.Services.AddScoped(db => new SqliteConnection( builder.Configuration.GetConnectionString("Default"))); #else builder.Services.AddScoped(db => new SqlConnection( builder.Configuration.GetConnectionString("Default"))); #endif builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddQuartz(q => { JobKey updateCertDataJobKey = new JobKey("Pending OOO status job"); q.AddJob(opts => opts .WithIdentity(updateCertDataJobKey) ); q.AddTrigger(opts => opts .ForJob(updateCertDataJobKey) .WithIdentity("Pending OOO status trigger") .WithSimpleSchedule(x => x .WithIntervalInMinutes(10) .RepeatForever() ) .StartNow() ); }); builder.Services.AddQuartzHostedService(opt => { opt.WaitForJobsToComplete = true; }); WebApplication app = builder.Build(); app.Run();