// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env , ILoggerManager logger, IMongoDbContext context, IHostApplicationLifetime appLifetime) { app.UseCors("DiscPolicy"); _quartzScheduler.JobFactory = new AspnetCoreJobFactory(app.ApplicationServices); _quartzScheduler.Start().Wait(); _quartzScheduler2.JobFactory = new AspnetCoreJobFactory(app.ApplicationServices); _quartzScheduler2.Start().Wait(); appLifetime.ApplicationStopped.Register(() => { // Drop hangfire database on server shutdown var mongoUrlBuilder = new MongoUrlBuilder("mongodb://localhost/jobs"); var quartzmong = new MongoUrlBuilder("mongodb://localhost/Quartzjobs"); var dbName = mongoUrlBuilder.DatabaseName; var quartzdb = quartzmong.DatabaseName; context.Dropdatabase(dbName); context.Dropdatabase(quartzdb); }); app.UseHangfireServer(); app.UseHangfireDashboard(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } // app.ConfigureExceptionHandler(logger); var swaggerSettings = new SwaggerSettings(); Configuration.GetSection(nameof(swaggerSettings)).Bind(swaggerSettings); app.UseSwagger(options => { options.RouteTemplate = swaggerSettings.JsonRoute; }); app.UseSwaggerUI(setupAction => { setupAction.SwaggerEndpoint(swaggerSettings.UiEndPoint, swaggerSettings.Description); setupAction.DocExpansion(DocExpansion.None); }); DbInitializer.SeedData(context); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapHub <LiveGameHub>("/LiveGameHub"); endpoints.MapHub <BetSystemHub>("/Betsystemhub"); endpoints.MapHub <ScoreBoardHub>("/ScoreBHub"); endpoints.MapControllers(); }); RecurringJob.AddOrUpdate <BetsSetJob>( job => job.SetBets(), " */5 * * * *"); RecurringJob.AddOrUpdate <LiveGamesUpdateJob>( job => job.Updatelivegames(), "*/15 * * * * *"); }