/// <summary> /// внести в БД данные если она пустая /// </summary> private void InitializeData() { _dataInit = new InitializeData( _productService, _storageService, _unitService, _documentTypeService, _productOperationService, _ruleSaleService, _operationTypeService, _documentService, _storageRemainderService, _documentOperationService ); _dataInit.Initialize(); //инициализация данных при первой загрузке приложения _dataInit.DropOpenDocuments(); //удалить открытые документы CreateSaleDocument(); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.MapWhen(x => !x.Request.Path.Value.StartsWith("/api"), builder => { builder.UseMvc(routes => { routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); }); // To add migrations, this code must be commented out. var scopeFactory = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>(); using (var scope = scopeFactory.CreateScope()) { InitializeData.Initialize(scope.ServiceProvider, loggerFactory); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptions <AppSettings> appSettings, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseStaticFiles(); if (appSettings.Value.ThemeOptions.ThemeName.ToLower() == "see3slam") { app.Map("/.well-known/acme-challenge/f7zuskQNCT9DJm3UBVp2Aku0xvK4_JA2oojt1GGOcXo", (myApp) => { myApp.Run(async context => { await context.Response.WriteAsync("f7zuskQNCT9DJm3UBVp2Aku0xvK4_JA2oojt1GGOcXo.P7i0MAfwh8h4Er9lLDatf5hwA9ifJwWhU4FFuCYO-xU"); }); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}/{id?}", defaults: new { controller = "Team", action = "Index" }); }); } else { app.UseMvcWithDefaultRoute(); } InitializeData.Initialize(serviceProvider, loggerFactory, appSettings.Value.ThemeOptions.ThemeName.ToLower()); }
public static async Task Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var dbContext = services.GetRequiredService <ApplicationContext>(); dbContext.Database.EnsureCreated(); await InitializeData.Initialize(dbContext); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); InitializeData.Initialize(context, userManager, roleManager).Wait(); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); }