2018-09-21 20:23:31 +02:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2018-09-26 12:32:50 +02:00
|
|
|
using Result.Data;
|
2018-09-21 20:23:31 +02:00
|
|
|
using Result.Hubs;
|
2018-09-26 11:29:39 +02:00
|
|
|
using Result.Timers;
|
2018-09-21 20:23:31 +02:00
|
|
|
|
|
|
|
namespace Result
|
|
|
|
{
|
|
|
|
public class Startup
|
|
|
|
{
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
|
|
|
services.AddSignalR();
|
2018-09-26 12:32:50 +02:00
|
|
|
|
|
|
|
services.AddTransient<IResultData, MySqlResultData>()
|
|
|
|
.AddSingleton<PublishResultsTimer>();
|
2018-09-21 20:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
|
|
|
{
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
app.UseExceptionHandler("/Error");
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseSignalR(routes =>
|
|
|
|
{
|
|
|
|
routes.MapHub<ResultsHub>("/resultsHub");
|
|
|
|
});
|
|
|
|
app.UseMvc();
|
2018-09-26 11:29:39 +02:00
|
|
|
|
|
|
|
var timer = app.ApplicationServices.GetService<PublishResultsTimer>();
|
|
|
|
timer.Start();
|
2018-09-21 20:23:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|