Пример #1
0
        public async Task ImportAll()
        {
            uSyncBackOfficeContext.Instance.Init();

            await Out.WriteLineAsync("Importing all migration changes from disk");
            var migrationManager = new MigrationManager("~/usync/migrations/");

            var actions = migrationManager.ApplyMigrations();
            if (actions.Any(x => x.Change > ChangeType.NoChange))
            {
                await Out.WriteLineAsync(
                    string.Format("Migrations Imported {0} items, {1} changes",
                        actions.Count(), actions.Count(x => x.Change > ChangeType.NoChange
                    )));

                foreach(var action in actions.Where(x => x.Change > ChangeType.NoChange))
                {
                    await Out.WriteLineAsync(
                        string.Format("{0,-30}, {1,10} {2}", action.Name, action.Change, action.Message));
                }
            }
            else
            {
                await Out.WriteLineAsync(
                    string.Format("{0} items processed, but no changes where made", actions.Count()));
            }

        }
Пример #2
0
        public async Task ImportAll()
        {
            uSyncBackOfficeContext.Instance.Init();

            await Out.WriteLineAsync("Importing all migration changes from disk");

            var migrationManager = new MigrationManager("~/usync/migrations/");

            var actions = migrationManager.ApplyMigrations();

            if (actions.Any(x => x.Change > ChangeType.NoChange))
            {
                await Out.WriteLineAsync(
                    string.Format("Migrations Imported {0} items, {1} changes",
                                  actions.Count(), actions.Count(x => x.Change > ChangeType.NoChange
                                                                 )));

                foreach (var action in actions.Where(x => x.Change > ChangeType.NoChange))
                {
                    await Out.WriteLineAsync(
                        string.Format("{0,-30}, {1,10} {2}", action.Name, action.Change, action.Message));
                }
            }
            else
            {
                await Out.WriteLineAsync(
                    string.Format("{0} items processed, but no changes where made", actions.Count()));
            }
        }
Пример #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            MigrationManager.ApplyMigrations();

            SetupIoc();
        }
Пример #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, BasicSeedManager seedManager, MigrationManager migrationManager)
        {
            var stopwatch = Stopwatch.StartNew();

            try
            {
                loggerFactory.AddSerilog();

                Log.Logger().Information("Application is starting...");
                Log.Logger().Information("Configuration:");

                ConfigurationProvider.GetType().GetProperties().ToList().ForEach(prop =>
                {
                    Log.Logger().Information("[{name}] = '{value}'", prop.Name,
                                             prop.GetValue(ConfigurationProvider));
                });

                DateTimeContext.Initialize(ConfigurationProvider.TimeZone);

                Log.Logger().Information("Configure EF Mappings...");
                MappingConfig.RegisterMappings();


                Log.Logger().Information("Configure Jwt Bearer Authentication...");
                app.ConfigJwtBearerMiddleware();

                app.UseDefaultFiles();
                app.UseStaticFiles();

                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Default}/{action=Index}/{id?}");

                    routes.MapRoute(
                        name: "admin",
                        template: "{*url}",
                        defaults: new { controller = "Default", action = "Index" }
                        );
                });



                //app.Use(async (context, next) =>
                //{
                //  await next();
                //  if (context.Response.StatusCode == 404 &&
                //      !Path.HasExtension(context.Request.Path.Value) &&
                //      !context.Request.Path.Value.StartsWith("/api/"))
                //  {
                //    context.Request.Path = "/index.html";
                //    await next();
                //  }
                //});

                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();

                    migrationManager.ApplyMigrations(ConfigurationProvider);

                    //seedManager.Seed();
                }
                else
                {
                    app.UseExceptionHandler("/error");
                }
            }
            catch (Exception e)
            {
                Log.Logger().Error(e, "Application failed to start");
                throw;
            }
            finally
            {
                stopwatch.Stop();
                Log.Logger().Information("Startup time: {Seconds}s", stopwatch.Elapsed.Seconds);
            }
        }