mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-04 15:26:34 +08:00
修改了流程运行中的bug
This commit is contained in:
@@ -1438,8 +1438,7 @@ namespace Serein.NodeFlow.Env
|
||||
try
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom(dllPath); // 加载DLL文件
|
||||
Type[] types = assembly.GetTypes(); // 获取程序集中的所有类型
|
||||
|
||||
List<Type> types = assembly.GetTypes().ToList(); // 获取程序集中的所有类型
|
||||
Dictionary<RegisterSequence, List<Type>> autoRegisterTypes = new Dictionary<RegisterSequence, List<Type>>();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
@@ -1720,10 +1719,6 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
if (!string.IsNullOrEmpty(toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceNodeGuid))
|
||||
{
|
||||
//if(toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceType == connectionArgSourceType)
|
||||
//{
|
||||
// return ;
|
||||
//}
|
||||
await RemoteConnectAsync(fromNode,toNode,argIndex); // 已经存在连接,将其移除
|
||||
}
|
||||
toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceNodeGuid = fromNode.Guid;
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace Serein.NodeFlow.Env
|
||||
var md = methodDetails.CloneOfNode(nodeModel.Env, nodeModel);
|
||||
nodeModel.DisplayName = md.MethodAnotherName;
|
||||
nodeModel.MethodDetails = md;
|
||||
|
||||
|
||||
nodeModel.OnLoading();
|
||||
return nodeModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,21 +169,6 @@ namespace Serein.NodeFlow
|
||||
|
||||
#endregion
|
||||
|
||||
#region 检查并修正初始化、加载时、退出时方法作用的对象,保证后续不会报错(已注释)
|
||||
//foreach (var md in initMethods) // 初始化
|
||||
//{
|
||||
// md.ActingInstance ??= Context.SereinIoc.GetOrRegisterInstantiate(md.ActingInstanceType);
|
||||
//}
|
||||
//foreach (var md in loadingMethods) // 加载
|
||||
//{
|
||||
// md.ActingInstance ??= Context.SereinIoc.GetOrRegisterInstantiate(md.ActingInstanceType);
|
||||
//}
|
||||
//foreach (var md in exitMethods) // 初始化
|
||||
//{
|
||||
// md.ActingInstance ??= Context.SereinIoc.GetOrRegisterInstantiate(md.ActingInstanceType);
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 执行初始化,绑定IOC容器,再执行加载时
|
||||
|
||||
if (autoRegisterTypes.TryGetValue(RegisterSequence.FlowInit, out var flowInitTypes))
|
||||
@@ -356,7 +341,9 @@ namespace Serein.NodeFlow
|
||||
/// <param name="env">流程运行全局环境</param>
|
||||
/// <param name="singleFlipFlopNode">需要全局监听信号的触发器</param>
|
||||
/// <returns></returns>
|
||||
private async Task FlipflopExecuteAsync(IFlowEnvironment env, SingleFlipflopNode singleFlipFlopNode, CancellationTokenSource cts)
|
||||
private async Task FlipflopExecuteAsync(IFlowEnvironment env,
|
||||
SingleFlipflopNode singleFlipFlopNode,
|
||||
CancellationTokenSource cts)
|
||||
{
|
||||
if(_flipFlopCts is null)
|
||||
{
|
||||
@@ -369,34 +356,38 @@ namespace Serein.NodeFlow
|
||||
try
|
||||
{
|
||||
var newFlowData = await singleFlipFlopNode.ExecutingAsync(context); // 获取触发器等待Task
|
||||
context.AddOrUpdate(singleFlipFlopNode.Guid, newFlowData);
|
||||
await NodeModelBase.RefreshFlowDataAndExpInterrupt(context, singleFlipFlopNode, newFlowData); // 全局触发器触发后刷新该触发器的节点数据
|
||||
if (context.NextOrientation == ConnectionInvokeType.None)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var nextNodes = singleFlipFlopNode.SuccessorNodes[context.NextOrientation];
|
||||
for (int i = nextNodes.Count - 1; i >= 0 && !_flipFlopCts.IsCancellationRequested; i--)
|
||||
{
|
||||
// 筛选出启用的节点
|
||||
if (!nextNodes[i].DebugSetting.IsEnable)
|
||||
_ = Task.Run(async () => {
|
||||
var nextNodes = singleFlipFlopNode.SuccessorNodes[context.NextOrientation];
|
||||
for (int i = nextNodes.Count - 1; i >= 0 && !_flipFlopCts.IsCancellationRequested; i--)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 筛选出启用的节点
|
||||
if (!nextNodes[i].DebugSetting.IsEnable)
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
|
||||
nextNodes[i].PreviousNode = singleFlipFlopNode;
|
||||
if (nextNodes[i].DebugSetting.IsInterrupt) // 执行触发前
|
||||
{
|
||||
var cancelType = await nextNodes[i].DebugSetting.GetInterruptTask();
|
||||
await Console.Out.WriteLineAsync($"[{nextNodes[i].MethodDetails.MethodName}]中断已{cancelType},开始执行后继分支");
|
||||
context.SetPreviousNode(nextNodes[i], singleFlipFlopNode);
|
||||
if (nextNodes[i].DebugSetting.IsInterrupt) // 执行触发前
|
||||
{
|
||||
var cancelType = await nextNodes[i].DebugSetting.GetInterruptTask();
|
||||
await Console.Out.WriteLineAsync($"[{nextNodes[i].MethodDetails.MethodName}]中断已{cancelType},开始执行后继分支");
|
||||
}
|
||||
await nextNodes[i].StartFlowAsync(context); // 启动执行触发器后继分支的节点
|
||||
context.Exit();
|
||||
}
|
||||
await nextNodes[i].StartFlowAsync(context); // 启动执行触发器后继分支的节点
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
catch (FlipflopException ex)
|
||||
{
|
||||
await Console.Out.WriteLineAsync($"触发器[{singleFlipFlopNode.MethodDetails.MethodName}]因非预期异常终止。"+ex.Message);
|
||||
if (ex.Type == FlipflopException.CancelClass.Flow)
|
||||
if (ex.Type == FlipflopException.CancelClass.CancelFlow)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -407,7 +398,7 @@ namespace Serein.NodeFlow
|
||||
}
|
||||
finally
|
||||
{
|
||||
context.Exit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,13 @@ namespace Serein.NodeFlow.Model
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
{
|
||||
Console.WriteLine("CompositeConditionNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
public void AddNode(SingleConditionNode node)
|
||||
{
|
||||
@@ -59,7 +66,8 @@ namespace Serein.NodeFlow.Model
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(context.GetFlowData(PreviousNode.Guid)); // 条件区域透传上一节点的数据
|
||||
//var previousNode = context.GetPreviousNode()
|
||||
return Task.FromResult(context.TransmissionData(this)); // 条件区域透传上一节点的数据
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,15 @@ namespace Serein.NodeFlow.Model
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
{
|
||||
Console.WriteLine("SingleActionNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
public override ParameterData[] GetParameterdatas()
|
||||
{
|
||||
if (base.MethodDetails.ParameterDetailss.Length > 0)
|
||||
|
||||
@@ -39,8 +39,34 @@ namespace Serein.NodeFlow.Model
|
||||
this.IsCustomData = false;
|
||||
this.CustomData = null;
|
||||
this.Expression = "PASS";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
{
|
||||
var pd = new ParameterDetails
|
||||
{
|
||||
Index = 0,
|
||||
Name = "Exp",
|
||||
DataType = typeof(object),
|
||||
ExplicitType = typeof(object),
|
||||
IsExplicitData = false,
|
||||
DataValue = string.Empty,
|
||||
ArgDataSourceNodeGuid = string.Empty,
|
||||
ArgDataSourceType = ConnectionArgSourceType.GetPreviousNodeData,
|
||||
NodeModel = this,
|
||||
Convertor = null,
|
||||
ExplicitTypeName = "Value",
|
||||
Items = Array.Empty<string>(),
|
||||
};
|
||||
|
||||
this.MethodDetails.ParameterDetailss = new ParameterDetails[] { pd };
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重写节点的方法执行
|
||||
/// </summary>
|
||||
@@ -50,7 +76,7 @@ namespace Serein.NodeFlow.Model
|
||||
{
|
||||
// 接收上一节点参数or自定义参数内容
|
||||
object? parameter;
|
||||
object? result = context.GetFlowData(PreviousNode.Guid); // 条件节点透传上一节点的数据
|
||||
object? result = context.TransmissionData(this); // 条件节点透传上一节点的数据
|
||||
if (IsCustomData) // 是否使用自定义参数
|
||||
{
|
||||
// 表达式获取上一节点数据
|
||||
|
||||
@@ -28,10 +28,18 @@ namespace Serein.NodeFlow.Model
|
||||
|
||||
}
|
||||
|
||||
//public override async Task<object?> Executing(IDynamicContext context)
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
{
|
||||
Console.WriteLine("SingleExpOpNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
|
||||
public override Task<object?> ExecutingAsync(IDynamicContext context)
|
||||
{
|
||||
var data = context.GetFlowData(PreviousNode.Guid); // 表达式节点使用上一节点数据
|
||||
var data = context.TransmissionData(this); // 表达式节点使用上一节点数据
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -16,6 +16,14 @@ namespace Serein.NodeFlow.Model
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
{
|
||||
Console.WriteLine("SingleFlipflopNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 执行触发器进行等待触发
|
||||
@@ -56,7 +64,7 @@ namespace Serein.NodeFlow.Model
|
||||
}
|
||||
catch (FlipflopException ex)
|
||||
{
|
||||
if(ex.Type == FlipflopException.CancelClass.Flow)
|
||||
if(ex.Type == FlipflopException.CancelClass.CancelFlow)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user