117 lines
3.9 KiB
C#
117 lines
3.9 KiB
C#
using FabApprovalWorkerService.Clients;
|
|
using FabApprovalWorkerService.Services;
|
|
using FabApprovalWorkerService.Workers;
|
|
|
|
using NLog.Extensions.Logging;
|
|
|
|
using Quartz;
|
|
|
|
using System.Net.Mail;
|
|
|
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
|
|
|
builder.Logging.ClearProviders();
|
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
|
builder.Logging.AddNLog();
|
|
|
|
builder.Services.AddHttpClient();
|
|
|
|
builder.Services.AddScoped<IDbConnectionService, DbConnectionService>();
|
|
builder.Services.AddScoped<IMonInClient, MonInClient>();
|
|
builder.Services.AddScoped<IDalService, DalService>();
|
|
builder.Services.AddScoped<SmtpClient>((serviceProvider) => {
|
|
return new SmtpClient("mailrelay-external.infineon.com");
|
|
});
|
|
builder.Services.AddScoped<ISmtpClientWrapper, SmtpClientWrapper>();
|
|
builder.Services.AddScoped<ISmtpService, SmtpService>();
|
|
|
|
builder.Services.AddScoped<IUserService, UserService>();
|
|
builder.Services.AddScoped<IECNService, ECNService>();
|
|
builder.Services.AddScoped<ITrainingService, TrainingService>();
|
|
builder.Services.AddScoped<ICorrectiveActionService, CorrectiveActionService>();
|
|
|
|
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")
|
|
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 15))
|
|
);
|
|
|
|
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")
|
|
.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")
|
|
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(6, 0))
|
|
);
|
|
|
|
JobKey expiredTECNJob = new JobKey("Expired TECN job");
|
|
q.AddJob<ExpiredTECNWorker>(opts => opts
|
|
.WithIdentity(expiredTECNJob)
|
|
);
|
|
q.AddTrigger(opts => opts
|
|
.ForJob(expiredTECNJob)
|
|
.WithIdentity("Expired TECN trigger")
|
|
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(6, 0))
|
|
);
|
|
|
|
JobKey trainingReminderJob = new JobKey("Training reminder job");
|
|
q.AddJob<TrainingNotificationWorker>(opts => opts
|
|
.WithIdentity(trainingReminderJob)
|
|
);
|
|
q.AddTrigger(opts => opts
|
|
.ForJob(trainingReminderJob)
|
|
.WithIdentity("Training reminder trigger")
|
|
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(6, 0))
|
|
);
|
|
|
|
JobKey caFollowUpJob = new JobKey("CA follow up job");
|
|
q.AddJob<CAFollowUpWorker>(opts => opts
|
|
.WithIdentity(caFollowUpJob)
|
|
);
|
|
q.AddTrigger(opts => opts
|
|
.ForJob(caFollowUpJob)
|
|
.WithIdentity("CA follow up trigger")
|
|
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(6, 0))
|
|
);
|
|
|
|
JobKey userCertJob = new JobKey("Certification training group job");
|
|
q.AddJob<CertificationTrainingGroupWorker>(opts => opts
|
|
.WithIdentity(userCertJob)
|
|
);
|
|
q.AddTrigger(opts => opts
|
|
.ForJob(userCertJob)
|
|
.WithIdentity("Certification training group trigger")
|
|
.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(1, 0))
|
|
);
|
|
});
|
|
|
|
builder.Services.AddQuartzHostedService(opt => {
|
|
opt.WaitForJobsToComplete = true;
|
|
});
|
|
|
|
builder.Services.AddWindowsService(options => {
|
|
options.ServiceName = "Fab Approval Worker Service";
|
|
});
|
|
builder.Services.AddHostedService<WindowsService>();
|
|
|
|
IHost app = builder.Build();
|
|
|
|
app.Run();
|