Refactor, update deps

This commit is contained in:
Laura Hausmann 2023-01-24 18:52:32 +01:00
parent 3ef7971fec
commit ec1a9a5216
Signed by: zotan
GPG Key ID: D044E84C5BE01605
5 changed files with 52 additions and 87 deletions

View File

@ -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();

View File

@ -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();
});
}
}

View File

@ -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");
}

View File

@ -28,10 +28,10 @@ public class Database {
public class DbConn : DataConnection {
public DbConn() : base("db") { }
public ITable<DbInfo> DbInfo => GetTable<DbInfo>();
public ITable<DbInfo> DbInfo => this.GetTable<DbInfo>();
public ITable<User> Users => GetTable<User>();
public ITable<Leg> Legs => GetTable<Leg>();
public ITable<Trip> Trips => GetTable<Trip>();
public ITable<User> Users => this.GetTable<User>();
public ITable<Leg> Legs => this.GetTable<Leg>();
public ITable<Trip> Trips => this.GetTable<Trip>();
}
}

View File

@ -30,14 +30,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="18.0.0" />
<PackageReference Include="CsvHelper" Version="19.0.0" />
<PackageReference Include="Ical.Net" Version="4.2.0" />
<PackageReference Include="linq2db" Version="3.2.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.2" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="linq2db" Version="4.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.2" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
</ItemGroup>
</Project>