diff --git a/Directory.Build.Microsoft.targets b/Directory.Build.Microsoft.targets new file mode 100644 index 0000000..a7050c4 --- /dev/null +++ b/Directory.Build.Microsoft.targets @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Directory.Build.Volo.targets b/Directory.Build.Volo.targets new file mode 100644 index 0000000..7af4c34 --- /dev/null +++ b/Directory.Build.Volo.targets @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..d88a5d6 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,154 @@ + + + + + + + latest + 1.0.1 + JiShe Service Pro + $(NoWarn);CS1591;CS0436;NU1504 + app + true + 湖南集社电子技术有限公司 + true + icon.png + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj b/modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj index 66b1fcf..31fb4f1 100644 --- a/modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj +++ b/modules/JiShe.CollectBus.Analyzers/JiShe.CollectBus.Analyzers.csproj @@ -12,8 +12,8 @@ true - - + + diff --git a/modules/JiShe.CollectBus.Cassandra/JiShe.CollectBus.Cassandra.csproj b/modules/JiShe.CollectBus.Cassandra/JiShe.CollectBus.Cassandra.csproj index a3360e3..c7fbb47 100644 --- a/modules/JiShe.CollectBus.Cassandra/JiShe.CollectBus.Cassandra.csproj +++ b/modules/JiShe.CollectBus.Cassandra/JiShe.CollectBus.Cassandra.csproj @@ -1,17 +1,18 @@  - net8.0 + net9.0 enable enable - - - - - + + + + + + diff --git a/modules/JiShe.CollectBus.FreeRedis/JiShe.CollectBus.FreeRedis.csproj b/modules/JiShe.CollectBus.FreeRedis/JiShe.CollectBus.FreeRedis.csproj index 92b3223..e985649 100644 --- a/modules/JiShe.CollectBus.FreeRedis/JiShe.CollectBus.FreeRedis.csproj +++ b/modules/JiShe.CollectBus.FreeRedis/JiShe.CollectBus.FreeRedis.csproj @@ -1,13 +1,13 @@  - net8.0 + net9.0 enable enable - - + + diff --git a/modules/JiShe.CollectBus.FreeSql/JiShe.CollectBus.FreeSql.csproj b/modules/JiShe.CollectBus.FreeSql/JiShe.CollectBus.FreeSql.csproj index 9b40553..9b5355c 100644 --- a/modules/JiShe.CollectBus.FreeSql/JiShe.CollectBus.FreeSql.csproj +++ b/modules/JiShe.CollectBus.FreeSql/JiShe.CollectBus.FreeSql.csproj @@ -1,13 +1,13 @@  - net8.0 + net9.0 enable enable - - - + + + diff --git a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj index 78b81e3..7c368f2 100644 --- a/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj +++ b/modules/JiShe.CollectBus.IoTDB/JiShe.CollectBus.IoTDB.csproj @@ -1,13 +1,13 @@  - net8.0 + net9.0 enable enable - - + + diff --git a/modules/JiShe.CollectBus.Kafka.Test/JiShe.CollectBus.Kafka.Test.csproj b/modules/JiShe.CollectBus.Kafka.Test/JiShe.CollectBus.Kafka.Test.csproj index c312740..61f3e77 100644 --- a/modules/JiShe.CollectBus.Kafka.Test/JiShe.CollectBus.Kafka.Test.csproj +++ b/modules/JiShe.CollectBus.Kafka.Test/JiShe.CollectBus.Kafka.Test.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable @@ -16,14 +16,14 @@ - - - - - - - - + + + + + + + + diff --git a/modules/JiShe.CollectBus.Kafka.Test/KafkaProduceBenchmark.cs b/modules/JiShe.CollectBus.Kafka.Test/KafkaProduceBenchmark.cs index 4152a33..155b074 100644 --- a/modules/JiShe.CollectBus.Kafka.Test/KafkaProduceBenchmark.cs +++ b/modules/JiShe.CollectBus.Kafka.Test/KafkaProduceBenchmark.cs @@ -19,7 +19,7 @@ using System.Threading.Tasks; namespace JiShe.CollectBus.Kafka.Test { - [SimpleJob(RuntimeMoniker.Net80)] + [SimpleJob(RuntimeMoniker.Net90)] //[SimpleJob(RuntimeMoniker.NativeAot80)] [RPlotExporter] public class KafkaProduceBenchmark diff --git a/modules/JiShe.CollectBus.Kafka.Test/TestService.cs b/modules/JiShe.CollectBus.Kafka.Test/TestService.cs new file mode 100644 index 0000000..04dd8ed --- /dev/null +++ b/modules/JiShe.CollectBus.Kafka.Test/TestService.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JiShe.CollectBus.Kafka.Test +{ + public class TestService + { + + public void Test() + { + Console.WriteLine("测试动态注入"); + } + } +} diff --git a/modules/JiShe.CollectBus.Kafka/JiShe.CollectBus.Kafka.csproj b/modules/JiShe.CollectBus.Kafka/JiShe.CollectBus.Kafka.csproj index a0fd2f7..b955229 100644 --- a/modules/JiShe.CollectBus.Kafka/JiShe.CollectBus.Kafka.csproj +++ b/modules/JiShe.CollectBus.Kafka/JiShe.CollectBus.Kafka.csproj @@ -1,17 +1,17 @@  - net8.0 + net9.0 enable enable - - - - - + + + + + diff --git a/modules/JiShe.CollectBus.MongoDB/JiShe.CollectBus.MongoDB.csproj b/modules/JiShe.CollectBus.MongoDB/JiShe.CollectBus.MongoDB.csproj index 2987d33..82ee2f5 100644 --- a/modules/JiShe.CollectBus.MongoDB/JiShe.CollectBus.MongoDB.csproj +++ b/modules/JiShe.CollectBus.MongoDB/JiShe.CollectBus.MongoDB.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable JiShe.CollectBus @@ -12,11 +12,11 @@ - - - - + + + + diff --git a/protocols/JiShe.CollectBus.Protocol.T1882018/JiShe.CollectBus.Protocol.T1882018.csproj b/protocols/JiShe.CollectBus.Protocol.T1882018/JiShe.CollectBus.Protocol.T1882018.csproj index 0f8d650..400c849 100644 --- a/protocols/JiShe.CollectBus.Protocol.T1882018/JiShe.CollectBus.Protocol.T1882018.csproj +++ b/protocols/JiShe.CollectBus.Protocol.T1882018/JiShe.CollectBus.Protocol.T1882018.csproj @@ -1,15 +1,15 @@  - net8.0 + net9.0 enable enable - - - + + + diff --git a/protocols/JiShe.CollectBus.Protocol.T37612012/JiShe.CollectBus.Protocol.T37612012.csproj b/protocols/JiShe.CollectBus.Protocol.T37612012/JiShe.CollectBus.Protocol.T37612012.csproj index e83c165..6207b54 100644 --- a/protocols/JiShe.CollectBus.Protocol.T37612012/JiShe.CollectBus.Protocol.T37612012.csproj +++ b/protocols/JiShe.CollectBus.Protocol.T37612012/JiShe.CollectBus.Protocol.T37612012.csproj @@ -1,14 +1,15 @@  - net8.0 + net9.0 enable enable - - + + + diff --git a/protocols/JiShe.CollectBus.Protocol.T6452007/JiShe.CollectBus.Protocol.T6452007.csproj b/protocols/JiShe.CollectBus.Protocol.T6452007/JiShe.CollectBus.Protocol.T6452007.csproj index e19a7e0..1876a75 100644 --- a/protocols/JiShe.CollectBus.Protocol.T6452007/JiShe.CollectBus.Protocol.T6452007.csproj +++ b/protocols/JiShe.CollectBus.Protocol.T6452007/JiShe.CollectBus.Protocol.T6452007.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable @@ -10,8 +10,8 @@ - - + + diff --git a/protocols/JiShe.CollectBus.Protocol.Test/JiShe.CollectBus.Protocol.Test.csproj b/protocols/JiShe.CollectBus.Protocol.Test/JiShe.CollectBus.Protocol.Test.csproj index e798bdb..5eceed5 100644 --- a/protocols/JiShe.CollectBus.Protocol.Test/JiShe.CollectBus.Protocol.Test.csproj +++ b/protocols/JiShe.CollectBus.Protocol.Test/JiShe.CollectBus.Protocol.Test.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable @@ -10,8 +10,8 @@ - - + + diff --git a/protocols/JiShe.CollectBus.Protocol.Test/JiSheCollectBusTestProtocolModule.cs b/protocols/JiShe.CollectBus.Protocol.Test/JiSheCollectBusTestProtocolModule.cs index 6c3ebdc..f35b00e 100644 --- a/protocols/JiShe.CollectBus.Protocol.Test/JiSheCollectBusTestProtocolModule.cs +++ b/protocols/JiShe.CollectBus.Protocol.Test/JiSheCollectBusTestProtocolModule.cs @@ -1,5 +1,7 @@ using JiShe.CollectBus.Protocol.Interfaces; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System.Reflection; using Volo.Abp; using Volo.Abp.Modularity; diff --git a/protocols/JiShe.CollectBus.Protocol.Test/TestServer.cs b/protocols/JiShe.CollectBus.Protocol.Test/TestServer.cs new file mode 100644 index 0000000..23a8703 --- /dev/null +++ b/protocols/JiShe.CollectBus.Protocol.Test/TestServer.cs @@ -0,0 +1,27 @@ +using JiShe.CollectBus.Protocol.Interfaces; +using JiShe.CollectBus.Protocol.T37612012.AnalysisData.AFN_00H; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JiShe.CollectBus.Protocol.Test +{ + public class TestServer: IAnalysisStrategy + { + private readonly ILogger _logger; + public TestServer (ILogger logger) + { + _logger= logger; + } + + public Task ExecuteAsync(string input, Action? result = null) + { + _logger.LogWarning("测试插件动态加载"); + return Task.FromResult(true); + } + + } +} diff --git a/protocols/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj b/protocols/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj index 7fead27..6b06536 100644 --- a/protocols/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj +++ b/protocols/JiShe.CollectBus.Protocol/JiShe.CollectBus.Protocol.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable @@ -18,8 +18,9 @@ - - + + + diff --git a/services/JiShe.CollectBus.Application.Contracts/JiShe.CollectBus.Application.Contracts.csproj b/services/JiShe.CollectBus.Application.Contracts/JiShe.CollectBus.Application.Contracts.csproj index fedbafd..650d8b5 100644 --- a/services/JiShe.CollectBus.Application.Contracts/JiShe.CollectBus.Application.Contracts.csproj +++ b/services/JiShe.CollectBus.Application.Contracts/JiShe.CollectBus.Application.Contracts.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable JiShe.CollectBus True @@ -21,8 +21,9 @@ - - + + + diff --git a/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs b/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs index 8fa7033..9b311da 100644 --- a/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs +++ b/services/JiShe.CollectBus.Application/CollectBusApplicationModule.cs @@ -54,6 +54,7 @@ public class CollectBusApplicationModule : AbpModule var any = methods.Any(a => a.GetCustomAttribute() != null); if (any) ctx.Interceptors.TryAdd(); }); + } public override async Task OnApplicationInitializationAsync( diff --git a/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj b/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj index 5dae431..59e6456 100644 --- a/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj +++ b/services/JiShe.CollectBus.Application/JiShe.CollectBus.Application.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable JiShe.CollectBus True @@ -15,12 +15,13 @@ - - - - - - + + + + + + + diff --git a/services/JiShe.CollectBus.Application/Samples/TestAppService.cs b/services/JiShe.CollectBus.Application/Samples/TestAppService.cs index 8c7b5fe..af8bbde 100644 --- a/services/JiShe.CollectBus.Application/Samples/TestAppService.cs +++ b/services/JiShe.CollectBus.Application/Samples/TestAppService.cs @@ -1,17 +1,24 @@ -using JiShe.CollectBus.Common.Enums; +using IdentityModel.Client; +using JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.DynamicModule; using JiShe.CollectBus.Interceptors; using JiShe.CollectBus.IotSystems.MessageIssueds; using JiShe.CollectBus.IotSystems.Protocols; +using JiShe.CollectBus.Protocol; using JiShe.CollectBus.Protocol.Interfaces; +using JiShe.CollectBus.Protocol3761; using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Reflection; using System.Threading.Tasks; +using TouchSocket.Sockets; +using Volo.Abp; using Volo.Abp.Modularity; namespace JiShe.CollectBus.Samples; @@ -25,13 +32,13 @@ public class TestAppService : CollectBusAppService private readonly IProtocolService _protocolService; private readonly IServiceProvider _serviceProvider; private readonly IDynamicModuleManager _dynamicModuleManager; - + private readonly IServiceCollection _serviceDescriptors; public TestAppService( ILogger logger, //ICassandraRepository messageReceivedCassandraRepository, //ICassandraProvider cassandraProvider, - IProtocolService protocolService,IServiceProvider serviceProvider, IDynamicModuleManager dynamicModuleManager) + IProtocolService protocolService,IServiceProvider serviceProvider, IDynamicModuleManager dynamicModuleManager, IServiceCollection serviceDescriptors) { _logger = logger; //_messageReceivedCassandraRepository = messageReceivedCassandraRepository; @@ -39,6 +46,7 @@ public class TestAppService : CollectBusAppService _protocolService = protocolService; _serviceProvider = serviceProvider; _dynamicModuleManager = dynamicModuleManager; + _serviceDescriptors = serviceDescriptors; } public async Task AddMessageOfCassandra() { @@ -135,8 +143,76 @@ public class TestAppService : CollectBusAppService public async Task ReloadPluginsAsync() { var aa = Assembly.LoadFile( - @"D:\Codes\CollectBusV5\JiShe.CollectBus\web\JiShe.CollectBus.Host\bin\Debug\net8.0\Plugins\JiShe.CollectBus.Protocol.Test.dll"); + @"E:\Devlopment\JiShe.CollectBusDev01\web\JiShe.CollectBus.Host\bin\Debug\net8.0\Plugins\JiShe.CollectBus.Protocol.Test.dll"); var module = aa.GetTypes().First(a=> typeof(IAbpModule).IsAssignableFrom(a)); - await _dynamicModuleManager.ReinitializeModuleAsync(module); + await _dynamicModuleManager.LoadModuleAsync(module); + } + + + public async Task TestPlugins() + { + var executor = _serviceProvider.GetRequiredService(); + return await executor.ExecuteAsync("TestServer", "TestServer"); + + } + + /// + /// 注册策略 + /// + public void RegisterProtocolAnalysis() + { + // 扫描并注册所有策略 + var strategyMetadata = new Dictionary<(string, Type), Type>(); + _serviceDescriptors.AddTransient(); + + // 批量注册 + var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); + if (string.IsNullOrWhiteSpace(assemblyPath)) + { + return; + } + var dllFiles = Directory.GetFiles(Path.Combine(assemblyPath, "Plugins"), "*.dll"); + foreach (var file in dllFiles) + { + // 跳过已加载的程序集 + var assemblyName = AssemblyName.GetAssemblyName(file); + var existingAssembly = AppDomain.CurrentDomain.GetAssemblies() + .FirstOrDefault(a => a.GetName().FullName == assemblyName.FullName); + var assembly = existingAssembly ?? Assembly.LoadFrom(file); + // 实现IAnalysisStrategy接口 + var analysisStrategyTypes = assembly.GetTypes().Where(t => !t.IsAbstract && !t.IsInterface && t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAnalysisStrategy<>))); + if (!analysisStrategyTypes.Any()) + continue; + foreach (var analysisStrategyType in analysisStrategyTypes) + { + // 通过反射获取静态元数据 + var strategyType = analysisStrategyType.Name; + var genericArgs = analysisStrategyType.GetInterface($"IAnalysisStrategy`1")!.GetGenericArguments(); + var inputType = genericArgs[0]; + // 注册策略实现 + _serviceDescriptors.AddTransient(analysisStrategyType); + strategyMetadata[(strategyType, inputType)] = analysisStrategyType; + + } + } + + // 注册元数据字典 + _serviceDescriptors.AddSingleton(strategyMetadata); + + // 注册策略解析工厂 + _serviceDescriptors.AddTransient>(provider => (name, inputType) => + { + var metadata = provider.GetRequiredService>(); + if (metadata.TryGetValue((name, inputType), out var strategyType)) + { + return provider.GetRequiredService(strategyType); + } + else + { + var logger = provider.GetRequiredService>(); + logger.LogWarning($"未能找到解析策略:{name}-{inputType}"); + return null; + } + }); } } diff --git a/services/JiShe.CollectBus.DbMigrator/JiShe.CollectBus.DbMigrator.csproj b/services/JiShe.CollectBus.DbMigrator/JiShe.CollectBus.DbMigrator.csproj index 00b7197..17d2413 100644 --- a/services/JiShe.CollectBus.DbMigrator/JiShe.CollectBus.DbMigrator.csproj +++ b/services/JiShe.CollectBus.DbMigrator/JiShe.CollectBus.DbMigrator.csproj @@ -4,20 +4,21 @@ Exe - net8.0 + net9.0 enable - - - - - + + + + + + - + diff --git a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj index e69f3b6..3a2fcc9 100644 --- a/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj +++ b/services/JiShe.CollectBus.Domain/JiShe.CollectBus.Domain.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable JiShe.CollectBus @@ -30,11 +30,11 @@ - - - - - + + + + + diff --git a/services/JiShe.CollectBus.Migration.Application.Contracts/JiShe.CollectBus.Migration.Application.Contracts.csproj b/services/JiShe.CollectBus.Migration.Application.Contracts/JiShe.CollectBus.Migration.Application.Contracts.csproj index f3ef574..f5ede33 100644 --- a/services/JiShe.CollectBus.Migration.Application.Contracts/JiShe.CollectBus.Migration.Application.Contracts.csproj +++ b/services/JiShe.CollectBus.Migration.Application.Contracts/JiShe.CollectBus.Migration.Application.Contracts.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable JiShe.CollectBus.Migration True @@ -21,8 +21,8 @@ - - + + diff --git a/services/JiShe.CollectBus.Migration.Application/JiShe.CollectBus.Migration.Application.csproj b/services/JiShe.CollectBus.Migration.Application/JiShe.CollectBus.Migration.Application.csproj index bce2a34..8af92a2 100644 --- a/services/JiShe.CollectBus.Migration.Application/JiShe.CollectBus.Migration.Application.csproj +++ b/services/JiShe.CollectBus.Migration.Application/JiShe.CollectBus.Migration.Application.csproj @@ -3,7 +3,7 @@ - net8.0 + net9.0 enable JiShe.CollectBus.Migration True @@ -15,13 +15,14 @@ - - - - - - - + + + + + + + + diff --git a/services/JiShe.CollectBusEPO.Application.Contracts/JiShe.CollectBusEPO.Application.Contracts.csproj b/services/JiShe.CollectBusEPO.Application.Contracts/JiShe.CollectBusEPO.Application.Contracts.csproj index 23e52c4..d77157a 100644 --- a/services/JiShe.CollectBusEPO.Application.Contracts/JiShe.CollectBusEPO.Application.Contracts.csproj +++ b/services/JiShe.CollectBusEPO.Application.Contracts/JiShe.CollectBusEPO.Application.Contracts.csproj @@ -1,12 +1,12 @@ - + - net8.0 + net9.0 JiShe.CollectBusEPO - - + + diff --git a/services/JiShe.CollectBusEPO.Application/JiShe.CollectBusEPO.Application.csproj b/services/JiShe.CollectBusEPO.Application/JiShe.CollectBusEPO.Application.csproj index 0bb7da1..ad5fe8d 100644 --- a/services/JiShe.CollectBusEPO.Application/JiShe.CollectBusEPO.Application.csproj +++ b/services/JiShe.CollectBusEPO.Application/JiShe.CollectBusEPO.Application.csproj @@ -2,13 +2,13 @@ - net8.0 + net9.0 JiShe.CollectBusEPO - - + + diff --git a/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj b/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj index 4b94598..8d54d0c 100644 --- a/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj +++ b/shared/JiShe.CollectBus.Common/JiShe.CollectBus.Common.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable @@ -16,20 +16,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/DynamicModuleManager.cs b/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/DynamicModuleManager.cs index 8f8e0eb..73d5a85 100644 --- a/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/DynamicModuleManager.cs +++ b/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/DynamicModuleManager.cs @@ -6,7 +6,9 @@ using System.Reflection; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; +using Volo.Abp.Logging; using Volo.Abp.Modularity; +using Volo.Abp.Modularity.PlugIns; namespace JiShe.CollectBus.DynamicModule { @@ -17,13 +19,22 @@ namespace JiShe.CollectBus.DynamicModule { private readonly IModuleContainer _moduleContainer; private readonly IServiceProvider _serviceProvider; + //private readonly IModuleLoader _moduleLoader; + //private readonly IAbpApplicationWithInternalServiceProvider _abpApplicationWithInternalServiceProvider; + //private readonly IServiceCollection _services; public DynamicModuleManager( IModuleContainer moduleContainer, - IServiceProvider serviceProvider) + IServiceProvider serviceProvider + //IModuleLoader moduleLoader, + //IServiceCollection services, IAbpApplicationWithInternalServiceProvider abpApplicationWithInternalServiceProvider + ) { _moduleContainer = moduleContainer; _serviceProvider = serviceProvider; + //_moduleLoader = moduleLoader; + //_services = services; + //_abpApplicationWithInternalServiceProvider= abpApplicationWithInternalServiceProvider; } public Type[] GetRegisteredModuleTypes() @@ -31,6 +42,21 @@ namespace JiShe.CollectBus.DynamicModule return _moduleContainer.Modules.Select(m => m.Type).ToArray(); } + public async Task LoadModuleAsync(Type moduleType) + { + if (!typeof(IAbpModule).IsAssignableFrom(moduleType)) + { + throw new ArgumentException($"指定的类型 {moduleType.FullName} 不是有效的ABP模块类型", nameof(moduleType)); + } + //var modules = _moduleLoader.LoadModules(_services, moduleType, new PlugInSourceList()); + using (var application = AbpApplicationFactory.Create(moduleType)) + { + await application.InitializeAsync(); + } + + //await _abpApplicationWithInternalServiceProvider.InitializeAsync(); + } + public async Task ReinitializeModuleAsync(Type moduleType) { if (!typeof(IAbpModule).IsAssignableFrom(moduleType)) diff --git a/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/IDynamicModuleManager.cs b/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/IDynamicModuleManager.cs index 3f87820..079f754 100644 --- a/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/IDynamicModuleManager.cs +++ b/shared/JiShe.CollectBus.Domain.Shared/DynamicModule/IDynamicModuleManager.cs @@ -41,5 +41,7 @@ namespace JiShe.CollectBus.DynamicModule /// 模块名称 /// 模块类型,如果找不到则为null Type GetModuleTypeByName(string moduleName); + + Task LoadModuleAsync(Type moduleType); } } \ No newline at end of file diff --git a/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj b/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj index 5453712..bd94cb1 100644 --- a/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj +++ b/shared/JiShe.CollectBus.Domain.Shared/JiShe.CollectBus.Domain.Shared.csproj @@ -1,21 +1,21 @@ - + - net8.0 + net9.0 enable JiShe.CollectBus true - - + + - + @@ -31,6 +31,11 @@ + + + + + diff --git a/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj b/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj index 2877bab..9337526 100644 --- a/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj +++ b/web/JiShe.CollectBus.Host/JiShe.CollectBus.Host.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True @@ -24,31 +24,31 @@ - - - - - + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -79,4 +79,4 @@ - + \ No newline at end of file diff --git a/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj b/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj index 3ea1d32..d81e1e8 100644 --- a/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj +++ b/web/JiShe.CollectBus.HttpApi/JiShe.CollectBus.HttpApi.csproj @@ -1,9 +1,9 @@ - + - net8.0 + net9.0 enable JiShe.CollectBus True @@ -15,7 +15,7 @@ - + diff --git a/web/JiShe.CollectBus.Migration.Host/JiShe.CollectBus.Migration.Host.csproj b/web/JiShe.CollectBus.Migration.Host/JiShe.CollectBus.Migration.Host.csproj index 5e6ba2d..94bf626 100644 --- a/web/JiShe.CollectBus.Migration.Host/JiShe.CollectBus.Migration.Host.csproj +++ b/web/JiShe.CollectBus.Migration.Host/JiShe.CollectBus.Migration.Host.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True @@ -20,33 +20,33 @@ - - - - - + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - + + diff --git a/web/JiShe.CollectBus.Migration.HttpApi/JiShe.CollectBus.Migration.HttpApi.csproj b/web/JiShe.CollectBus.Migration.HttpApi/JiShe.CollectBus.Migration.HttpApi.csproj index 5047d92..5f3d51f 100644 --- a/web/JiShe.CollectBus.Migration.HttpApi/JiShe.CollectBus.Migration.HttpApi.csproj +++ b/web/JiShe.CollectBus.Migration.HttpApi/JiShe.CollectBus.Migration.HttpApi.csproj @@ -1,9 +1,9 @@ - + - net8.0 + net9.0 enable JiShe.CollectBus True @@ -15,7 +15,7 @@ - + diff --git a/web/JiShe.CollectBusEPO.HttpApi.Host/JiShe.CollectBusEPO.HttpApi.Host.csproj b/web/JiShe.CollectBusEPO.HttpApi.Host/JiShe.CollectBusEPO.HttpApi.Host.csproj index 1c0e309..94f55d8 100644 --- a/web/JiShe.CollectBusEPO.HttpApi.Host/JiShe.CollectBusEPO.HttpApi.Host.csproj +++ b/web/JiShe.CollectBusEPO.HttpApi.Host/JiShe.CollectBusEPO.HttpApi.Host.csproj @@ -1,6 +1,6 @@ - + - net8.0 + net9.0 JiShe.CollectBusEPO true JiShe.MicroService-4681b4fd-151f-4221-84a4-929d86723e4c @@ -10,22 +10,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/web/JiShe.CollectBusEPO.HttpApi/JiShe.CollectBusEPO.HttpApi.csproj b/web/JiShe.CollectBusEPO.HttpApi/JiShe.CollectBusEPO.HttpApi.csproj index 52da299..8032b51 100644 --- a/web/JiShe.CollectBusEPO.HttpApi/JiShe.CollectBusEPO.HttpApi.csproj +++ b/web/JiShe.CollectBusEPO.HttpApi/JiShe.CollectBusEPO.HttpApi.csproj @@ -3,12 +3,12 @@ - net8.0 + net9.0 JiShe.CollectBusEPO - +