using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using CZFW.Core; using CZFW.Framework; using CZFW.Framework.Logic; using CZFW.Framework.Model; using CZFW.Logger; using CZKJ.GBRS2.Web.AppCode; using log4net; using log4net.Config; using log4net.Repository; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; namespace CZKJ.GBRS2.Web { public class Startup { public static ILoggerRepository repository { get; set; } public Startup(IConfiguration configuration) { Configuration = configuration; ConfigHelper.Configs = Configuration; repository = LogManager.CreateRepository("NetCoreRepository"); XmlConfigurator.Configure(repository, new FileInfo("log4net.config")); InitRepository.loggerRepository = repository; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext(); services.AddMvc(o => o.Filters.Add(typeof(GlobalExceptions))); services.AddSession(); services.ConfigServies(); services.AddLogging(); services.AddMemoryCache(); services.AddLogging(); services.ConfigureFrameworkServices(); CZHttpContext.ServiceProvider = services.BuildServiceProvider(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseSession(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "araas", template: "{area=exists}/{controller=Home}/{action=Index}/{id?}" ); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } } }