Initial commit: JDE Scoping Tool migration project
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using JdeScoping.Api;
|
||||
using JdeScoping.Core.Interfaces;
|
||||
using JdeScoping.Core.Options;
|
||||
using JdeScoping.DataAccess.Configuration;
|
||||
using JdeScoping.Database;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Windows Service support (no-op on non-Windows)
|
||||
builder.Host.UseWindowsService();
|
||||
|
||||
// Run database migrations (skip in Testing environment)
|
||||
if (!builder.Environment.IsEnvironment("Testing"))
|
||||
{
|
||||
var migrator = new DatabaseMigrator(builder.Configuration);
|
||||
var migrationResult = migrator.Migrate();
|
||||
|
||||
if (!migrationResult.Successful)
|
||||
{
|
||||
Console.WriteLine($"Database migration failed: {migrationResult.Error?.Message}");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// ASP.NET Core services
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
// Module registration (in dependency order)
|
||||
builder.Services
|
||||
.AddDataAccess(builder.Configuration) // 1. Database access + search processing
|
||||
.AddInfrastructure(builder.Configuration) // 2. Infrastructure (JDE/CMS/Auth)
|
||||
.AddDataSyncServices(builder.Configuration) // 3. Data sync background service
|
||||
.AddExcelIO(builder.Configuration) // 4. Result export
|
||||
.AddWebApi(builder.Configuration); // 5. Web API (controllers, auth, SignalR)
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Startup validation - verify critical services are registered
|
||||
ValidateServices(app.Services);
|
||||
|
||||
// Configure the HTTP request pipeline
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseWebAssemblyDebugging();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseBlazorFrameworkFiles();
|
||||
app.UseRouting();
|
||||
|
||||
// Configure Web API middleware (authentication, authorization, controllers, SignalR hub)
|
||||
app.UseWebApi();
|
||||
|
||||
app.MapRazorPages();
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
|
||||
// Validates that critical services are properly registered
|
||||
static void ValidateServices(IServiceProvider services)
|
||||
{
|
||||
using var scope = services.CreateScope();
|
||||
var provider = scope.ServiceProvider;
|
||||
|
||||
// Validate Options classes are bound
|
||||
_ = provider.GetRequiredService<IOptions<DataAccessOptions>>();
|
||||
_ = provider.GetRequiredService<IOptions<DataSyncOptions>>();
|
||||
_ = provider.GetRequiredService<IOptions<JdeScoping.DataSync.Configuration.DataSyncOptions>>();
|
||||
_ = provider.GetRequiredService<IOptions<ExcelExportOptions>>();
|
||||
_ = provider.GetRequiredService<IOptions<SearchProcessingOptions>>();
|
||||
_ = provider.GetRequiredService<IOptions<DataSourceOptions>>();
|
||||
|
||||
// Validate data source services
|
||||
_ = provider.GetRequiredService<IJdeDataSource>();
|
||||
_ = provider.GetRequiredService<ICmsDataSource>();
|
||||
|
||||
Console.WriteLine("Service validation completed successfully.");
|
||||
}
|
||||
Reference in New Issue
Block a user