54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
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<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();
|