Created Windows Service

This commit is contained in:
Chase Tucker
2024-04-03 12:05:44 -07:00
parent 35690df362
commit 794b616293
14 changed files with 247 additions and 38 deletions

@ -8,7 +8,7 @@ using Quartz;
using System.Net.Mail;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
@ -36,11 +36,7 @@ builder.Services.AddQuartz(q => {
q.AddTrigger(opts => opts
.ForJob(pendingOOOStatusJob)
.WithIdentity("Pending OOO status trigger")
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(10)
.RepeatForever()
)
.StartNow()
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 0))
);
JobKey expiredOOOStatusJob = new JobKey("Expired OOO status job");
@ -50,6 +46,16 @@ builder.Services.AddQuartz(q => {
q.AddTrigger(opts => opts
.ForJob(expiredOOOStatusJob)
.WithIdentity("Expired OOO status trigger")
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 0))
);
JobKey expiringTECNJob = new JobKey("Expiring TECN job");
q.AddJob<ExpiringTECNWorker>(opts => opts
.WithIdentity(expiringTECNJob)
);
q.AddTrigger(opts => opts
.ForJob(expiringTECNJob)
.WithIdentity("Expiring TECN trigger")
.WithSimpleSchedule(x => x
.WithIntervalInMinutes(10)
.RepeatForever()
@ -62,6 +68,11 @@ builder.Services.AddQuartzHostedService(opt => {
opt.WaitForJobsToComplete = true;
});
WebApplication app = builder.Build();
builder.Services.AddWindowsService(options => {
options.ServiceName = "Fab Approval Worker Service";
});
builder.Services.AddHostedService<WindowsService>();
IHost app = builder.Build();
app.Run();