2025-01-03 16:21:03 +00:00
|
|
|
|
using Autofac;
|
2025-02-02 23:13:17 +01:00
|
|
|
|
using Core.Configurations.JsonConfigProvider;
|
|
|
|
|
|
using Core.Configurations;
|
2025-02-05 18:38:29 +01:00
|
|
|
|
|
2025-01-03 16:21:03 +00:00
|
|
|
|
namespace PlanTempus
|
|
|
|
|
|
{
|
2025-02-02 23:13:17 +01:00
|
|
|
|
public class Startup
|
|
|
|
|
|
{
|
|
|
|
|
|
public Startup(IWebHostEnvironment env)
|
|
|
|
|
|
{
|
|
|
|
|
|
var builder = new Core.Configurations.ConfigurationBuilder()
|
|
|
|
|
|
.AddJsonFile("appconfiguration.json", optional: true, reloadOnChange: true);
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
ConfigurationRoot = builder.Build();
|
|
|
|
|
|
}
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
public Core.Configurations.IConfigurationRoot ConfigurationRoot { get; private set; }
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
public ILifetimeScope AutofacContainer { get; private set; }
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
|
{
|
2025-01-03 16:21:03 +00:00
|
|
|
|
services.AddControllers();
|
2025-02-02 23:13:17 +01:00
|
|
|
|
services.AddOptions();
|
|
|
|
|
|
services.AddRazorPages();
|
|
|
|
|
|
//services.AddApplicationInsightsTelemetry(ConfigurationRoot["ApplicationInsights:InstrumentationKey"]);
|
|
|
|
|
|
services.AddAntiforgery(x => x.HeaderName = "X-ANTI-FORGERY-TOKEN");
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-01-14 23:10:30 +01:00
|
|
|
|
services.Configure<Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions>(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.ViewLocationExpanders.Add(new Application.Common.ComponentsViewLocationExpander());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-02-02 23:13:17 +01:00
|
|
|
|
public void ConfigureContainer(ContainerBuilder builder)
|
|
|
|
|
|
{
|
|
|
|
|
|
builder.RegisterModule(new Core.ModuleRegistry.DbPostgreSqlModule
|
|
|
|
|
|
{
|
|
|
|
|
|
ConnectionString = ConfigurationRoot.GetConnectionString("ptdb")
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule
|
|
|
|
|
|
{
|
|
|
|
|
|
TelemetryConfig = ConfigurationRoot.GetSection(nameof(Core.ModuleRegistry.TelemetryConfig)).Get<Core.ModuleRegistry.TelemetryConfig>()
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
|
|
{
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
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.UseRouting();
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
|
|
{
|
|
|
|
|
|
//endpoints.MapHub<MotionHub>("/motionhub");
|
|
|
|
|
|
endpoints.MapRazorPages();
|
|
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
|
});
|
2025-01-03 16:21:03 +00:00
|
|
|
|
|
2025-02-02 23:13:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 16:21:03 +00:00
|
|
|
|
}
|