Esempio n. 1
0
        // 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?}");
            });
        }
Esempio n. 2
0
 static void Main()
 {
     InitDb.InitDbFile();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainForm());
 }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        // 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);
        }
Esempio n. 5
0
        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" });
            });
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            InitDb.InitializeDatabase(host);
            host.Run();
        }
Esempio n. 7
0
        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());
        }
Esempio n. 8
0
        // 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);
        }
Esempio n. 9
0
        public MainVM()
        {
            var InitDb = new InitDb();

            InitDb.InitQuestion().ForEach(Answer => { MillionerDBContext.Questions.Add(Answer); });
            MillionerDBContext.SaveChanges();
            SetQuestion();
        }
Esempio n. 10
0
 public ConnectionScope()
 {
     if (string.IsNullOrEmpty(s_connectionString))
     {
         s_connectionString = InitDb.ConnectionStr();
     }
     Init(s_connectionString);
 }
Esempio n. 11
0
        static void Main(string[] args)
        {
            InitDb.Start();

            EFServiceProvider.RunInContext(context =>
            {
                basicQueries(context);
            });

            // testUpdateTriggers();
        }
Esempio n. 12
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.DateTimeZoneHandling  = DateTimeZoneHandling.Utc;
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            InitDb.InitConnectionString(services);
        }
Esempio n. 13
0
        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"));
        }
Esempio n. 14
0
        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();
        }
Esempio n. 15
0
        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();
        }
Esempio n. 17
0
        // 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);
        }
Esempio n. 18
0
        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();
        }
Esempio n. 19
0
        // 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);
        }
Esempio n. 20
0
        // 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();
            });
        }
Esempio n. 21
0
        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());
        }
Esempio n. 22
0
        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();
        }
Esempio n. 23
0
        // 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);
        }
Esempio n. 24
0
        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();
        }
Esempio n. 25
0
 public static void ClassInit(TestContext context)
 {
     InitDb.CreateDbLikeProperties();
     InitDb.CreateDbTestLikeMySql();
 }
Esempio n. 26
0
 public FormMainData()
 {
     new ConnectionScope(InitDb.ConnectionStr());
 }
Esempio n. 27
0
 public UpgradeActionService()
 {
     new ConnectionScope(InitDb.ConnectionStr());
 }