using System.Reflection; using AutomationBLL.Run; using AutomationSL.Hubs; using GB5Shared.Hosting; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace AutomationSL; public class AutomationModule : IModule { public void Register(IServiceCollection services, IConfiguration configuration) { // Used by IJobEngineScheduleClient to sync TSCHEDULE rows to JobEngine's Quartz scheduler // over HTTP rather than a direct BLL reference — see JobEngineScheduleClient.cs. services.AddHttpClient("jobengine"); // Used by IAckCallbackClient to POST the acknowledgement writeback to whichever module's // API TAUTOMATIONEVENTMAP.ACKCALLBACKURL points at. services.AddHttpClient("ackcallback"); // AutomationRunHub — live log tail for RunDetailComponent, mirrors MMModule.cs's real // AddSignalR wiring (MRPRunHub/SchedulingRunHub/OperatorConsoleHub). services.AddSignalR(options => { options.EnableDetailedErrors = true; options.MaximumReceiveMessageSize = 32 * 1024; options.ClientTimeoutInterval = TimeSpan.FromSeconds(60); options.KeepAliveInterval = TimeSpan.FromSeconds(15); }); // IHubContext is Singleton and thread-safe — safe to register the notifier as Singleton // too, mirroring GopHubNotifier's registration exactly. services.Scan below only scans // AutomationBLL/AutomationDAL, not this module's own assembly, so the SL-side implementation // needs this explicit registration. services.AddSingleton(); var bll = Assembly.Load("AutomationBLL"); var dal = Assembly.Load("AutomationDAL"); services.Scan(scan => scan .FromAssemblies(bll, dal) .AddClasses(c => c.Where(t => !t.IsAbstract && !t.IsInterface && !t.Name.EndsWith("ListDTO") && !t.Name.EndsWith("DTO"))) .AsImplementedInterfaces() .WithScopedLifetime()); } public void MapEndpoints(WebApplication app) { app.MapHub("/hubs/automation-run"); } }