|
|
|
@ -183,6 +183,7 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
{
|
|
|
|
|
ConfigId = configItem.Id,
|
|
|
|
|
PId = flowLog.Id,
|
|
|
|
|
IsSuccess = true,
|
|
|
|
|
};
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -227,8 +228,10 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"在依赖注入容器未找到Interface【{module.InterfaceName}】的实现类");
|
|
|
|
|
}
|
|
|
|
|
var impType = imp.GetType();
|
|
|
|
|
|
|
|
|
|
MethodInfo? method = imp.GetType().GetMethod(module.MethodName!);
|
|
|
|
|
|
|
|
|
|
MethodInfo? method = impType.GetMethod(module.MethodName!, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
|
|
|
|
if (method == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"在Interface【{module.InterfaceName}】的实现类中未找到Method【{module.MethodName}】");
|
|
|
|
@ -236,33 +239,45 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
|
|
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
|
|
var resultTemp = method.Invoke(imp, new object[] { dataContext });
|
|
|
|
|
if (resultTemp is DataResult result1 && result1 != null)
|
|
|
|
|
var taskObj = method.Invoke(imp, new object[] { dataContext })!;
|
|
|
|
|
|
|
|
|
|
if (taskObj is Task task)
|
|
|
|
|
{
|
|
|
|
|
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(result1);
|
|
|
|
|
flowLogDetail.IsSuccess = result1.Succeeded;
|
|
|
|
|
await task;
|
|
|
|
|
|
|
|
|
|
if (!result1.Succeeded)
|
|
|
|
|
if (task.IsFaulted)
|
|
|
|
|
{
|
|
|
|
|
flowLog.IsSuccess = false;
|
|
|
|
|
if (task.Exception != null)
|
|
|
|
|
{
|
|
|
|
|
throw task.Exception;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("模块执行过程中发生未知异常,但是Exception为null,请检查");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (resultTemp is Task<DataResult> result2 && result2 != null && result2.IsCompleted)
|
|
|
|
|
{
|
|
|
|
|
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(result2.Result);
|
|
|
|
|
flowLogDetail.IsSuccess = result2.Result.Succeeded;
|
|
|
|
|
|
|
|
|
|
if (!result2.Result.Succeeded)
|
|
|
|
|
dynamic dynamicTask = task;
|
|
|
|
|
if (dynamicTask.Result != null)
|
|
|
|
|
{
|
|
|
|
|
flowLog.IsSuccess = false;
|
|
|
|
|
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(dynamicTask.Result);
|
|
|
|
|
|
|
|
|
|
var isSuccess = dynamicTask.Result.Succeeded;
|
|
|
|
|
if (isSuccess != null && isSuccess is bool)
|
|
|
|
|
{
|
|
|
|
|
flowLogDetail.IsSuccess = isSuccess;
|
|
|
|
|
|
|
|
|
|
if (isSuccess == false)
|
|
|
|
|
{
|
|
|
|
|
flowLog.IsSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (resultTemp is Task result3)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (result3.Exception != null && result3.IsFaulted)
|
|
|
|
|
{
|
|
|
|
|
throw result3.Exception;
|
|
|
|
|
}
|
|
|
|
|
throw new Exception("模块执行结果不是Task类型,请检查");
|
|
|
|
|
// 后面支持非异步
|
|
|
|
|
}
|
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
flowLogDetail.ElapsedMillisecond = stopwatch.ElapsedMilliseconds;
|
|
|
|
|