Created PendingOOOStatusWorker
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user