public ArticleCache() { _dbConnectionString = Dbms.getDbContextString(); _masterDBContext = new ProductionDomainContext(options: new DbContextOptionsBuilder <MasterDBContext>() .UseSqlServer(connectionString: _dbConnectionString) .Options); _masterDBContext.Database.EnsureCreated(); MasterDbInitializerTable.DbInitialize(context: _masterDBContext); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app , IWebHostEnvironment env , HangfireDBContext hangfireContext , MasterDBContext context , ResultContext contextResults , ProductionDomainContext productionDomainContext) { MasterDbInitializerTable.DbInitialize(context: context); ResultDBInitializerBasic.DbInitialize(context: contextResults); #region Hangfire HangfireDBInitializer.DbInitialize(context: hangfireContext); GlobalConfiguration.Configuration .UseFilter(filter: new AutomaticRetryAttribute { Attempts = 0 }) .UseSqlServerStorage(nameOrConnectionString: Configuration.GetConnectionString(name: "Hangfire")) .UseConsole(); app.UseHangfireDashboard(); #endregion var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options: options.Value); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler(errorHandlingPath: "/Home/Error"); } app.UseCors("CorsPolicy"); app.UseFileServer(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(router => { router.MapHub <MessageHub>("/MessageHub"); }); app.UseMvc(configureRoutes: routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public async Task <IActionResult> ReloadDb(string products) { await Task.Run(action : () => { switch (products) { case "Tables": _context.Database.EnsureDeleted(); MasterDbInitializerTable.DbInitialize(context: _context); break; case "Trucks": _context.Database.EnsureDeleted(); MasterDBInitializerTruck.DbInitialize(context: _context, resourceModelSize: ModelSize.Medium, setupModelSize: ModelSize.Medium, ModelSize.Small, 3, false); break; default: break; } } ); return(View(viewName: "Index")); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app , IHostingEnvironment env , ILoggerFactory loggerFactory , HangfireDBContext hangfireContext , MasterDBContext context , ResultContext contextResults , ProductionDomainContext productionDomainContext) { //MasterDBInitializerLarge.DbInitialize(context); //MasterDBInitializerLarge.DbInitialize(context); MasterDbInitializerTable.DbInitialize(context: context); ResultDBInitializerBasic.DbInitialize(context: contextResults); HangfireDBInitializer.DbInitialize(context: hangfireContext); var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(options: options.Value); GlobalConfiguration.Configuration.UseFilter(filter: new AutomaticRetryAttribute { Attempts = 0 }); #region Hangfire GlobalConfiguration.Configuration.UseSqlServerStorage(nameOrConnectionString: Configuration.GetConnectionString(name: "Hangfire")); app.UseHangfireDashboard(); app.UseHangfireServer(); #endregion if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler(errorHandlingPath: "/Home/Error"); } app.UseFileServer(); app.UseStaticFiles(); // app.UseSignalR(); app.UseSignalR(configure: router => { router.MapHub <MessageHub>(path: "/MessageHub"); }); var serverOptions = new BackgroundJobServerOptions() { ServerName = "ProcessingUnit", }; app.UseHangfireServer(options: serverOptions); app.UseHangfireDashboard(); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(setupAction: c => { c.SwaggerEndpoint(url: "/swagger/v1/swagger.json", name: "API DOC V1"); }); app.UseMvc(configureRoutes: routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }