mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
更改了日志输出,更改了ChannelFlowTrigger存在的内存泄漏(取消超时机制)
This commit is contained in:
@@ -15,12 +15,12 @@ namespace Serein.NodeFlow.Model
|
||||
if (base.MethodDetails.ExplicitDatas.Length > 0)
|
||||
{
|
||||
return MethodDetails.ExplicitDatas
|
||||
.Select(it => new Parameterdata
|
||||
{
|
||||
State = it.IsExplicitData,
|
||||
Value = it.DataValue,
|
||||
})
|
||||
.ToArray();
|
||||
.Select(it => new Parameterdata
|
||||
{
|
||||
State = it.IsExplicitData,
|
||||
Value = it.DataValue,
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -22,31 +22,49 @@ namespace Serein.NodeFlow.Model
|
||||
public override async Task<object?> ExecutingAsync(IDynamicContext context)
|
||||
{
|
||||
#region 执行前中断
|
||||
if (TryCreateInterruptTask(context, this, out Task<CancelType>? task))
|
||||
if (DebugSetting.IsInterrupt && TryCreateInterruptTask(context, this, out Task<CancelType>? task)) // 执行触发前
|
||||
{
|
||||
string guid = this.Guid.ToString();
|
||||
this.CancelInterruptCallback ??= () => context.FlowEnvironment.ChannelFlowInterrupt.TriggerSignal(guid);
|
||||
var cancelType = await task!;
|
||||
task?.ToString();
|
||||
await Console.Out.WriteLineAsync($"[{this.MethodDetails.MethodName}]中断已{(cancelType == CancelType.Manual ? "手动取消" : "自动取消")},开始执行后继分支");
|
||||
}
|
||||
#endregion
|
||||
|
||||
MethodDetails md = MethodDetails;
|
||||
Delegate del = md.MethodDelegate;
|
||||
var del = md.MethodDelegate.Clone();
|
||||
object instance = md.ActingInstance;
|
||||
var haveParameter = md.ExplicitDatas.Length >= 0;
|
||||
// Task<IFlipflopContext>? flipflopTask = null;
|
||||
try
|
||||
{
|
||||
// 调用委托并获取结果
|
||||
Task<IFlipflopContext> flipflopTask = haveParameter switch
|
||||
Task<IFlipflopContext> flipflopTask = md.ExplicitDatas.Length switch
|
||||
{
|
||||
true => ((Func<object, object?[]?, Task<IFlipflopContext>>)del).Invoke(instance, GetParameters(context, md)), // 执行流程中的触发器方法时获取入参参数
|
||||
false => ((Func<object, Task<IFlipflopContext>>)del).Invoke(instance),
|
||||
0 => ((Func<object, Task<IFlipflopContext>>)del).Invoke(md.ActingInstance),
|
||||
_ => ((Func<object, object?[]?, Task<IFlipflopContext>>)del).Invoke(md.ActingInstance, GetParameters(context, md)), // 执行流程中的触发器方法时获取入参参数
|
||||
};
|
||||
|
||||
//object?[]? parameters;
|
||||
//object? result = null;
|
||||
//if (haveParameter)
|
||||
//{
|
||||
// var data = GetParameters(context, md);
|
||||
// parameters = [instance, data];
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// parameters = [instance];
|
||||
//}
|
||||
//flipflopTask = del.DynamicInvoke(parameters) as Task<IFlipflopContext>;
|
||||
//if (flipflopTask == null)
|
||||
//{
|
||||
// throw new FlipflopException(base.MethodDetails.MethodName + "触发器返回值非 Task<IFlipflopContext> 类型");
|
||||
//}
|
||||
IFlipflopContext flipflopContext = (await flipflopTask) ?? throw new FlipflopException("没有返回上下文");
|
||||
NextOrientation = flipflopContext.State.ToContentType();
|
||||
if(flipflopContext.TriggerData.Type == Library.NodeFlow.Tool.TriggerType.Overtime)
|
||||
if(flipflopContext.TriggerData is null || flipflopContext.TriggerData.Type == Library.NodeFlow.Tool.TriggerType.Overtime)
|
||||
{
|
||||
throw new FlipflopException("");
|
||||
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid"+base.Guid);
|
||||
}
|
||||
return flipflopContext.TriggerData.Value;
|
||||
}
|
||||
@@ -62,6 +80,10 @@ namespace Serein.NodeFlow.Model
|
||||
RuningException = ex;
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// flipflopTask?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
internal override Parameterdata[] GetParameterdatas()
|
||||
|
||||
Reference in New Issue
Block a user