mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-08 10:40:48 +08:00
忘记改啥了*1
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Serein.NodeFlow.Model
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
public override void OnCreating()
|
||||
{
|
||||
Console.WriteLine("CompositeConditionNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace Serein.NodeFlow.Model
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
public override void OnCreating()
|
||||
{
|
||||
Console.WriteLine("SingleActionNode 暂未实现 OnLoading");
|
||||
// Console.WriteLine("SingleActionNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
public override ParameterData[] GetParameterdatas()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Library.Utils.SereinExpression;
|
||||
using System.ComponentModel;
|
||||
|
||||
@@ -22,14 +23,13 @@ namespace Serein.NodeFlow.Model
|
||||
/// 自定义参数值
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private object? _customData;
|
||||
private string? _customData;
|
||||
|
||||
/// <summary>
|
||||
/// 条件表达式
|
||||
/// </summary>
|
||||
[PropertyInfo(IsNotification = true)]
|
||||
private string _expression;
|
||||
|
||||
}
|
||||
|
||||
public partial class SingleConditionNode : NodeModelBase
|
||||
@@ -39,32 +39,9 @@ namespace Serein.NodeFlow.Model
|
||||
this.IsCustomData = false;
|
||||
this.CustomData = null;
|
||||
this.Expression = "PASS";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
{
|
||||
var pd = new ParameterDetails
|
||||
{
|
||||
Index = 0,
|
||||
Name = "Exp",
|
||||
DataType = typeof(object),
|
||||
ExplicitType = typeof(object),
|
||||
IsExplicitData = false,
|
||||
DataValue = string.Empty,
|
||||
ArgDataSourceNodeGuid = string.Empty,
|
||||
ArgDataSourceType = ConnectionArgSourceType.GetPreviousNodeData,
|
||||
NodeModel = this,
|
||||
Convertor = null,
|
||||
ExplicitTypeName = "Value",
|
||||
Items = Array.Empty<string>(),
|
||||
};
|
||||
|
||||
this.MethodDetails.ParameterDetailss = new ParameterDetails[] { pd };
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -138,36 +115,102 @@ namespace Serein.NodeFlow.Model
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override ParameterData[] GetParameterdatas()
|
||||
{
|
||||
var value = CustomData switch
|
||||
{
|
||||
Type when CustomData.GetType() == typeof(int)
|
||||
&& CustomData.GetType() == typeof(double)
|
||||
&& CustomData.GetType() == typeof(float)
|
||||
=> ((double)CustomData).ToString(),
|
||||
Type when CustomData.GetType() == typeof(bool) => ((bool)CustomData).ToString(),
|
||||
_ => CustomData?.ToString()!,
|
||||
};
|
||||
return [new ParameterData
|
||||
{
|
||||
State = IsCustomData,
|
||||
Expression = Expression,
|
||||
Value = value,
|
||||
}];
|
||||
var pd1 = MethodDetails.ParameterDetailss[0];
|
||||
var pd2 = MethodDetails.ParameterDetailss[1];
|
||||
var pd3 = MethodDetails.ParameterDetailss[2];
|
||||
return [
|
||||
new ParameterData // 保存表达式
|
||||
{
|
||||
Value = Expression ,
|
||||
SourceNodeGuid = pd1.ArgDataSourceNodeGuid,
|
||||
SourceType = pd1.ArgDataSourceType.ToString(),
|
||||
},
|
||||
new ParameterData // 保存自定义参数
|
||||
{
|
||||
Value = CustomData?.ToString() ,
|
||||
SourceNodeGuid = pd2.ArgDataSourceNodeGuid,
|
||||
SourceType = pd2.ArgDataSourceType.ToString(),
|
||||
},
|
||||
new ParameterData // 参数来源状态
|
||||
{
|
||||
Value = IsCustomData.ToString() ,
|
||||
SourceNodeGuid = pd3.ArgDataSourceNodeGuid,
|
||||
SourceType = pd3.ArgDataSourceType.ToString(),
|
||||
}];
|
||||
}
|
||||
|
||||
public override void OnCreating()
|
||||
{
|
||||
// 自定义节点初始化默认的参数实体
|
||||
var tmpParameterDetails = new ParameterDetails[3];
|
||||
for (int index = 0; index <= 2; index++)
|
||||
{
|
||||
tmpParameterDetails[index] = new ParameterDetails
|
||||
{
|
||||
Index = index,
|
||||
IsExplicitData = false,
|
||||
DataValue = string.Empty,
|
||||
ArgDataSourceNodeGuid = string.Empty,
|
||||
ArgDataSourceType = ConnectionArgSourceType.GetPreviousNodeData,
|
||||
NodeModel = this,
|
||||
Convertor = null,
|
||||
ExplicitTypeName = "Value",
|
||||
Items = Array.Empty<string>(),
|
||||
};
|
||||
}
|
||||
|
||||
var pd1 = tmpParameterDetails[0]; // 表达式
|
||||
var pd2 = tmpParameterDetails[1]; // 自定义参数
|
||||
var pd3 = tmpParameterDetails[2]; // 参数来源
|
||||
|
||||
// 表达式
|
||||
pd1.Name = nameof(Expression);
|
||||
pd1.DataType = typeof(string);
|
||||
pd1.ExplicitType = typeof(string);
|
||||
|
||||
// 自定义参数
|
||||
pd2.Name = nameof(CustomData);
|
||||
pd2.DataType = typeof(string);
|
||||
pd2.ExplicitType = typeof(string);
|
||||
|
||||
// 参数来源
|
||||
pd3.Name = nameof(IsCustomData);
|
||||
pd3.DataType = typeof(bool);
|
||||
pd3.ExplicitType = typeof(bool);
|
||||
|
||||
//this.MethodDetails.ParameterDetailss = new ParameterDetails[2] { pd1, pd2 };
|
||||
this.MethodDetails.ParameterDetailss = [..tmpParameterDetails];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override NodeModelBase LoadInfo(NodeInfo nodeInfo)
|
||||
{
|
||||
var node = this;
|
||||
node.Guid = nodeInfo.Guid;
|
||||
this.Guid = nodeInfo.Guid;
|
||||
this.Position = nodeInfo.Position;// 加载位置信息
|
||||
|
||||
var pdInfo1 = nodeInfo.ParameterData[0];
|
||||
this.Expression = pdInfo1.Value; // 加载表达式
|
||||
|
||||
var pdInfo2 = nodeInfo.ParameterData[1];
|
||||
this.CustomData = pdInfo2.Value; // 加载自定义参数信息
|
||||
|
||||
var pdInfo3 = nodeInfo.ParameterData[2];
|
||||
bool.TryParse(pdInfo3.Value,out var @bool); // 参数来源状态
|
||||
this.IsCustomData = @bool;
|
||||
|
||||
for (int i = 0; i < nodeInfo.ParameterData.Length; i++)
|
||||
{
|
||||
ParameterData? pd = nodeInfo.ParameterData[i];
|
||||
node.IsCustomData = pd.State;
|
||||
node.CustomData = pd.Value;
|
||||
node.Expression = pd.Expression;
|
||||
var pd = this.MethodDetails.ParameterDetailss[i]; // 本节点的参数信息
|
||||
ParameterData? pdInfo = nodeInfo.ParameterData[i]; // 项目文件的保存信息
|
||||
|
||||
pd.ArgDataSourceNodeGuid = pdInfo.SourceNodeGuid;
|
||||
pd.ArgDataSourceType = EnumHelper.ConvertEnum<ConnectionArgSourceType>(pdInfo.SourceType);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Library.Utils.SereinExpression;
|
||||
using System.Reactive;
|
||||
using System.Reflection.Metadata;
|
||||
@@ -32,14 +33,14 @@ namespace Serein.NodeFlow.Model
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
public override void OnCreating()
|
||||
{
|
||||
var pd = new ParameterDetails
|
||||
{
|
||||
Index = 0,
|
||||
Name = "Exp",
|
||||
DataType = typeof(object),
|
||||
ExplicitType = typeof(object),
|
||||
Name = nameof(Expression),
|
||||
DataType = typeof(string),
|
||||
ExplicitType = typeof(string),
|
||||
IsExplicitData = false,
|
||||
DataValue = string.Empty,
|
||||
ArgDataSourceNodeGuid = string.Empty,
|
||||
@@ -92,7 +93,7 @@ namespace Serein.NodeFlow.Model
|
||||
}
|
||||
|
||||
context.NextOrientation = ConnectionInvokeType.IsSucceed;
|
||||
return Task.FromResult(result);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -105,7 +106,11 @@ namespace Serein.NodeFlow.Model
|
||||
|
||||
public override ParameterData[] GetParameterdatas()
|
||||
{
|
||||
return [new ParameterData { Expression = Expression }];
|
||||
return [new ParameterData {
|
||||
Value = Expression,
|
||||
SourceNodeGuid = this.MethodDetails.ParameterDetailss[0].ArgDataSourceNodeGuid,
|
||||
SourceType = this.MethodDetails.ParameterDetailss[0].ArgDataSourceType.ToString(),
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -113,11 +118,17 @@ namespace Serein.NodeFlow.Model
|
||||
public override NodeModelBase LoadInfo(NodeInfo nodeInfo)
|
||||
{
|
||||
var node = this;
|
||||
this.Position = nodeInfo.Position;// 加载位置信息
|
||||
node.Guid = nodeInfo.Guid;
|
||||
this.Position = nodeInfo.Position;// 加载位置信息
|
||||
|
||||
var pdInfo1 = nodeInfo.ParameterData[0];
|
||||
node.Expression = pdInfo1.Value; // 加载表达式
|
||||
|
||||
for (int i = 0; i < nodeInfo.ParameterData.Length; i++)
|
||||
{
|
||||
node.Expression = nodeInfo.ParameterData[i].Expression;
|
||||
ParameterData? pd = nodeInfo.ParameterData[i];
|
||||
node.MethodDetails.ParameterDetailss[i].ArgDataSourceNodeGuid = pd.SourceNodeGuid;
|
||||
node.MethodDetails.ParameterDetailss[i].ArgDataSourceType = EnumHelper.ConvertEnum<ConnectionArgSourceType>(pd.SourceType);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace Serein.NodeFlow.Model
|
||||
/// <summary>
|
||||
/// 加载完成后调用的方法
|
||||
/// </summary>
|
||||
public override void OnLoading()
|
||||
public override void OnCreating()
|
||||
{
|
||||
Console.WriteLine("SingleFlipflopNode 暂未实现 OnLoading");
|
||||
// Console.WriteLine("SingleFlipflopNode 暂未实现 OnLoading");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,16 +50,18 @@ namespace Serein.NodeFlow.Model
|
||||
object instance = md.ActingInstance;
|
||||
try
|
||||
{
|
||||
|
||||
var args = await GetParametersAsync(context, this, md);
|
||||
var result = await dd.InvokeAsync(md.ActingInstance, args);
|
||||
dynamic flipflopContext = result;
|
||||
FlipflopStateType flipflopStateType = flipflopContext.State;
|
||||
// 因为这里会返回不确定的泛型 IFlipflopContext<TRsult>
|
||||
// 而我们只需要获取到 State 和 Value(返回的数据)
|
||||
dynamic dynamicFlipflopContext = await dd.InvokeAsync(md.ActingInstance, args);
|
||||
FlipflopStateType flipflopStateType = dynamicFlipflopContext.State;
|
||||
context.NextOrientation = flipflopStateType.ToContentType();
|
||||
if (flipflopContext.Type == TriggerType.Overtime)
|
||||
if (dynamicFlipflopContext.Type == TriggerType.Overtime)
|
||||
{
|
||||
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
|
||||
}
|
||||
return flipflopContext.Value;
|
||||
return dynamicFlipflopContext.Value;
|
||||
|
||||
}
|
||||
catch (FlipflopException ex)
|
||||
|
||||
Reference in New Issue
Block a user