/// <summary> /// Sucht nach neuen Ausgaben /// Und löscht den Cache /// </summary> /// <returns></returns> private async void CheckNewIssues(ComicDBContext comicDB) { try { var checkData = comicDB.CheckData.ToList(); var controller = new DataController(comicDB); foreach (var check in checkData) { var volume = await controller.GetVolume(check.VolumeId); if (check.LastCount != volume.IssueCount) { check.LastCount = volume.IssueCount; check.HasNew = true; } } comicDB.SaveChanges(); //Cache aufräumen foreach (var file in Directory.GetFiles("Cache")) { File.Delete(file); } } catch (Exception ex) { } }
public DataController(ComicDBContext comicDB) { this._comicDB = comicDB; }
public VillainsController(ComicDBContext context) { _context = context; }
public TeamsController(ComicDBContext context) { _context = context; }
public HeroesController(ComicDBContext context) { _context = context; }
// 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, ComicDBContext comicDB) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseResponseCompression(); comicDB.Database.Migrate(); //CheckService var state = new object(); Startup.DataTimer = new Timer((s) => { CheckNewIssues(comicDB); }, state, 24 * 60 * 60 * 1000, 24 * 60 * 60 * 1000); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // Für Debug caches deaktivieren app.UseStaticFiles(new StaticFileOptions() { OnPrepareResponse = context => { context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store"); context.Context.Response.Headers.Add("Expires", "-1"); } }); // node_modules verfügbar machen app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"node_modules")), RequestPath = new PathString("/node_modules"), }); } else { app.UseExceptionHandler("/Home/Error"); // Live mit richtigen Caches app.UseStaticFiles(new StaticFileOptions() { OnPrepareResponse = context => { if (!StringValues.IsNullOrEmpty(context.Context.Response.Headers[HeaderNames.AcceptEncoding])) { context.Context.Response.Headers.Append(HeaderNames.Vary, HeaderNames.AcceptEncoding); } context.Context.Response.Headers.Add("Cache-Control", "public,max-age=" + 60 * 60 * 24); } }); // Dist verfügbar machen app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"dist")), RequestPath = new PathString("/dist"), OnPrepareResponse = context => { if (!StringValues.IsNullOrEmpty(context.Context.Response.Headers[HeaderNames.AcceptEncoding])) { context.Context.Response.Headers.Append(HeaderNames.Vary, HeaderNames.AcceptEncoding); } context.Context.Response.Headers.Add("Cache-Control", "public,max-age=" + 60 * 60 * 24); } }); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "angular", template: "{action=Index}", defaults: new { controller = "Home" }); }); }