/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> public void Configure(IApplicationBuilder app /*, * IWebHostEnvironment env, * ILoggerFactory loggerFactory */) { Logger log = LogManager.GetLogger("Startup"); try { #region 确保数据库生成,并暖机 string dbconn = GConnStrings.PostgreSQLCoreDBConn; DbContextOptions <CoreContextDIP> opt = new DbContextOptions <CoreContextDIP>(); using (var db = new CoreContextDIP(opt)) { #if DEBUG db.Database.EnsureCreated(); #endif db.Accounts.FirstOrDefaultAsync(); db.Roles.FirstOrDefaultAsync(); db.RoutePages.FirstOrDefaultAsync(); db.RoutePageRoles.FirstOrDefaultAsync(); db.AccountRoles.FirstOrDefaultAsync(); //db.WarmUp(); } #endregion #region MVC 和WebAPI 相关 app.UseRouting(); #region 其他常用配置 app.UseHsts(); app.UseHttpsRedirection(); app.UseCookiePolicy(); app.UseCors(GWebVariable.CQRSPolicy); app.UseSession(this.GSessionOpts); app.UseAuthentication(); app.UseAuthorization(); app.UseMvc(); string path = Path.Combine(Directory.GetCurrentDirectory(), ".Cache"); app.UseStaticFiles ( new StaticFileOptions { FileProvider = new PhysicalFileProvider(path), RequestPath = "/Cache" } ); #endregion app.UseEndpoints(c => { //MVC c.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); // WebAPI c.MapControllerRoute("WebAPI", "api/{controller=Test}/{action=HelloNetCore}/{id?}"); // Area c.MapAreaControllerRoute(name: "Exam", areaName: "Exam", pattern: "Exam/{controller=home}/{action=index}"); }); app.UseEndpoints(c => { c.MapControllerRoute("default", "{controller=Home}/{action=Index}"); }); #endregion #region SingalR app.UseEndpoints(c => { c.MapHub <CommonHub>("/commonHub"); }); #endregion #region Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebCoreService"); }); #endregion } catch (Exception ex) { log.Error($" ============================= Error : { ex.Message } "); Debug.WriteLine($" ============================= Error : { ex.Message } "); Console.WriteLine($" ============================= Error : { ex.Message } "); } }
/// <summary> /// /// </summary> /// <param name="_db"></param> public ForumModuleDomain(CoreContextDIP _db, IForumModuleAccesser _accesser) { this.db = _db; this.accesser = _accesser; }
/// <summary> /// /// </summary> public ForumTopicDomain(CoreContextDIP _db, IForumTopicAccesser _accesser) { this.db = _db; this.accesser = _accesser; }
/// <summary> /// /// </summary> public AccountAccesser(CoreContextDIP _db) { db = _db; }