using System.Reflection; using AnalyticsBLL.OEE; using GB5Shared.Hosting; using GB5Shared.ListQuery; namespace AnalyticsSL; public class AnalyticsModule : IModule { public void Register(IServiceCollection services, IConfiguration configuration) { services.AddHttpClient(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddHostedService(); // SwBLL.ClientDatabase.ClientDatabaseBLL / SwBLL.Provisioning.TargetDbExecutor's own DI // graph (used by the wizard's execution-routing/DataSource validation paths) needs these — // same registration as SwSL/SwModule.cs, needed here because BusinessHost hosts Analytics, // not SqlWorkbench, so PlatformHost's own copy of this registration never runs for it. services.Configure( configuration.GetSection(SwBLL.Provisioning.SqlServerProvisioningOptions.SectionName)); services.AddSingleton(sp => { var authMethod = new VaultSharp.V1.AuthMethods.Token.TokenAuthMethodInfo(configuration["Vault:Token"]!); var settings = new VaultSharp.VaultClientSettings(configuration["Vault:Address"]!, authMethod); return new VaultSharp.VaultClient(settings); }); var analyticsBLLAssembly = Assembly.Load("AnalyticsBLL"); var analyticsDALAssembly = Assembly.Load("AnalyticsDAL"); // Analytics Catalog Wizard + execution-routing depend on Framework's schema-introspection/ // DBObject services and SqlWorkbench's target-DB executor/client-database services — // ProjectReference alone gets these to compile, but this module's own DI scan is what // BusinessHost actually uses to resolve them at runtime, so they must be listed here too // (see MMModule's identical AdminBLL/AdminDAL scan for the established precedent). var frameworkBLLAssembly = Assembly.Load("FrameworkBLL"); var frameworkDALAssembly = Assembly.Load("FrameworkDAL"); var swBLLAssembly = Assembly.Load("SwBLL"); var swDALAssembly = Assembly.Load("SwDAL"); // IDBObjectBLL/IOwnDbSchemaBLL (Analytics Catalog Wizard schema introspection + DBOBJECT // registration) moved from FrameworkBLL into GB5Shared — must scan GB5Shared too or these // fail to resolve at runtime, same class of gap as the FrameworkBLL/FrameworkDAL lines above. var gb5SharedAssembly = Assembly.Load("GB5Shared"); services.Scan(scan => scan .FromAssemblies(analyticsBLLAssembly, analyticsDALAssembly, frameworkBLLAssembly, frameworkDALAssembly, swBLLAssembly, swDALAssembly, gb5SharedAssembly) .AddClasses(c => c.Where(t => !t.IsAbstract && !t.IsInterface && !typeof(Microsoft.Extensions.Hosting.IHostedService).IsAssignableFrom(t))) .AsImplementedInterfaces() .WithScopedLifetime()); // ClientDatabaseBLL (used by the wizard's execution-routing/DataSource validation paths) // needs IListHandler — SwModule.cs // registers this for PlatformHost via the same call; BusinessHost needs its own copy // since it hosts Analytics, not SqlWorkbench itself. services.AddListInfrastructure(swDALAssembly); } public void MapEndpoints(WebApplication app) { } }