mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-12 10:56:34 +08:00
设计了流程接口节点,能够切换本节点数据、目标节点数据,目前还有数据来源相关操作没有实现
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Library.Api
|
||||
@@ -11,6 +12,7 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
public interface IDynamicFlowNode
|
||||
{
|
||||
Task<FlowResult> ExecutingAsync(IDynamicContext context, CancellationToken token);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Serein.Library
|
||||
ParameterData = parameterData.ToArray(),
|
||||
ErrorNodes = errorNodes.ToArray(),
|
||||
Position = nodeModel.Position,
|
||||
IsProtectionParameter = nodeModel.MethodDetails.IsProtectionParameter,
|
||||
IsProtectionParameter = nodeModel.DebugSetting.IsProtectionParameter,
|
||||
IsInterrupt = nodeModel.DebugSetting.IsInterrupt,
|
||||
IsEnable = nodeModel.DebugSetting.IsEnable,
|
||||
ParentNodeGuid = nodeModel.ContainerNode?.Guid,
|
||||
@@ -139,7 +139,7 @@ namespace Serein.Library
|
||||
nodeModel.Guid = nodeInfo.Guid;
|
||||
nodeModel.Position = nodeInfo.Position ?? new PositionOfUI(0, 0);// 加载位置信息
|
||||
var md = nodeModel.MethodDetails; // 当前节点的方法说明
|
||||
nodeModel.MethodDetails.IsProtectionParameter = nodeInfo.IsProtectionParameter; // 保护参数
|
||||
nodeModel.DebugSetting.IsProtectionParameter = nodeInfo.IsProtectionParameter; // 保护参数
|
||||
nodeModel.DebugSetting.IsInterrupt = nodeInfo.IsInterrupt; // 是否中断
|
||||
nodeModel.DebugSetting.IsEnable = nodeInfo.IsEnable; // 是否使能
|
||||
nodeModel.IsPublic = nodeInfo.IsPublic; // 是否全局公开
|
||||
@@ -169,7 +169,7 @@ namespace Serein.Library
|
||||
|
||||
for (int i = 0; i < nodeInfo.ParameterData.Length; i++)
|
||||
{
|
||||
if (i >= pds.Length)
|
||||
if (i >= pds.Length && nodeModel.ControlType != NodeControlType.FlowCall)
|
||||
{
|
||||
nodeModel.Env.WriteLine(InfoType.ERROR, $"保存的参数数量大于方法此时的入参参数数量:[{nodeInfo.Guid}][{nodeInfo.MethodName}]");
|
||||
break;
|
||||
|
||||
@@ -30,12 +30,6 @@ namespace Serein.Library
|
||||
private string _assemblyName;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否保护参数
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private bool _isProtectionParameter;
|
||||
|
||||
/// <summary>
|
||||
/// 调用节点方法时需要的实例(多个相同的节点将拥有相同的类型)
|
||||
/// </summary>
|
||||
@@ -245,7 +239,6 @@ namespace Serein.Library
|
||||
ReturnType = this.ReturnType, // 拷贝
|
||||
MethodName = this.MethodName, // 拷贝
|
||||
MethodLockName = this.MethodLockName, // 拷贝
|
||||
IsProtectionParameter = this.IsProtectionParameter, // 拷贝
|
||||
ParamsArgIndex = this.ParamsArgIndex, // 拷贝
|
||||
ParameterDetailss = this.ParameterDetailss?.Select(p => p?.CloneOfModel(nodeModel)).ToArray(), // 拷贝属于节点方法的新入参描述
|
||||
};
|
||||
@@ -255,6 +248,10 @@ namespace Serein.Library
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.MethodName))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var tmp = this.MethodName.Split('.') ;
|
||||
var methodName = tmp[tmp.Length - 1];
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -22,6 +22,13 @@ namespace Serein.Library
|
||||
NodeModel = nodeModel;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否保护参数
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private bool _isProtectionParameter;
|
||||
|
||||
/// <summary>
|
||||
/// 对应的节点
|
||||
/// </summary>
|
||||
@@ -37,7 +44,7 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 是否中断节点。
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true, CustomCodeAtEnd = "ChangeInterruptState(value);")] // CustomCode = "NodeModel?.Env?.SetNodeInterruptAsync(NodeModel?.Guid, value);"
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private bool _isInterrupt = false;
|
||||
|
||||
}
|
||||
@@ -66,18 +73,16 @@ namespace Serein.Library
|
||||
public Func<Task> GetInterruptTask => _getInterruptTask;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 改变中断状态
|
||||
/// </summary>
|
||||
public void ChangeInterruptState(bool state)
|
||||
|
||||
partial void OnIsInterruptChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
if (state && _getInterruptTask is null)
|
||||
if (newValue && _getInterruptTask is null)
|
||||
{
|
||||
// 设置获取中断的委托
|
||||
_getInterruptTask = () => NodeModel.Env.IOC.Get<FlowInterruptTool>().WaitTriggerAsync(NodeModel.Guid);
|
||||
|
||||
|
||||
}
|
||||
else if (!state)
|
||||
else if (!newValue)
|
||||
{
|
||||
if (_getInterruptTask is null)
|
||||
{
|
||||
@@ -90,11 +95,13 @@ namespace Serein.Library
|
||||
_cancelInterrupt.Invoke();
|
||||
_getInterruptTask = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ namespace Serein.Library
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点基类(数据)
|
||||
/// </summary>
|
||||
[NodeProperty(ValuePath = NodeValuePath.Node)]
|
||||
public abstract partial class NodeModelBase : IDynamicFlowNode
|
||||
public abstract partial class NodeModelBase : INotifyPropertyChanged, IDynamicFlowNode
|
||||
{
|
||||
/// <summary>
|
||||
/// 节点运行环境
|
||||
@@ -56,9 +58,15 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 是否公开
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true, CustomCodeAtEnd = "NodePublicStateChanged();")]
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private bool _isPublic;
|
||||
|
||||
/* /// <summary>
|
||||
/// 是否保护参数
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private bool _isProtectionParameter;*/
|
||||
|
||||
/// <summary>
|
||||
/// 附加的调试功能
|
||||
/// </summary>
|
||||
@@ -68,7 +76,7 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 方法描述。包含参数信息。不包含Method与委托,如若需要调用对应的方法,需要通过MethodName从环境中获取委托进行调用。
|
||||
/// </summary>
|
||||
[PropertyInfo(IsProtection = true)]
|
||||
[PropertyInfo]
|
||||
private MethodDetails _methodDetails ;
|
||||
}
|
||||
|
||||
@@ -108,7 +116,7 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 不同分支的子节点(流程调用)
|
||||
/// </summary>
|
||||
public Dictionary<ConnectionInvokeType, List<NodeModelBase>> SuccessorNodes { get; }
|
||||
public Dictionary<ConnectionInvokeType, List<NodeModelBase>> SuccessorNodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 该节点的容器节点
|
||||
@@ -123,10 +131,9 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 节点公开状态发生改变
|
||||
/// </summary>
|
||||
private void NodePublicStateChanged()
|
||||
partial void OnIsPublicChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
|
||||
if (IsPublic)
|
||||
if (newValue)
|
||||
{
|
||||
// 公开节点
|
||||
if (!CanvasDetails.PublicNodes.Contains(this))
|
||||
@@ -143,6 +150,8 @@ namespace Serein.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,33 +62,37 @@ namespace Serein.Library
|
||||
{
|
||||
this.DebugSetting.CancelInterrupt?.Invoke();
|
||||
}
|
||||
this.DebugSetting.NodeModel = null;
|
||||
this.DebugSetting = null;
|
||||
if (this.MethodDetails.ParameterDetailss != null)
|
||||
|
||||
if (this.IsPublic)
|
||||
{
|
||||
foreach (var pd in this.MethodDetails.ParameterDetailss)
|
||||
{
|
||||
pd.DataValue = null;
|
||||
pd.Items = null;
|
||||
pd.NodeModel = null;
|
||||
pd.ExplicitType = null;
|
||||
pd.DataType = null;
|
||||
pd.Name = null;
|
||||
pd.ArgDataSourceNodeGuid = null;
|
||||
pd.InputType = ParameterValueInputType.Input;
|
||||
}
|
||||
this.CanvasDetails.PublicNodes.Remove(this);
|
||||
}
|
||||
|
||||
this.MethodDetails.ParameterDetailss = null;
|
||||
//this.MethodDetails.ActingInstance = null;
|
||||
this.MethodDetails.NodeModel = null;
|
||||
this.MethodDetails.ReturnType = null;
|
||||
this.MethodDetails.AssemblyName = null;
|
||||
this.MethodDetails.MethodAnotherName = null;
|
||||
this.MethodDetails.MethodLockName = null;
|
||||
this.MethodDetails.MethodName = null;
|
||||
this.MethodDetails.ActingInstanceType = null;
|
||||
this.MethodDetails = null;
|
||||
this.DebugSetting.NodeModel = null;
|
||||
this.DebugSetting = null;
|
||||
if(this.MethodDetails is not null)
|
||||
{
|
||||
if (this.MethodDetails.ParameterDetailss != null)
|
||||
{
|
||||
foreach (var pd in this.MethodDetails.ParameterDetailss)
|
||||
{
|
||||
pd.DataValue = null;
|
||||
pd.Items = null;
|
||||
pd.NodeModel = null;
|
||||
pd.ExplicitType = null;
|
||||
pd.DataType = null;
|
||||
pd.Name = null;
|
||||
pd.ArgDataSourceNodeGuid = null;
|
||||
pd.InputType = ParameterValueInputType.Input;
|
||||
}
|
||||
}
|
||||
this.MethodDetails.ParameterDetailss = null;
|
||||
this.MethodDetails.NodeModel = null;
|
||||
this.MethodDetails.ReturnType = null;
|
||||
this.MethodDetails.ActingInstanceType = null;
|
||||
this.MethodDetails = null;
|
||||
}
|
||||
|
||||
this.Position = null;
|
||||
this.DisplayName = null;
|
||||
|
||||
@@ -99,6 +103,8 @@ namespace Serein.Library
|
||||
/// 执行节点对应的方法
|
||||
/// </summary>
|
||||
/// <param name="context">流程上下文</param>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="args">自定义参数</param>
|
||||
/// <returns>节点传回数据对象</returns>
|
||||
public virtual async Task<FlowResult> ExecutingAsync(IDynamicContext context, CancellationToken token)
|
||||
{
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Serein.Library
|
||||
//Convertor = this.Convertor,
|
||||
DataType = this.DataType,
|
||||
Name = this.Name,
|
||||
DataValue = string.IsNullOrEmpty(DataValue) ? string.Empty : DataValue,
|
||||
DataValue = this.DataValue,
|
||||
Items = this.Items?.Select(it => it).ToArray(),
|
||||
IsParams = this.IsParams,
|
||||
Description = this.Description,
|
||||
|
||||
Reference in New Issue
Block a user