Ejemplo n.º 1
0
        public XhrResponse DbCleanup([FromServices] DbMaintainer dbMaintainer)
        {
            if (dbMaintainer.IsDbUpdateRunning)
            {
                return(XhrResponseFactory.CreateError("Already Refreshing."));
            }

            var task = dbMaintainer.Update(DbMaintainer.UpdateType.Cleanup);

            return(XhrResponseFactory.CreateSucceeded(true));
        }
Ejemplo n.º 2
0
        public XhrResponse DbScanNew([FromServices] DbMaintainer dbMaintainer)
        {
            if (dbMaintainer.IsDbUpdateRunning)
            {
                return(XhrResponseFactory.CreateError("Already Updating."));
            }

            var task = dbMaintainer.Update(DbMaintainer.UpdateType.ScanNew);

            return(XhrResponseFactory.CreateSucceeded(true));
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IApplicationLifetime applicationLifetime,
            IHostingEnvironment env
            )
        {
            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                using (var dbEnsurer = serviceScope.ServiceProvider.GetService <DbEnsurer>())
                {
                    dbEnsurer.Ensure();
                    this._dbMaintainer = serviceScope.ServiceProvider.GetService <DbMaintainer>();
                }

            // アプリケーション起動/終了をハンドルする。
            // https://stackoverflow.com/questions/41675577/where-can-i-log-an-asp-net-core-apps-start-stop-error-events
            applicationLifetime.ApplicationStarted.Register(this.OnStarted);
            applicationLifetime.ApplicationStopping.Register(this.OnShutdown);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 4
0
        public XhrResponse GetUpdateProgress([FromServices] DbMaintainer dbMaintainer)
        {
            var result = dbMaintainer.GetDbUpdateProgress();

            return(XhrResponseFactory.CreateSucceeded(result));
        }