Esempio n. 1
0
 public static void DbInit(DwDbContext c)
 {
     c.Database.EnsureCreated();
     //c.Database.Migrate();
     c.CommonConfig.Add(new CommonConfigEntity {
         Item = "BlogPageSize", Value = "20"
     });
     c.CommonConfig.Add(new CommonConfigEntity {
         Item = "BlogReplyPageSize", Value = "10"
     });
     c.CommonConfig.Add(new CommonConfigEntity {
         Item = "ForumPostPageSize", Value = "20"
     });
     c.CommonConfig.Add(new CommonConfigEntity {
         Item = "ForumReplyPageSize", Value = "20"
     });
     c.CommonConfig.Add(new CommonConfigEntity {
         Item = "ForumSubReplyPageSize", Value = "10"
     });
     c.SaveChanges();
 }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DwDbContext dbc)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "quizsite API");
                });
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            //如/file对应的文件夹不存在,自动创建文件夹
            if (!Directory.Exists(Configuration.GetSection("VirtualPath").GetValue <string>("File")))
            {
                Directory.CreateDirectory(Configuration.GetSection("VirtualPath").GetValue <string>("File"));
            }
            app.UseFileServer(new FileServerOptions()
            {
                FileProvider            = new PhysicalFileProvider(Configuration.GetSection("VirtualPath").GetValue <string>("File")),
                RequestPath             = "/file",
                EnableDirectoryBrowsing = false
            });
            Initialize.DbInit(dbc);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Esempio n. 3
0
 public static void DbInit(DwDbContext c)
 {
     c.Database.EnsureCreated();
     //c.Database.Migrate();
     c.SaveChanges();
 }
Esempio n. 4
0
 public ViewBaseController(DwDbContext dbc, ILoggerFactory logFac, IServiceProvider svp) : base(dbc, logFac, svp)
 {
 }
Esempio n. 5
0
 public BlogController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac)
 {
     _blogApi = new BlogApiController(dbc, logFac);
 }
Esempio n. 6
0
 //StackRedisHelper redis;
 public BlogApiController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac)
 {
     //redis = StackRedisHelper.Instance;
 }
Esempio n. 7
0
 public ApiBaseController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac)
 {
 }
Esempio n. 8
0
 public BaseController(DwDbContext dbc, ILoggerFactory logFac)
 {
     this.dbc = dbc;
     _log     = logFac.CreateLogger("seekerhut");
 }
Esempio n. 9
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, DwDbContext c)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            loggerFactory.AddNLog().AddDebug();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            //app.UseSession();
            app.UseWebSockets();
            IConfigurationSection redisConf = Configuration.GetSection("Redis");

            //StackRedisHelper.InitRedis(redisConf.GetValue<string>("ConnStr"), redisConf.GetValue<Int32>("Database"), redisConf.GetValue<string>("Name"));
            //如/file对应的文件夹不存在,自动创建文件夹
            if (!Directory.Exists(Configuration.GetSection("VirtualPath").GetValue <string>("File")))
            {
                Directory.CreateDirectory(Configuration.GetSection("VirtualPath").GetValue <string>("File"));
            }
            app.UseFileServer(new FileServerOptions()
            {
                FileProvider            = new PhysicalFileProvider(Configuration.GetSection("VirtualPath").GetValue <string>("File")),
                RequestPath             = "/file",
                EnableDirectoryBrowsing = false
            });

            app.UseStaticFiles();
            Initialize.DbInit(c);
            //app.UseErrorPage();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Esempio n. 10
0
 public HomeApiController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac)
 {
 }
Esempio n. 11
0
 public ErrorController(DwDbContext dbc, ILoggerFactory logFac) : base(dbc, logFac)
 {
 }
Esempio n. 12
0
 //protected StackRedisHelper redis;
 public BaseController(DwDbContext dbc, ILoggerFactory logFac, IServiceProvider svp)
 {
     this.dbc = dbc;
     _log     = logFac.CreateLogger("simpleproj");
     //redis = StackRedisHelper.Instance;
 }
Esempio n. 13
0
 public QuizController(DwDbContext dbc, ILoggerFactory logFac, IServiceProvider svp) : base(dbc, logFac, svp)
 {
     qac = new QuizApiController(dbc, logFac, svp);
 }