mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-02 15:50:47 +08:00
解决了流程接口节点执行后,后续调用的节点无法正确获取入参的问题
This commit is contained in:
@@ -37,6 +37,24 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
Exception ExceptionOfRuning { get; set; }
|
||||
|
||||
/* /// <summary>
|
||||
/// 忽略处理该节点流程
|
||||
/// </summary>
|
||||
void IgnoreFlowHandle(NodeModelBase node);
|
||||
/// <summary>
|
||||
/// 获取此次流程处理状态
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
bool GetIgnodeFlowStateUpload(NodeModelBase node);
|
||||
/// <summary>
|
||||
/// 恢复流程处理状态
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
void RecoverIgnodeFlowStateUpload(NodeModelBase node);*/
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置节点的运行时上一节点,用以多线程中隔开不同流程的数据
|
||||
/// </summary>
|
||||
|
||||
@@ -209,14 +209,11 @@ namespace Serein.Library
|
||||
&& token.IsCancellationRequested == false // 没有取消
|
||||
&& stack.Count > 0) // 循环中直到栈为空才会退出循环
|
||||
{
|
||||
|
||||
|
||||
#if DEBUG
|
||||
await Task.Delay(1);
|
||||
#endif
|
||||
|
||||
#region 执行相关
|
||||
|
||||
// 从栈中弹出一个节点作为当前节点进行处理
|
||||
var currentNode = stack.Pop();
|
||||
context.NextOrientation = ConnectionInvokeType.None; // 重置上下文状态
|
||||
@@ -238,11 +235,14 @@ namespace Serein.Library
|
||||
context.NextOrientation = ConnectionInvokeType.IsError;
|
||||
context.ExceptionOfRuning = ex;
|
||||
}
|
||||
context.AddOrUpdate(currentNode, flowResult); // 上下文中更新数据
|
||||
#endregion
|
||||
|
||||
#region 执行完成
|
||||
|
||||
//var ignodeState = context.GetIgnodeFlowStateUpload(currentNode);
|
||||
// 更新数据
|
||||
//if(!ignodeState)
|
||||
context.AddOrUpdate(currentNode, flowResult); // 上下文中更新数据
|
||||
|
||||
// 首先将指定类别后继分支的所有节点逆序推入栈中
|
||||
var nextNodes = currentNode.SuccessorNodes[context.NextOrientation];
|
||||
for (int index = nextNodes.Count - 1; index >= 0; index--)
|
||||
@@ -250,7 +250,8 @@ namespace Serein.Library
|
||||
// 筛选出启用的节点的节点
|
||||
if (nextNodes[index].DebugSetting.IsEnable)
|
||||
{
|
||||
context.SetPreviousNode(nextNodes[index], currentNode);
|
||||
//if (!ignodeState)
|
||||
context.SetPreviousNode(nextNodes[index], currentNode);
|
||||
stack.Push(nextNodes[index]);
|
||||
}
|
||||
}
|
||||
@@ -261,10 +262,12 @@ namespace Serein.Library
|
||||
// 筛选出启用的节点的节点
|
||||
if (upstreamNodes[index].DebugSetting.IsEnable)
|
||||
{
|
||||
context.SetPreviousNode(upstreamNodes[index], currentNode);
|
||||
//if (!ignodeState)
|
||||
context.SetPreviousNode(upstreamNodes[index], currentNode);
|
||||
stack.Push(upstreamNodes[index]);
|
||||
}
|
||||
}
|
||||
//context.RecoverIgnodeFlowStateUpload(currentNode);
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace Serein.Library
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<NodeModelBase, NodeModelBase> dictPreviousNodes = new ConcurrentDictionary<NodeModelBase, NodeModelBase>();
|
||||
|
||||
/// <summary>
|
||||
/// 记录忽略处理的流程
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<NodeModelBase, bool> dictIgnoreNodeFlow = new ConcurrentDictionary<NodeModelBase, bool>();
|
||||
|
||||
/// <summary>
|
||||
/// 设置运行时上一节点
|
||||
/// </summary>
|
||||
@@ -66,6 +71,35 @@ namespace Serein.Library
|
||||
dictPreviousNodes.AddOrUpdate(currentNodeModel, (_) => PreviousNode, (o, n) => PreviousNode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略处理该节点流程
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
public void IgnoreFlowHandle(NodeModelBase node)
|
||||
{
|
||||
dictIgnoreNodeFlow.AddOrUpdate(node, (o) => true, (o, n) => true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取此次流程处理状态
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetIgnodeFlowStateUpload(NodeModelBase node)
|
||||
{
|
||||
return dictIgnoreNodeFlow.TryGetValue(node, out var state) ? state : false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 恢复流程处理状态
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
public void RecoverIgnodeFlowStateUpload(NodeModelBase node)
|
||||
{
|
||||
dictIgnoreNodeFlow.AddOrUpdate(node, (o) => false, (o, n) => false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前节点的运行时上一节点
|
||||
/// </summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using Serein.Library.Utils;
|
||||
using Serein.Library.Utils.SereinExpression;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
@@ -254,10 +255,23 @@ namespace Serein.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if(!env.TryGetNodeModel(ArgDataSourceNodeGuid, out var argSourceNodeModel))
|
||||
{
|
||||
throw new Exception($"[arg{Index}][{Name}][{DataType}]需要节点[{ArgDataSourceNodeGuid}]的参数,但节点不存在");
|
||||
}
|
||||
|
||||
// 如果是公开的节点,需要判断上下文调用中是否存在流程接口节点
|
||||
if (argSourceNodeModel.IsPublic)
|
||||
{
|
||||
var pn = context.GetPreviousNode(NodeModel);
|
||||
if(pn.ControlType == NodeControlType.FlowCall)
|
||||
{
|
||||
argSourceNodeModel = pn;
|
||||
}
|
||||
}
|
||||
|
||||
if (ArgDataSourceType == ConnectionArgSourceType.GetOtherNodeData)
|
||||
{
|
||||
var flowData = context.GetFlowData(argSourceNodeModel);
|
||||
|
||||
@@ -193,7 +193,32 @@ namespace Serein.NodeFlow.Model
|
||||
this.MethodDetails = targetNode.MethodDetails;
|
||||
}
|
||||
this.SuccessorNodes = targetNode.SuccessorNodes;
|
||||
return await base.ExecutingAsync(context, token);
|
||||
var flowData = await base.ExecutingAsync(context, token);
|
||||
|
||||
if (IsShareParam)
|
||||
{
|
||||
// 设置运行时上一节点
|
||||
|
||||
// 此处代码与SereinFlow.Library.FlowNode.ParameterDetails
|
||||
// ToMethodArgData()方法中判断流程接口节点分支逻辑耦合
|
||||
// 不要轻易修改
|
||||
context.AddOrUpdate(targetNode, flowData);
|
||||
foreach (ConnectionInvokeType ctType in NodeStaticConfig.ConnectionTypes)
|
||||
{
|
||||
if (this.SuccessorNodes[ctType] == null) continue;
|
||||
foreach (var node in this.SuccessorNodes[ctType])
|
||||
{
|
||||
if (node.DebugSetting.IsEnable)
|
||||
{
|
||||
|
||||
context.SetPreviousNode(node, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return flowData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Serein.Workbench.ViewModels
|
||||
|
||||
partial void OnSelectedTabChanged(FlowEditorTabModel value)
|
||||
{
|
||||
flowNodeService.CurrentSelectCanvas = value.Content;
|
||||
flowNodeService.CurrentSelectCanvas = value?.Content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user