using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.EntityFrameworkCore; using Hangfire; using Hangfire.MySql.Core; using Database; using Main.Jobs; namespace Main { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.Configure(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext(options => { options.UseMySQL(Configuration.GetConnectionString("Storage")); }); services.AddScoped(); services.AddHangfire(options => options.UseStorage(new MySqlStorage(Configuration.GetConnectionString("Storage")))); services.AddDirectoryBrowser(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAggregatorJob aggregator) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseHangfireServer(); app.UseHangfireDashboard(); RecurringJob.AddOrUpdate("aggregator", () => aggregator.Start(), Cron.HourInterval(3)); } } }