2024-03-25 12:24:25 -07:00

63 lines
1.7 KiB
C#

using FabApprovalWorkerService.Services;
using FabApprovalWorkerService.Workers;
using Microsoft.Data.Sqlite;
using NLog.Extensions.Logging;
using Quartz;
using System.Data;
using Microsoft.Data.SqlClient;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddNLog();
builder.Services.AddHttpClient();
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 pendingOOOStatusJob = new JobKey("Pending OOO status job");
q.AddJob<PendingOOOStatusWorker>(opts => opts
.WithIdentity(pendingOOOStatusJob)
);
q.AddTrigger(opts => opts
.ForJob(pendingOOOStatusJob)
.WithIdentity("Pending OOO status trigger")
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(10)
.RepeatForever()
)
.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 => {
opt.WaitForJobsToComplete = true;
});
WebApplication app = builder.Build();
app.Run();