|
|
|
@ -1,14 +1,19 @@ |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
using Shentun.Peis.Models; |
|
|
|
using Shentun.Peis.PlugIns; |
|
|
|
using Shentun.Peis.SysParmValues; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
|
|
|
|
@ -22,6 +27,7 @@ namespace Shentun.Peis.LisRequests |
|
|
|
private readonly IRepository<SysParmValue> _sysParmValueRepository; |
|
|
|
private readonly IRepository<PrimarykeyBuilder> _primarykeyBuilderRepository; |
|
|
|
private readonly IRepository<LisRequest, Guid> _lisRequestRepository; |
|
|
|
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository; |
|
|
|
private readonly SysParmValueManager _sysParmValueManager; |
|
|
|
public LisRequestManager( |
|
|
|
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemeRepository, |
|
|
|
@ -30,7 +36,8 @@ namespace Shentun.Peis.LisRequests |
|
|
|
IRepository<SysParmValue> sysParmValueRepository, |
|
|
|
IRepository<PrimarykeyBuilder> primarykeyBuilderRepository, |
|
|
|
IRepository<LisRequest, Guid> lisRequestRepository, |
|
|
|
SysParmValueManager sysParmValueManager |
|
|
|
SysParmValueManager sysParmValueManager, |
|
|
|
IRepository<ThirdInterface, Guid> thirdInterfaceRepository |
|
|
|
) |
|
|
|
{ |
|
|
|
this._registerCheckAsbitemeRepository = registerCheckAsbitemeRepository; |
|
|
|
@ -40,6 +47,7 @@ namespace Shentun.Peis.LisRequests |
|
|
|
this._primarykeyBuilderRepository = primarykeyBuilderRepository; |
|
|
|
this._lisRequestRepository = lisRequestRepository; |
|
|
|
_sysParmValueManager = sysParmValueManager; |
|
|
|
_thirdInterfaceRepository = thirdInterfaceRepository; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -250,7 +258,27 @@ namespace Shentun.Peis.LisRequests |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task SendThirdLisRequest(Guid id) |
|
|
|
{ |
|
|
|
var thirdInterfaces = (await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ChargeRequest)) |
|
|
|
.OrderBy(o=>o.DisplayOrder).ToList(); |
|
|
|
foreach (var thirdInterface in thirdInterfaces) |
|
|
|
{ |
|
|
|
var lisRequestPluginsInput = new LisRequestPluginsInput() |
|
|
|
{ |
|
|
|
LisRequestId = id |
|
|
|
}; |
|
|
|
|
|
|
|
var parmValue = thirdInterface.ParmValue; |
|
|
|
var configurationBuilder = new ConfigurationBuilder() |
|
|
|
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); |
|
|
|
var config = configurationBuilder.Build(); |
|
|
|
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value; |
|
|
|
var className = config.GetSection("Interface").GetSection("ClassName").Value; |
|
|
|
object[] objects = [lisRequestPluginsInput]; |
|
|
|
var LisRequestPluginsOut = await InvokeAsync(assemblyName, className, parmValue, "SendRequest", objects); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -385,6 +413,31 @@ namespace Shentun.Peis.LisRequests |
|
|
|
public Guid SampleGroupId { get; set; } |
|
|
|
public Guid? LisRequestId { get; set; } |
|
|
|
} |
|
|
|
private async Task<LisRequestPluginsOut> InvokeAsync(string assemblyName, string className, string classConstructorArg, string methodName, object[] args = null) |
|
|
|
{ |
|
|
|
Assembly assembly = Assembly.Load(assemblyName); |
|
|
|
Type type = assembly.GetType(className); |
|
|
|
// 创建类的实例
|
|
|
|
object instance = Activator.CreateInstance(type, classConstructorArg); |
|
|
|
// 获取方法信息
|
|
|
|
MethodInfo method = type.GetMethod(methodName); |
|
|
|
// 调用方法,如果方法需要参数,可以传入对应的参数数组,例如: new object[] { arg1, arg2 }
|
|
|
|
LisRequestPluginsOut returnValue; |
|
|
|
var isAsync = (method.ReturnType == typeof(Task) || |
|
|
|
(method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(Task<>))); |
|
|
|
if (isAsync) |
|
|
|
{ |
|
|
|
// 使用反射调用方法
|
|
|
|
|
|
|
|
//object returnValue = method.Invoke(instance, args);
|
|
|
|
returnValue = await (Task<LisRequestPluginsOut>)method.Invoke(instance, args); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
returnValue = (LisRequestPluginsOut)method.Invoke(instance, args); |
|
|
|
|
|
|
|
} |
|
|
|
return returnValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |