using System.Data; using GB5Shared.GOP.Qualifier; using System.Reflection; using GB5Shared.Addon; using GB5Shared.DaprCache; using GB5Shared.DTO.Framework.CommonConfig; using GB5Shared.EntityHandler; using GB5Shared.EventLogPublish; using GB5Shared.GB5Library.Qualifier; using GB5Shared.GenerateAutoNumber; using GB5Shared.GOP.ExecuteAsync; using GB5Shared.Hosting; using GB5Shared.PubSub.OutBox; using GB5Shared.WorkFlow.WorkFlowEngine; using GB5Shared.WorkFlow.WorkFlowRunTime; using Microsoft.Data.SqlClient; using Npgsql; using static GB5Shared.DTO.Framework.Enum.FrameworkEnumDTO; namespace CMGMSL; public class CMGMModule : IModule { public string DisplayName => "CompetencyMgmt"; public void Register(IServiceCollection services, IConfiguration configuration) { AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); services.AddHttpClient(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(typeof(BaseEntityAppService<>), typeof(BaseEntityAppService<>)); services.AddScoped(); services.AddGB5QualifierEngine(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); var gb5Config = configuration.GetSection("Gb5SystemDTO").Get()!; var activeDbType = (DatabaseType)gb5Config.DataBaseType; services.AddSingleton(new DatabaseTypeConfig(activeDbType)); services.AddScoped(_ => { var connStr = gb5Config.ActiveConnectionString; return activeDbType switch { DatabaseType.SQL => (IDbConnection)new SqlConnection(connStr), DatabaseType.POSTGRE => (IDbConnection)new NpgsqlConnection(connStr), _ => throw new NotSupportedException($"DataBaseType '{gb5Config.DataBaseType}' not supported.") }; }); var cmgmBLLAssembly = Assembly.Load("CMGMBLL"); var cmgmDALAssembly = Assembly.Load("CMGMDAL"); var permDALAssembly = Assembly.Load("PERMDAL"); var skillDALAssembly = Assembly.Load("SkillManagementDAL"); services.Scan(scan => scan .FromAssemblies(cmgmBLLAssembly, cmgmDALAssembly, permDALAssembly, skillDALAssembly) .AddClasses(c => c.Where(t => !t.IsAbstract && !t.IsInterface && t.GetMethod("$") == null)) .AsImplementedInterfaces() .WithScopedLifetime()); } public void MapEndpoints(WebApplication app) { } }