|
|
|
@ -186,8 +186,8 @@ namespace Shentun.Peis.ColumnReferences |
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/ColumnReference/GetAppColumnNames")] |
|
|
|
public async Task<List<string>> GetAppColumnNamesAsync(ColumnReferenceIdInputDto input) |
|
|
|
[HttpPost("api/app/ColumnReference/GetAppColumns")] |
|
|
|
public async Task<List<ColumnReferenceColumn>> GetAppColumnsAsync(ColumnReferenceIdInputDto input) |
|
|
|
{ |
|
|
|
var entity = await _repository.GetAsync(input.Id); |
|
|
|
var parmValue = entity.ParmValue; |
|
|
|
@ -196,13 +196,9 @@ namespace Shentun.Peis.ColumnReferences |
|
|
|
var config = configurationBuilder.Build(); |
|
|
|
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value; |
|
|
|
var className = config.GetSection("Interface").GetSection("ClassName").Value; |
|
|
|
object objectValue = await InvokeAsync(assemblyName, className, parmValue, "GetAppColumnNames"); |
|
|
|
List<string> list = new List<string>(); |
|
|
|
var list = await InvokeColumnsAsync(assemblyName, className, parmValue, "GetAppColumns"); |
|
|
|
|
|
|
|
|
|
|
|
if (objectValue is IEnumerable enumerableObject) |
|
|
|
{ |
|
|
|
list = enumerableObject.Cast<string>().ToList(); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
public async Task<string> GetAppFilterColumnName(ColumnReferenceIdInputDto input) |
|
|
|
@ -214,8 +210,8 @@ namespace Shentun.Peis.ColumnReferences |
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/ColumnReference/GetInterfaceColumnNames")] |
|
|
|
public async Task<List<string>> GetInterfaceColumnNamesAsync(ColumnReferenceIdInputDto input) |
|
|
|
[HttpPost("api/app/ColumnReference/GetInterfaceColumns")] |
|
|
|
public async Task<List<ColumnReferenceColumn>> GetInterfaceColumnsAsync(ColumnReferenceIdInputDto input) |
|
|
|
{ |
|
|
|
var entity = await _repository.GetAsync(input.Id); |
|
|
|
var parmValue = entity.ParmValue; |
|
|
|
@ -224,13 +220,8 @@ namespace Shentun.Peis.ColumnReferences |
|
|
|
var config = configurationBuilder.Build(); |
|
|
|
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value; |
|
|
|
var className = config.GetSection("Interface").GetSection("ClassName").Value; |
|
|
|
object objectValue = await InvokeAsync(assemblyName, className, parmValue, "GetInterfaceColumnNames"); |
|
|
|
List<string> list = new List<string>(); |
|
|
|
|
|
|
|
if (objectValue is IEnumerable enumerableObject) |
|
|
|
{ |
|
|
|
list = enumerableObject.Cast<string>().ToList(); |
|
|
|
} |
|
|
|
var list = await InvokeColumnsAsync(assemblyName, className, parmValue, "GetInterfaceColumns"); |
|
|
|
|
|
|
|
return list; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
@ -382,5 +373,32 @@ namespace Shentun.Peis.ColumnReferences |
|
|
|
return returnValue; |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<List<ColumnReferenceColumn>> InvokeColumnsAsync(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 }
|
|
|
|
List<ColumnReferenceColumn> 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<List<ColumnReferenceColumn>>)method.Invoke(instance, args); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
returnValue = (List<ColumnReferenceColumn>)method.Invoke(instance, args); |
|
|
|
|
|
|
|
} |
|
|
|
return returnValue; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |