| | 1 | | using ReportingServices.Shared.Repositories; |
| | 2 | | using Serilog; |
| | 3 | |
|
| 0 | 4 | | LoggerConfiguration loggerConfiguration = new(); |
| | 5 | |
|
| 0 | 6 | | var builder = WebApplication.CreateBuilder(args); |
| 0 | 7 | | Environment.SetEnvironmentVariable("workingDirectory", "C:/tmp/logging"); |
| 0 | 8 | | _ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, builder.Configuration); |
| 0 | 9 | | _ = SerilogHostBuilderExtensions.UseSerilog(builder.Host); |
| 0 | 10 | | Log.Logger = loggerConfiguration.CreateLogger(); |
| 0 | 11 | | Serilog.ILogger log = Log.ForContext<Program>(); |
| | 12 | |
|
| | 13 | |
|
| | 14 | | // Add services to the container. |
| 0 | 15 | | builder.Services.AddControllersWithViews(); |
| 0 | 16 | | builder.Services.AddScoped<IScrapeDatabaseRepository, ScrapeDatabaseRepository>(); |
| 0 | 17 | | builder.Services.AddScoped<IFabTimeReportingRepository, FabTimeReportingRepository>(); |
| | 18 | |
|
| 0 | 19 | | var app = builder.Build(); |
| | 20 | |
|
| | 21 | | // Configure the HTTP request pipeline. |
| 0 | 22 | | if (!app.Environment.IsDevelopment()) |
| 0 | 23 | | { |
| 0 | 24 | | app.UseExceptionHandler("/Home/Error"); |
| | 25 | | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspne |
| 0 | 26 | | app.UseHsts(); |
| 0 | 27 | | } |
| | 28 | |
|
| 0 | 29 | | app.UseHttpsRedirection(); |
| 0 | 30 | | app.UseStaticFiles(); |
| | 31 | |
|
| 0 | 32 | | app.UseRouting(); |
| | 33 | |
|
| 0 | 34 | | app.UseAuthorization(); |
| | 35 | |
|
| 0 | 36 | | app.MapControllerRoute( |
| 0 | 37 | | name: "default", |
| 0 | 38 | | pattern: "{controller=Home}/{action=Index}/{id?}"); |
| 0 | 39 | | _ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); |
| 0 | 40 | | log.Information("Starting Web Application"); |
| | 41 | | try |
| 0 | 42 | | { |
| 0 | 43 | | app.Run(); |
| 0 | 44 | | } |
| 0 | 45 | | catch (Exception ex) |
| 0 | 46 | | { |
| 0 | 47 | | log.Fatal(ex, "Host terminated unexpectedly"); |
| 0 | 48 | | } |
| | 49 | | finally |
| 0 | 50 | | { |
| 0 | 51 | | Log.CloseAndFlush(); |
| 0 | 52 | | } |