mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
优化了流程的进行
This commit is contained in:
@@ -26,50 +26,38 @@ namespace Serein.NodeFlow.Model
|
||||
/// <returns></returns>
|
||||
public override object? Execute(IDynamicContext context)
|
||||
{
|
||||
// bool allTrue = ConditionNodes.All(condition => Judge(context,condition.MethodDetails));
|
||||
// bool IsAllTrue = true; // 初始化为 true
|
||||
FlowState = FlowStateType.Succeed;
|
||||
// NextOrientation = ConnectionType.IsSucceed;
|
||||
|
||||
// 条件区域中遍历每个条件节点
|
||||
foreach (SingleConditionNode? node in ConditionNodes)
|
||||
{
|
||||
var state = Judge(context, node);
|
||||
if (state == FlowStateType.Fail || FlowStateType.Fail == FlowStateType.Error)
|
||||
NextOrientation = state; // 每次判读完成后,设置区域后继方向为判断结果
|
||||
if (state != ConnectionType.IsSucceed)
|
||||
{
|
||||
FlowState = state;
|
||||
break;// 一旦发现条件为假,立即退出循环
|
||||
// 如果条件不通过,立刻推出循环
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return PreviousNode?.FlowData;
|
||||
//if (IsAllTrue)
|
||||
//{
|
||||
// foreach (var nextNode in TrueBranchNextNodes)
|
||||
// {
|
||||
// nextNode.ExecuteStack(context);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// foreach (var nextNode in FalseBranchNextNodes)
|
||||
// {
|
||||
// nextNode.ExecuteStack(context);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private FlowStateType Judge(IDynamicContext context, SingleConditionNode node)
|
||||
private ConnectionType Judge(IDynamicContext context, SingleConditionNode node)
|
||||
{
|
||||
try
|
||||
{
|
||||
node.Execute(context);
|
||||
return node.FlowState;
|
||||
return node.NextOrientation;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
return FlowStateType.Error;
|
||||
NextOrientation = ConnectionType.IsError;
|
||||
RuningException = ex;
|
||||
return ConnectionType.IsError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user