Created ExpiredOOOStatusWorker

This commit is contained in:
Chase Tucker
2024-03-25 12:22:26 -07:00
parent 27f78da969
commit 69fdd98ab3
46 changed files with 549 additions and 5118 deletions

View File

@ -8,6 +8,7 @@ using NLog.Extensions.Logging;
using Quartz;
using System.Data;
using Microsoft.Data.SqlClient;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
@ -17,25 +18,18 @@ 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<IDbConnectionService, DbConnectionService>();
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");
JobKey pendingOOOStatusJob = new JobKey("Pending OOO status job");
q.AddJob<PendingOOOStatusWorker>(opts => opts
.WithIdentity(updateCertDataJobKey)
.WithIdentity(pendingOOOStatusJob)
);
q.AddTrigger(opts => opts
.ForJob(updateCertDataJobKey)
.ForJob(pendingOOOStatusJob)
.WithIdentity("Pending OOO status trigger")
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(10)
@ -43,6 +37,20 @@ builder.Services.AddQuartz(q => {
)
.StartNow()
);
JobKey expiredOOOStatusJob = new JobKey("Expired OOO status job");
q.AddJob<ExpiredOOOStatusWorker>(opts => opts
.WithIdentity(expiredOOOStatusJob)
);
q.AddTrigger(opts => opts
.ForJob(expiredOOOStatusJob)
.WithIdentity("Expired OOO status trigger")
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(10)
.RepeatForever()
)
.StartNow()
);
});
builder.Services.AddQuartzHostedService(opt => {
@ -50,4 +58,5 @@ builder.Services.AddQuartzHostedService(opt => {
});
WebApplication app = builder.Build();
app.Run();