diff --git a/aspnet-core/LINGYUN.MicroService.TaskManagement.sln b/aspnet-core/LINGYUN.MicroService.TaskManagement.sln index b33ff44de..326be95d8 100644 --- a/aspnet-core/LINGYUN.MicroService.TaskManagement.sln +++ b/aspnet-core/LINGYUN.MicroService.TaskManagement.sln @@ -136,6 +136,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Http EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Security", "framework\security\LINGYUN.Abp.Security\LINGYUN.Abp.Security.csproj", "{BEE1B759-5B65-481B-928B-8BC6A89A7C13}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "oss-management", "oss-management", "{F36E71F7-B05F-4513-A923-81E2A7474EAE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Domain.Shared", "modules\oss-management\LINGYUN.Abp.OssManagement.Domain.Shared\LINGYUN.Abp.OssManagement.Domain.Shared.csproj", "{94D1C512-09E4-4A68-8989-6DB49FEABA67}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Application.Contracts", "modules\oss-management\LINGYUN.Abp.OssManagement.Application.Contracts\LINGYUN.Abp.OssManagement.Application.Contracts.csproj", "{96B4D255-BB21-4BAF-902A-ADE3F25A44C2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.HttpApi.Client", "modules\oss-management\LINGYUN.Abp.OssManagement.HttpApi.Client\LINGYUN.Abp.OssManagement.HttpApi.Client.csproj", "{44778F3C-7610-4F1C-A2B6-DF8925B1CBE0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -354,6 +362,18 @@ Global {BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Release|Any CPU.Build.0 = Release|Any CPU + {94D1C512-09E4-4A68-8989-6DB49FEABA67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94D1C512-09E4-4A68-8989-6DB49FEABA67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94D1C512-09E4-4A68-8989-6DB49FEABA67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94D1C512-09E4-4A68-8989-6DB49FEABA67}.Release|Any CPU.Build.0 = Release|Any CPU + {96B4D255-BB21-4BAF-902A-ADE3F25A44C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96B4D255-BB21-4BAF-902A-ADE3F25A44C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96B4D255-BB21-4BAF-902A-ADE3F25A44C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96B4D255-BB21-4BAF-902A-ADE3F25A44C2}.Release|Any CPU.Build.0 = Release|Any CPU + {44778F3C-7610-4F1C-A2B6-DF8925B1CBE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44778F3C-7610-4F1C-A2B6-DF8925B1CBE0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44778F3C-7610-4F1C-A2B6-DF8925B1CBE0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44778F3C-7610-4F1C-A2B6-DF8925B1CBE0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -412,6 +432,9 @@ Global {B3E81983-629A-4380-B4C2-50E247916F5E} = {5A41C31A-B966-418B-B446-5BA1D7E61A62} {088064DD-D141-4E9A-B185-E332920A323A} = {5A41C31A-B966-418B-B446-5BA1D7E61A62} {BEE1B759-5B65-481B-928B-8BC6A89A7C13} = {5A41C31A-B966-418B-B446-5BA1D7E61A62} + {94D1C512-09E4-4A68-8989-6DB49FEABA67} = {F36E71F7-B05F-4513-A923-81E2A7474EAE} + {96B4D255-BB21-4BAF-902A-ADE3F25A44C2} = {F36E71F7-B05F-4513-A923-81E2A7474EAE} + {44778F3C-7610-4F1C-A2B6-DF8925B1CBE0} = {F36E71F7-B05F-4513-A923-81E2A7474EAE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E1FD1F4C-D344-408B-97CF-B6F1F6D7D293} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs index a27a9d0cf..b5c98602e 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Jobs/LINGYUN/Abp/BackgroundTasks/Jobs/ServiceInvocationJob.cs @@ -1,10 +1,13 @@ -using LINGYUN.Abp.Dapr.Client.DynamicProxying; +using Castle.DynamicProxy.Internal; +using LINGYUN.Abp.Dapr.Client.DynamicProxying; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Reflection; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Http.Client; @@ -61,7 +64,18 @@ public async virtual Task ExecuteAsync(JobRunnableContext context) var type = context.GetString(PropertyService); var method = context.GetString(PropertyMethod); var serviceType = Type.GetType(type, true); - var serviceMethod = serviceType.GetMethod(method); + var serviceMethod = serviceType.GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); + if (serviceMethod == null) + { + foreach (var ifce in serviceType.GetAllInterfaces()) + { + serviceMethod = ifce.GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); + if (serviceMethod != null) + { + break; + } + } + } context.TryGetString(PropertyCulture, out var culture); context.TryGetString(PropertyProvider, out var provider); provider ??= "http"; @@ -83,10 +97,9 @@ public async virtual Task ExecuteAsync(JobRunnableContext context) switch (provider) { case "http": - await ExecuteWithHttpProxy(context, serviceType, serviceMethod); - break; case "dapr": - await ExecuteWithDaprProxy(context, serviceType, serviceMethod); + // 接口代理无差异 + await ExecuteProxy(context, serviceType, serviceMethod); break; } } @@ -94,56 +107,41 @@ public async virtual Task ExecuteAsync(JobRunnableContext context) } #region HttpClient - - protected readonly static string CallRequestMethod = nameof(DynamicHttpProxyInterceptorClientProxy.CallRequestAsync); - protected readonly static MethodInfo ClientProxyMethod = typeof(DynamicHttpProxyInterceptorClientProxy<>) - .GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) - .First(m => m.Name == CallRequestMethod && !m.IsGenericMethodDefinition); - protected readonly static MethodInfo CallRequestAsyncMethod = typeof(DynamicHttpProxyInterceptor) - .GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) - .First(m => m.Name == CallRequestMethod && m.IsGenericMethodDefinition); - - protected async virtual Task ExecuteWithHttpProxy( + protected async virtual Task ExecuteProxy( JobRunnableContext context, Type serviceType, MethodInfo serviceMethod) { - // 反射所必须的参数 - var clientProxyType = typeof(DynamicHttpProxyInterceptorClientProxy<>).MakeGenericType(serviceType); - var clientProxy = context.GetRequiredService(clientProxyType); - - // 调用远程服务发现端点 - var actionApiDescription = await GetActionApiDescriptionModel(context, serviceType, serviceMethod); + var clientProxy = context.GetRequiredService(serviceType); // 调用参数 - var invokeParameters = new Dictionary(); + var methodParamters = serviceMethod.GetParameters(); + var invokeParameters = new List(); if (context.TryGetString(PropertyData, out var data)) { - var jsonSerializer = context.GetRequiredService(); - invokeParameters = jsonSerializer.Deserialize>(data); + var json = JsonNode.Parse(data); + foreach ( var param in methodParamters) + { + var input = json[param.Name]; + if (input != null) + { + invokeParameters.Add(input.Deserialize(param.ParameterType)); + } + } } - // 构造服务代理上下文 - var clientProxyRequestContext = new ClientProxyRequestContext( - actionApiDescription, - invokeParameters, - serviceType); - if (serviceMethod.ReturnType.GenericTypeArguments.IsNullOrEmpty()) { // 直接调用 - var taskProxy = (Task)ClientProxyMethod - .Invoke(clientProxy, new object[] { clientProxyRequestContext }); + var taskProxy = (Task)serviceMethod.Invoke(clientProxy, invokeParameters.ToArray()); await taskProxy; } else { // 有返回值的调用 var returnType = serviceMethod.ReturnType.GenericTypeArguments[0]; - var result = (Task)CallRequestAsyncMethod - .MakeGenericMethod(returnType) - .Invoke(this, new object[] { context }); - + var callResult = serviceMethod.Invoke(clientProxy, invokeParameters.ToArray()); + var result = (Task)callResult; context.SetResult(await GetResultAsync(result, returnType)); } } diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj index e7c025969..1a6a385bb 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj @@ -68,6 +68,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs index e812faf1b..b75dff455 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs @@ -14,6 +14,7 @@ using LINGYUN.Abp.Http.Client.Wrapper; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; +using LINGYUN.Abp.OssManagement; using LINGYUN.Abp.Saas.EntityFrameworkCore; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; @@ -52,6 +53,7 @@ namespace LY.MicroService.TaskManagement; typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpAuthorizationOrganizationUnitsModule), typeof(AbpEmailingExceptionHandlingModule), + typeof(AbpOssManagementHttpApiClientModule), typeof(AbpHttpClientIdentityModelWebModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpAspNetCoreMvcLocalizationModule), diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json index 41145a1da..efe8b174a 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json @@ -33,13 +33,13 @@ }, "MySql": { "TableNamePrefix": "tsk", - "ConnectionString": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + "ConnectionString": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None" }, "RabbitMQ": { "HostName": "127.0.0.1", "Port": 5672, "UserName": "admin", - "Password": "admin", + "Password": "123456", "ExchangeName": "LINGYUN.Abp.Application", "VirtualHost": "/" } @@ -50,7 +50,7 @@ "quartz.jobStore.dataSource": "tkm", "quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz", "quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz", - "quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", + "quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", "quartz.dataSource.tkm.connectionStringName": "TaskManagement", "quartz.dataSource.tkm.provider": "MySqlConnector", "quartz.jobStore.clustered": "true", @@ -58,13 +58,13 @@ } }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "TaskManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", - "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" + "Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", + "TaskManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", + "AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None", + "AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None" }, "RemoteServices": { "AbpOssManagement": { @@ -80,7 +80,7 @@ "GrantType": "client_credentials", "Scope": "lingyun-abp-application", "ClientId": "InternalServiceClient", - "ClientSecret": "1q2w3E*" + "ClientSecret": "1q2w3e*" } }, "DistributedLock": {