Refactor, update deps
parent
3ef7971fec
commit
ec1a9a5216
@ -1,24 +1,55 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using LinqToDB.Common;
|
||||
using LinqToDB.Data;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using trainav.web;
|
||||
using trainav.web.database;
|
||||
|
||||
namespace trainav.web;
|
||||
DataConnection.DefaultSettings = new Database.Settings();
|
||||
|
||||
public class Program {
|
||||
public static void Main(string[] args) {
|
||||
DataConnection.DefaultSettings = new Database.Settings();
|
||||
Configuration.Linq.AllowMultipleQuery = true;
|
||||
Directory.CreateDirectory(Variables.TicketDir);
|
||||
ThreadPool.SetMinThreads(100, 100);
|
||||
Migrations.RunMigrations();
|
||||
|
||||
Migrations.RunMigrations();
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddSession(options => {
|
||||
options.IdleTimeout = TimeSpan.MaxValue;
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
});
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
|
||||
}
|
||||
#if (DEBUG)
|
||||
builder.Services.AddControllers().AddRazorRuntimeCompilation();
|
||||
builder.Services.AddControllers();
|
||||
#else
|
||||
builder.Services.AddControllers();
|
||||
#endif
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment()) {
|
||||
app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseSession();
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints => {
|
||||
endpoints.MapRazorPages();
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
|
||||
app.Run();
|
||||
|
@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace trainav.web;
|
||||
|
||||
public class Startup {
|
||||
public Startup(IConfiguration configuration) => Configuration = configuration;
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services) {
|
||||
services.AddRazorPages();
|
||||
services.AddSession(options => {
|
||||
options.IdleTimeout = TimeSpan.MaxValue;
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
});
|
||||
#if (DEBUG)
|
||||
services.AddControllers().AddRazorRuntimeCompilation();
|
||||
services.AddControllers();
|
||||
#else
|
||||
services.AddControllers();
|
||||
#endif
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
|
||||
if (env.IsDevelopment()) {
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else {
|
||||
app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseSession();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints => {
|
||||
endpoints.MapRazorPages();
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace trainav.web;
|
||||
|
||||
public class Variables {
|
||||
public const string DataDir = "data";
|
||||
public static readonly string TicketDir = Path.Combine(DataDir, "tickets");
|
||||
}
|
Loading…
Reference in New Issue