设计了流程接口节点,能够切换本节点数据、目标节点数据,目前还有数据来源相关操作没有实现

This commit is contained in:
fengjiayi
2025-05-28 23:19:00 +08:00
parent f7cae3493f
commit a5715be929
44 changed files with 1064 additions and 277 deletions

View File

@@ -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();

View File

@@ -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;
}
}
}
}
}

View File

@@ -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
}
}
}
}
}

View File

@@ -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)
{

View File

@@ -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,