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)); }
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)); }
// 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?}"); }); }
public XhrResponse GetUpdateProgress([FromServices] DbMaintainer dbMaintainer) { var result = dbMaintainer.GetDbUpdateProgress(); return(XhrResponseFactory.CreateSucceeded(result)); }