Ejemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            var config = CreateHttpConfiguration();

            AppSeed.RegisterAutoFac(config, app);
            AppSeed.RegisterStaticFile(app);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 申请App实例Id
        /// 置换token
        /// 获取远程配置
        /// </summary>
        private static void InitApp()
        {
            //获取AppId
            var config = AppSeed.GetAppLocalConfig();

            if (config.ActionResult)
            {
                if (config.Data.IsRemoteConfigRoot)//远程配置服务不执行App验证和实例获取
                {
                    AppSeed.Instance.InitConfig();
                    return;
                }

                int appId         = config.Data.AppID;
                int appInstanceId = config.Data.AppInstanceID;
                var urlParamater  = new Dictionary <string, string>();


                String response = null;
                urlParamater.Add("t", config.Data.SecurityToken);
                String strAppService = JsonHelper.Serlaize <List <AppService> >(GetAppService(appId));
                urlParamater.Add("appservice", strAppService);
                urlParamater.Add("appinstanceid", appInstanceId.ToString());
                response = HttpHelper.Transaction(ConfigHelper.Instance.GetComponentConfig().AppAuthServiceUrl, urlParamater);
                TransactionResult <AppAuthReponse> trAppService = JsonHelper.DeserializeSafe <TransactionResult <AppAuthReponse> >(response);
                if (trAppService.Code == 0)
                {
                    if (appInstanceId == 0)
                    {
                        appInstanceId = trAppService.Data.AppInstanceId;
                        AppSeed.SetAppInstanceId(appInstanceId);
                    }
                    config.Data.SecurityToken = trAppService.Data.AppInstanceToken;//将APP的Token置换为实例Token,但是不保存至文件中
                    AppSeed.Instance.InitConfig();
                    //初始化授权数据
                    SecurityRoot.Init(appId);
                    //启动心跳
                    Heart.Isntance.Start(config.Data.SecurityToken, appInstanceId, appId);
                }
                else
                {
                    throw new Exception(trAppService.Message);
                }
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
//            var host = new WebHostBuilder()
//             .UseContentRoot(Directory.GetCurrentDirectory())
//             .UseKestrel()
////             .UseKestrel(options =>
////             {
//// //                options.Listen(IPAddress.Loopback, 5001, listenOptions =>
///////                 {
//////                     listenOptions.UseHttps("testCert.pfx", "testPassword");
//////                     listenOptions.UseConnectionLogging();
//////                 });
////             })
//////             .UseIISIntegration()
//             .UseStartup<Startup>()
//             .Build();

//            host.Run();
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var ctx = services.GetRequiredService <ApplicationDbContext>();
                    ctx.Database.Migrate();

                    AppSeed.SeedAsync(services).Wait();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while attempting to seed data.");
                }
            }
            host.Run();
        }
Ejemplo 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, AppSeed seeder)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                seeder.SeedData().Wait();
                app.UseDeveloperExceptionPage();
                loggerFactory.AddDebug(LogLevel.Information);
            }

            Mapper.Initialize(config =>
            {
                config.CreateMap <UserViewModel, User>().ReverseMap();
            });

            app.UseStaticFiles();
            app.UseMvc(configureRoutes =>
            {
                configureRoutes.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "index" }
                    );
            });
        }
Ejemplo n.º 5
0
 protected override void Seed(ilac_etkilesimleri.TingoonDbContext db)
 {
     var appSeed = new AppSeed(db);
     //db.Database.Delete();
     //db.Database.Create();
 }