Created PendingOOOStatusWorker

This commit is contained in:
Chase Tucker
2024-03-19 13:50:30 -07:00
parent 41a01fcf14
commit 27f78da969
184 changed files with 1930 additions and 2762 deletions

View File

@ -1,26 +1,53 @@
using FabApprovalWorkerService.Services;
using FabApprovalWorkerService.Workers;
using Microsoft.Extensions.Configuration;
using Microsoft.Data.Sqlite;
using NLog.Extensions.Logging;
using System.Data.SqlClient;
using Quartz;
using System.Data;
using FabApprovalWorkerService.Services;
IHostBuilder builder = Host.CreateDefaultBuilder(args)
.ConfigureLogging((hostContext, logging) => {
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
logging.AddNLog();
})
.ConfigureServices((hostContext, services) => {
services.AddHostedService<UserCertificationUpdateWorker>();
services.AddTransient<IDbConnection>(db => new SqlConnection(
hostContext.Configuration.GetConnectionString("Default")));
services.AddScoped<IDalService, DalService>();
services.AddScoped<IUserService, UserService>();
});
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
IHost host = builder.Build();
host.Run();
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddNLog();
builder.Services.AddHttpClient();
#if DEBUG
builder.Services.AddScoped<IDbConnection>(db => new SqliteConnection(
builder.Configuration.GetConnectionString("Default")));
#else
builder.Services.AddScoped<IDbConnection>(db => new SqlConnection(
builder.Configuration.GetConnectionString("Default")));
#endif
builder.Services.AddScoped<IMonInWorkerClient, MonInWorkerClient>();
builder.Services.AddScoped<IDalService, DalService>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddQuartz(q => {
JobKey updateCertDataJobKey = new JobKey("Pending OOO status job");
q.AddJob<PendingOOOStatusWorker>(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();