mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
重写了Emit构造委托的执行
This commit is contained in:
@@ -24,13 +24,12 @@ namespace Serein.NodeFlow.Model
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
//public override object? Executing(IDynamicContext context)
|
||||
public override Task<object?> ExecutingAsync(IDynamicContext context)
|
||||
public override async Task<object?> ExecutingAsync(IDynamicContext context)
|
||||
{
|
||||
// 条件区域中遍历每个条件节点
|
||||
foreach (SingleConditionNode? node in ConditionNodes)
|
||||
{
|
||||
var state = Judge(context, node);
|
||||
var state = await JudgeAsync(context, node);
|
||||
NextOrientation = state; // 每次判读完成后,设置区域后继方向为判断结果
|
||||
if (state != ConnectionType.IsSucceed)
|
||||
{
|
||||
@@ -42,11 +41,11 @@ namespace Serein.NodeFlow.Model
|
||||
}
|
||||
|
||||
|
||||
private ConnectionType Judge(IDynamicContext context, SingleConditionNode node)
|
||||
private async Task<ConnectionType> JudgeAsync(IDynamicContext context, SingleConditionNode node)
|
||||
{
|
||||
try
|
||||
{
|
||||
node.ExecutingAsync(context);
|
||||
await node.ExecutingAsync(context);
|
||||
return node.NextOrientation;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -40,32 +40,46 @@ namespace Serein.NodeFlow.Model
|
||||
object instance = md.ActingInstance;
|
||||
try
|
||||
{
|
||||
Task<IFlipflopContext> flipflopTask;
|
||||
var args = GetParameters(context, this, md);
|
||||
var delType = dd.EmitMethodType;
|
||||
var del = dd.EmitDelegate;
|
||||
if (delType == EmitHelper.EmitMethodType.HasResultTask && del is Func<object, object?[]?, Task<object>> hasResultTask)
|
||||
var result = await dd.Invoke(md.ActingInstance, args);
|
||||
if (result is IFlipflopContext flipflopContext)
|
||||
{
|
||||
var flipflopTaskObj = await hasResultTask(instance, args);
|
||||
if(flipflopTaskObj is IFlipflopContext flipflopContext)
|
||||
NextOrientation = flipflopContext.State.ToContentType();
|
||||
if (flipflopContext.TriggerData is null || flipflopContext.TriggerData.Type == Library.NodeFlow.Tool.TriggerType.Overtime)
|
||||
{
|
||||
NextOrientation = flipflopContext.State.ToContentType();
|
||||
if (flipflopContext.TriggerData is null || flipflopContext.TriggerData.Type == Library.NodeFlow.Tool.TriggerType.Overtime)
|
||||
{
|
||||
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
|
||||
}
|
||||
return flipflopContext.TriggerData.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FlipflopException("触发器节点返回了非预期的类型", true, FlipflopException.CancelClass.Flow);
|
||||
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
|
||||
}
|
||||
return flipflopContext.TriggerData.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FlipflopException("触发器节点构造了非预期的委托", true, FlipflopException.CancelClass.Flow);
|
||||
throw new FlipflopException("触发器节点返回了非预期的类型", true, FlipflopException.CancelClass.Flow);
|
||||
}
|
||||
|
||||
// Task<IFlipflopContext> flipflopTask;
|
||||
//var delType = dd.EmitMethodType;
|
||||
//var del = dd.EmitDelegate;
|
||||
//if (delType == EmitHelper.EmitMethodType.HasResultTask && del is Func<object, object?[]?, Task<object>> hasResultTask)
|
||||
//{
|
||||
// var flipflopTaskObj = await hasResultTask(instance, args);
|
||||
// if(flipflopTaskObj is IFlipflopContext flipflopContext)
|
||||
// {
|
||||
// NextOrientation = flipflopContext.State.ToContentType();
|
||||
// if (flipflopContext.TriggerData is null || flipflopContext.TriggerData.Type == Library.NodeFlow.Tool.TriggerType.Overtime)
|
||||
// {
|
||||
// throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
|
||||
// }
|
||||
// return flipflopContext.TriggerData.Value;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new FlipflopException("触发器节点返回了非预期的类型", true, FlipflopException.CancelClass.Flow);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// throw new FlipflopException("触发器节点构造了非预期的委托", true, FlipflopException.CancelClass.Flow);
|
||||
//}
|
||||
|
||||
}
|
||||
catch (FlipflopException ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user