using System.Collections; using Autofac; using CMS.Data.Stressing; using CMS.DataPersistence; using CMS.DataPersistence.Data; using CMS.Extensions.Abp.Autofac.Extensions.DependencyInjection; using CMS.Plugin.MesSuite.Abstractions; using CMS.Plugin.MesSuite.Abstractions.Consts; using CMS.Plugin.PipeLineLems.Abstractions; using CMS.Plugin.PipeLineLems.Apis; using CMS.Plugin.PipeLineLems.Domain; using CMS.Plugin.PipeLineLems.ProjectService; using CMS.Plugin.PipeLineLems.Workers; using CMS.Plugin.PipeLineLems.Apis; using CMS.Project.Abstractions; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Structing.AspNetCore; using Structing.Core; using Structing.Web; using SYC.Plugin; using Volo.Abp.BackgroundWorkers; using Volo.Abp.DependencyInjection; using Volo.Abp.Modularity.PlugIns; using CMS.Plugin.PipeLineLems.Application.Contracts.Services; using CMS.Plugin.PipeLineLems.Application.Implements; namespace CMS.Plugin.PipeLineLems; /// /// CMS插件入口,使用将导入Controller. /// [EnableApplicationPart] public class CMSPluginEntry : PluginEntry { private readonly IServiceCollection _service = new ServiceCollection(); /// public override void Register(IRegisteContext context) { var configuration = context.Features.GetConfiguration(); // 配置外部HttpApi: https://webapiclient.github.io/ context.Services .AddHttpApi() .ConfigureHttpApi(configuration.GetSection(nameof(IPipeLineLemsExternalApi))); context.Services.TryAddPipeLineLems(); context.Services.AddScoped(); context.Services.AddSingleton(); //context.Services.AddScoped(); context.Services.AddScoped(p => { var cfg = p.GetRequiredService(); return new DefaultEFDataProvider(CMSPluginMesSuiteOptions.DataProviderName, CMSPluginMesSuiteOptions.GetDatabaseSuffix(CMSPluginDbProperties.MigrationsHistoryTable), CMSPluginDbProperties.MigrationsHistoryTable, cfg); }); _service.AddObjectAccessor(); _service.AddApplication(options => { var databaseType = configuration[SectionName.DatabaseType] ?? "mysql"; if (KnowsDbCode.IsMysql(databaseType)) { options.PlugInSources.Add(new TypePlugInSource( typeof(MySQL.CMSPluginMySQLModule) )); } else if (KnowsDbCode.IsSqlServer(databaseType)) { options.PlugInSources.Add(new TypePlugInSource( typeof(SqlServer.CMSPluginSqlServerModule) )); } else if (KnowsDbCode.IsPostgreSql(databaseType)) { options.PlugInSources.Add(new TypePlugInSource( typeof(PostgreSql.CMSPluginPostgreSqlModule) )); } }); base.Register(context); } /// public override void ConfigureContainer(ContainerBuilder builder) { builder.Populate(_service); base.ConfigureContainer(builder); } /// public override async Task ReadyAsync(IReadyContext context) { context.Provider.GetRequiredService>().Value = context.Features.GetApplicationBuilder(); var app = context.Features.GetApplicationBuilder(); await app.InitializeApplicationAsync(); await base.ReadyAsync(context); } /// public override async Task AfterReadyAsync(IReadyContext context) { await context.GetRequiredService().AddAsync(context.GetRequiredService()); await base.AfterReadyAsync(context); } }