public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISubmissionObjectJobService jobService, IServiceScopeFactory serviceScopeFactory, IServiceAreaService svcAreaService, ICodeLookupRepository codeLookupRepo, IActivityRuleRepository activityRuleRepo, IFieldValidatorService validator) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseExceptionMiddleware(); app.UseHmcrHealthCheck(); app.UseRouting(); app.UseCors(Constants.HmcrOrigins); app.UseAuthentication(); app.UseAuthorization(); app.UseSerilogUi(); app.UseHmcrEndpoints(); app.UseHmcrSwagger(env, Configuration.GetSection("Constants:SwaggerApiUrl").Value); validator.CodeLookup = codeLookupRepo.LoadCodeLookupCache(); validator.ActivityCodeRuleLookup = activityRuleRepo.LoadActivityCodeRuleCache(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISubmissionObjectJobService jobService, IServiceScopeFactory serviceScopeFactory, IServiceAreaService svcAreaService, ICodeLookupRepository codeLookupRepo, IFieldValidatorService validator) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseExceptionMiddleware(); app.UseHmcrHealthCheck(); app.UseHangfireDashboard(); //Register Hangfire Recurring Jobs var serviceAreas = svcAreaService.GetAllServiceAreas(); var minutes = Configuration.GetValue <int>("Hangfire:ReportJobIntervalInMinutes"); minutes = minutes < 1 ? 5 : minutes; foreach (var serviceArea in serviceAreas) { RecurringJob.AddOrUpdate <SubmissionObjectJobService>($"SA{serviceArea.ServiceAreaNumber}", x => x.RunReportingJob(serviceArea.ServiceAreaNumber), $"*/{minutes} * * * *"); } //Inject Code Lookup validator.CodeLookup = codeLookupRepo.LoadCodeLookupCache(); minutes = Configuration.GetValue <int>("Hangfire:EmailJobIntervalInMinutes"); minutes = minutes < 1 ? 30 : minutes; RecurringJob.AddOrUpdate <EmailJobService>("ResendEmails", x => x.ResendEmails(), $"*/{minutes} * * * *"); }