Example #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime lifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            //日志
            //loggerFactory.AddNLog();
            //env.ConfigureNLog("nlog.config");

            //验证中间件
            app.UseAuthentication();

            //初始化数据库连接
            DbInitData initdata = new DbInitData
            {
                DbName       = Configuration["DbConfig:DbName"],
                Ip           = Configuration["DbConfig:Ip"],
                ProviderName = Configuration["DbConfig:ProviderName"],
                Pwd          = Configuration["DbConfig:Pwd"],
                UserName     = Configuration["DbConfig:UserName"]
            };

            DbFactory.DbInit = initdata;

            app.UseMvc();
            //consul
            app.RegisterWithConsul(lifetime, Configuration);//here
        }
Example #2
0
 public static IDataConnection InitDataBase(DbInitData data = null)
 {
     if (data == null)
     {
         data = DbInit;
     }
     switch (data.ProviderName)
     {
     case "MsSql":
         DataConnection = new MsSqlDataAccess(data);
         break;
     }
     return(DataConnection);
 }