1. 重新设计了 JSON门户类的实现

2. Script脚本添加了原始字符串的实现
3. 修复了Script中无法对  \" 双引号转义的问题
4. 新增了对于集合嵌套取值的支持(目前仅是集合取值)
5. 重新设计了FlowWorkManagement任务启动的逻辑,修复了触发器无法正常运行的问题
6. 在ScriptBaseFunc中新增了 json() 本地函数,支持将字符串转为IJsonToken进行取值。
7. EmitHelper对于集合取值时,反射获取“get_item”委托时存在看你多个MethodInfo,现在可以传入子项类型,帮助匹配目标重载方法
This commit is contained in:
fengjiayi
2025-07-31 23:59:31 +08:00
parent 5f6a58168a
commit 1bccccc835
36 changed files with 948 additions and 335 deletions

View File

@@ -59,7 +59,7 @@ namespace Serein.NodeFlow.Model.Nodes
if (token.IsCancellationRequested) { return null; }
}
MethodDetails? md = MethodDetails;
MethodDetails md = MethodDetails;
if (md is null)
{
throw new Exception($"节点{Guid}不存在方法信息请检查是否需要重写节点的ExecutingAsync");
@@ -71,7 +71,7 @@ namespace Serein.NodeFlow.Model.Nodes
if (md.IsStatic)
{
object[] args = await this.GetParametersAsync(context, token);
object[] args = md.ParameterDetailss.Length == 0 ? [] : await this.GetParametersAsync(context, token);
var result = await dd.InvokeAsync(null, args);
var flowReslt = FlowResult.OK(this.Guid, context, result);
return flowReslt;

View File

@@ -5,10 +5,22 @@ using System;
namespace Serein.NodeFlow.Model.Nodes
{
[FlowDataProperty(ValuePath = NodeValuePath.Node, IsNodeImp = true)]
public partial class SingleFlipflopNode
{
/// <summary>
/// <para>是否等待后继节点(仅对于全局触发器)</para>
/// <para>如果为 true则在触发器获取结果后等待后继节点执行完成才会调用触发器</para>
/// <para>如果为 false则触发器获取到结果后将使用 _ = Task.Run(...) 再次调用触发器</para>
/// </summary>
private bool _isWaitSuccessorNodes = true;
}
/// <summary>
/// 触发器节点
/// </summary>
public class SingleFlipflopNode : NodeModelBase
public partial class SingleFlipflopNode : NodeModelBase
{
/// <summary>
/// 构造一个新的单触发器节点实例。
@@ -29,46 +41,52 @@ namespace Serein.NodeFlow.Model.Nodes
/// <exception cref="Exception"></exception>
public override async Task<FlowResult> ExecutingAsync(IFlowContext context, CancellationToken token)
{
if (token.IsCancellationRequested)
{
return FlowResult.Fail(Guid, context, "流程操作已取消");
}
#region
if (DebugSetting.IsInterrupt) // 执行触发前
{
string guid = Guid.ToString();
SereinEnv.WriteLine(InfoType.INFO, $"[{MethodDetails.MethodName}]进入中断");
await DebugSetting.GetInterruptTask.Invoke();
await Console.Out.WriteLineAsync($"[{MethodDetails.MethodName}]中断已取消,开始执行后继分支");
SereinEnv.WriteLine(InfoType.INFO, $"[{MethodDetails.MethodName}]中断已取消,开始执行后继分支");
}
#endregion
MethodDetails md = MethodDetails;
if (!context.Env.TryGetDelegateDetails(md.AssemblyName, md.MethodName, out var dd)) // 流程运行到某个节点
{
throw new Exception("不存在对应委托");
context.Exit();
context.ExceptionOfRuning = new FlipflopException($"无法获取到委托 {md.MethodName} 的详细信息。请检查流程配置。");
return FlowResult.Fail(Guid, context, "不存在对应委托");
}
var instance = Env.FlowControl.IOC.Get(md.ActingInstanceType);
var ioc = Env.FlowControl.IOC;
var instance = ioc.Get(md.ActingInstanceType);
if (instance is null)
{
Env.FlowControl.IOC.Register(md.ActingInstanceType).Build();
instance = Env.FlowControl.IOC.Get(md.ActingInstanceType);
ioc.Register(md.ActingInstanceType).Build();
instance = ioc.Get(md.ActingInstanceType);
}
await dd.InvokeAsync(instance, [context]);
var args = await this.GetParametersAsync(context, token);
var args = MethodDetails.ParameterDetailss.Length == 0 ? [] : await this.GetParametersAsync(context, token);
// 因为这里会返回不确定的泛型 IFlipflopContext<TRsult>
// 而我们只需要获取到 State 和 Value返回的数据
// 所以使用 dynamic 类型接收
if (token.IsCancellationRequested)
{
return null;
}
dynamic dynamicFlipflopContext = await dd.InvokeAsync(instance, args);
FlipflopStateType flipflopStateType = dynamicFlipflopContext.State;
dynamic flipflopContext = await dd.InvokeAsync(instance, args);
FlipflopStateType flipflopStateType = flipflopContext.State;
context.NextOrientation = flipflopStateType.ToContentType();
if (dynamicFlipflopContext.Type == TriggerDescription.Overtime)
if (flipflopContext.Type == TriggerDescription.Overtime)
{
throw new FlipflopException(MethodDetails.MethodName + "触发器超时触发。Guid" + Guid);
}
object result = dynamicFlipflopContext.Value;
object result = flipflopContext.Value;
var flowReslt = FlowResult.OK(this.Guid, context, result);
return flowReslt;
}