|
|
|
@ -29,7 +29,15 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
this.tenantDb = tenantDb;
|
|
|
|
|
this.serviceProvider = serviceProvider;
|
|
|
|
|
}
|
|
|
|
|
public async Task Run(TaskBaseTypeEnum taskBaseType, TaskManageOrderMessageInfo messageInfo, TaskBaseInfo taskInfo, TaskFlowDataContext dataContext)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 执行
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskBaseType">任务类型</param>
|
|
|
|
|
/// <param name="messageInfo">任务原始接收信息</param>
|
|
|
|
|
/// <param name="taskInfo">任务基础信息</param>
|
|
|
|
|
/// <param name="dataContext">原始入参数据</param>
|
|
|
|
|
/// <returns>(执行日志Id,模块是否全部执行完成,模块执行结果是否全部为success)</returns>
|
|
|
|
|
public async Task<(long flowLogId, bool isAllComplete, bool isAllSuccess)> Run(TaskBaseTypeEnum taskBaseType, TaskManageOrderMessageInfo messageInfo, TaskBaseInfo taskInfo, TaskFlowDataContext dataContext)
|
|
|
|
|
{
|
|
|
|
|
if (taskInfo == null)
|
|
|
|
|
{
|
|
|
|
@ -52,8 +60,9 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
IsMatch = false,
|
|
|
|
|
TaskId = taskInfo.Id,
|
|
|
|
|
TaskType = taskBaseType.ToString(),
|
|
|
|
|
ExecuteStatus = 2,
|
|
|
|
|
ExceptionMessage = msg
|
|
|
|
|
IsComplete = false,
|
|
|
|
|
ExceptionMessage = msg,
|
|
|
|
|
IsSuccess = false,
|
|
|
|
|
};
|
|
|
|
|
await tenantDb.Insertable(log).ExecuteCommandAsync();
|
|
|
|
|
throw new Exception(msg);
|
|
|
|
@ -150,7 +159,8 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
MatchMainConfigId = targetConfig.Id,
|
|
|
|
|
ConfigList = JsonConvert.SerializeObject(configList),
|
|
|
|
|
ModuleList = JsonConvert.SerializeObject(moduleList),
|
|
|
|
|
ExecuteStatus = 1
|
|
|
|
|
IsComplete = true,
|
|
|
|
|
IsSuccess = true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var configItem in configList)
|
|
|
|
@ -212,31 +222,41 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
|
|
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
|
|
var invokeResult = method.Invoke(imp, new object[] { dataContext });
|
|
|
|
|
// 这里需要取一下返回值
|
|
|
|
|
//var b = invokeResult as DataResult;
|
|
|
|
|
//var c = invokeResult as Task<DataResult>;
|
|
|
|
|
//var d = c.Result;
|
|
|
|
|
if (invokeResult is DataResult result)
|
|
|
|
|
var resultTemp = method.Invoke(imp, new object[] { dataContext });
|
|
|
|
|
if (resultTemp is DataResult result1 && result1 != null)
|
|
|
|
|
{
|
|
|
|
|
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(result1);
|
|
|
|
|
flowLogDetail.IsSuccess = result1.Succeeded;
|
|
|
|
|
|
|
|
|
|
if (!result1.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
flowLog.IsSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
else if (invokeResult is Task<DataResult> result2)
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
flowLog.IsSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
flowLogDetail.ElapsedMillisecond = stopwatch.ElapsedMilliseconds;
|
|
|
|
|
flowLogDetail.ExecuteStatus = 1;
|
|
|
|
|
flowLogDetail.IsComplete = true;
|
|
|
|
|
|
|
|
|
|
await tenantDb.Insertable(flowLogDetail).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
flowLog.ExecuteStatus = 2;
|
|
|
|
|
flowLog.IsComplete = false;
|
|
|
|
|
flowLog.IsSuccess = false;
|
|
|
|
|
|
|
|
|
|
flowLogDetail.IsComplete = false;
|
|
|
|
|
flowLogDetail.IsSuccess = false;
|
|
|
|
|
flowLogDetail.ExceptionMessage = WriteLog("", ex);
|
|
|
|
|
flowLogDetail.ExecuteStatus = 2;
|
|
|
|
|
await tenantDb.Insertable(flowLogDetail).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
if (configItem.IsExceptionContinue)
|
|
|
|
@ -251,6 +271,7 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await tenantDb.Insertable(flowLog).ExecuteCommandAsync();
|
|
|
|
|
return (flowLog.Id, flowLog.IsComplete, flowLog.IsSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|