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.AddHangfire(options => options.UseStorage(new MySqlStorage(Configuration.GetConnectionString("Storage")))); services.AddDirectoryBrowser(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseHangfireServer(); app.UseHangfireDashboard(); RecurringJob.AddOrUpdate( x => x.Start(Configuration.GetConnectionString("Aggregator")), Cron.HourInterval(3) ); } } }