using Serein.DynamicFlow;
using Serein.DynamicFlow.Tool;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Threading.Tasks;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
namespace Serein.DynamicFlow.NodeModel
{
public enum ConnectionType
{
IsTrue,
IsFalse,
IsEx,
}
///
/// 节点基类(数据):条件控件,动作控件,条件区域,动作区域
///
public abstract class NodeBase : IDynamicFlowNode
{
public MethodDetails MethodDetails { get; set; }
public string Guid { get; set; }
public string DisplayName { get; set; }
public bool IsStart { get; set; }
public string DelegateName { get; set; }
///
/// 运行时的上一节点
///
public NodeBase? PreviousNode { get; set; }
///
/// 上一节点集合
///
public List PreviousNodes { get; set; } = [];
///
/// 下一节点集合(真分支)
///
public List TrueBranch { get; set; } = [];
///
/// 下一节点集合(假分支)
///
public List FalseBranch { get; set; } = [];
///
/// 异常分支
///
public List ExBranch { get; set; } = [];
///
/// 当前状态(进入真分支还是假分支,异常分支在异常中确定)
///
public bool FlowState { get; set; } = true;
//public ConnectionType NextType { get; set; } = ConnectionType.IsTrue;
///
/// 当前传递数据
///
public object? FlowData { get; set; } = null;
// 正常流程节点调用
public virtual object? Execute(DynamicContext context)
{
MethodDetails md = MethodDetails;
object? result = null;
if (DelegateCache.GlobalDicDelegates.TryGetValue(md.MethodName, out Delegate del))
{
if (md.ExplicitDatas.Length == 0)
{
if (md.ReturnType == typeof(void))
{
((Action