// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { using (var scope = app.ApplicationServices.CreateScope()) { ApplicationContext db = scope.ServiceProvider.GetRequiredService <ApplicationContext>(); InitDb.Initial(db); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // добавляем сборку через webpack app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("Home/Error"); app.UseHsts(); } app.UseDefaultFiles(); app.UseStatusCodePages(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=home}/{action=index}/{id?}"); }); }
static void Main() { InitDb.InitDbFile(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
public static async Task Main(string[] args) { var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); try { var host = CreateHostBuilder(args).Build(); using var serviceScope = host.Services.CreateScope(); try { var services = serviceScope.ServiceProvider; var dbContecxt = services.GetRequiredService <AppDbContext>(); await dbContecxt.Database.MigrateAsync(); await InitDb.Initialize(services); } catch (Exception ex) { logger.Error(ex, "An error occurred while seeding the database."); throw; } await host.RunAsync(); } catch (Exception ex) { logger.Error(ex, "Stopped program because of exception"); throw; } finally { NLog.LogManager.Shutdown(); } }
// 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, ELearningDbContext db) { if (env.IsDevelopment()) { app.UseCors(builder => builder .WithOrigins("http://localhost:60000", "http://localhost:5001") //<-- OP's origin .AllowAnyHeader() .AllowAnyOrigin() .AllowAnyMethod() .AllowCredentials() ); } loggerFactory.AddConsole(Configuration.GetSection("Logging")); //loggerFactory.AddDebug(); loggerFactory.AddFile("Logs/ELearning_Logs_{Date}.txt"); app.UseResponseCompression().UseStaticFiles(); app.UseTokenMiddlewareExtensions(); app.UseMvc(); InitDb.Init(db); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { InitDb.Init(app); if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseExceptionHandler(appError => { appError.Run(async context => { context.Response.ContentType = "application/json"; var contextFeature = context.Features.Get <IExceptionHandlerFeature>(); var error = contextFeature.Error; await context.Response.WriteAsync(error.Message); }); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute("angular-fallback", new { controller = "Home", action = "Index" }); }); }
public static void Main(string[] args) { var host = BuildWebHost(args); InitDb.InitializeDatabase(host); host.Run(); }
public static string TestDBConn(string data) { StringBuilder sb = new StringBuilder(); string saveRet = SaveSiteInfo(data); if (!string.IsNullOrEmpty(saveRet)) { return(saveRet); } var conn = new SqlConnection(InitDb.ConnectionStr()); try { conn.Open(); } catch (Exception ex) { conn.Close(); conn.Dispose(); sb.Append("数据库连接失败!\r\n" + ex.Message); } finally { conn.Close(); conn.Dispose(); } return(sb.ToString()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); InitDb.Init(context); }
public MainVM() { var InitDb = new InitDb(); InitDb.InitQuestion().ForEach(Answer => { MillionerDBContext.Questions.Add(Answer); }); MillionerDBContext.SaveChanges(); SetQuestion(); }
public ConnectionScope() { if (string.IsNullOrEmpty(s_connectionString)) { s_connectionString = InitDb.ConnectionStr(); } Init(s_connectionString); }
static void Main(string[] args) { InitDb.Start(); EFServiceProvider.RunInContext(context => { basicQueries(context); }); // testUpdateTriggers(); }
public void ConfigureServices(IServiceCollection services) { services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); InitDb.InitConnectionString(services); }
public void TestCreateDb() { InitDb.createDbTables(); Assert.IsTrue(InitDb.isTableExists("userinfo")); Assert.IsTrue(InitDb.isTableExists("backup_locations")); Assert.IsTrue(InitDb.isTableExists("logs")); Assert.IsTrue(InitDb.isTableExists("mysql_servers")); Assert.IsTrue(InitDb.isTableExists("schedule_save_locations")); Assert.IsTrue(InitDb.isTableExists("schedules")); Assert.IsFalse(InitDb.isTableExists("nonexistanceTable")); }
public static void Register(HttpConfiguration config) { // Web API configuration and services InitDb.UpdateDatabase(); var json = config.Formatters.JsonFormatter; json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All; json.SerializerSettings.Formatting = Formatting.None; config.Formatters.Remove(config.Formatters.XmlFormatter); // Web API routes config.MapHttpAttributeRoutes(); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { int countSize = 1000; modelBuilder.Entity <Position>().HasData(InitDb.GetPositions(countSize)); modelBuilder.Entity <Staff>().HasData(InitDb.GetStaffs(countSize)); modelBuilder.Entity <TypeAirplane>().HasData(InitDb.GetTypeAirplanes(countSize)); modelBuilder.Entity <Airplane>().HasData(InitDb.GetAirplanes(countSize)); modelBuilder.Entity <JobAirplane>().HasData(InitDb.GetJobAirplanes(countSize)); modelBuilder.Entity <Flight>().HasData(InitDb.GetFlights(countSize)); modelBuilder.Entity <Ticket>().HasData(InitDb.GetTickets(countSize)); }
public static void Main(string[] args) { //BuildWebHost(args).Run(); var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <UCmsApiContext>(); InitDb.Init(context); } host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ShoppingListContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); InitDb.Initialize(context); }
public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <CinemaDbContext>(); InitDb.Initialize(context); // This is where the Seed data is pohabilitiedi sluta copy paste } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); InitDb.Prepopulation(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { using (var scope = app.ApplicationServices.CreateScope()) { ApplicationContext db = scope.ServiceProvider.GetRequiredService <ApplicationContext>(); InitDb.Initial(db); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // добавляем сборку через webpack //app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions //{ // HotModuleReplacement = true //}); } else { app.UseExceptionHandler("Home/Error"); app.UseHsts(); } app.UseDefaultFiles(); app.UseStatusCodePages(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); // added app.UseCors(builder => builder.WithOrigins("http://localhost:4200")); //app.UseMvc(routes => //{ // routes.MapRoute( // name: "default", // template: "{controller=home}/{action=index}/{id?}"); //}); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public static string Test(SiteInfo info) { var sb = new StringBuilder(); var upFilesAddress = new DirectoryInfo(info.UpFilesAddress); if (!upFilesAddress.Exists) { sb.Append("UpFiles目录不存在!\r\n"); } var wFAddress = new DirectoryInfo(info.WFAddress); { if (!wFAddress.Exists) { sb.Append("工作流站点目录不存在!\r\n"); } } var conn = new SqlConnection(InitDb.ConnectionStr()); try { conn.Open(); } catch (Exception ex) { conn.Close(); conn.Dispose(); sb.Append("数据库连接失败!\r\n"); } finally { conn.Close(); conn.Dispose(); } return(sb.ToString()); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <UCmsApiContext>(); InitDb.Init(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
// 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, SIMSDbContext db) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); // loggerFactory.AddDebug(); loggerFactory.AddFile("Logs/SIMS-{Date}.txt"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseTokenMiddlewareExtensions(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}/{id?}"); routes.MapRoute( name: "api", template: "api/{controller}/{action}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); InitDb.Init(db); }
public static void Main(string[] args) { //BuildWebHost(args).Run(); var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <CartContext>(); InitDb.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occured while creating the Database"); } } host.Run(); }
public static void ClassInit(TestContext context) { InitDb.CreateDbLikeProperties(); InitDb.CreateDbTestLikeMySql(); }
public FormMainData() { new ConnectionScope(InitDb.ConnectionStr()); }
public UpgradeActionService() { new ConnectionScope(InitDb.ConnectionStr()); }