2024-09-12 20:32:54 +08:00
|
|
|
|
using Serein.Library.Api;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.Library.Entity;
|
2024-09-12 20:32:54 +08:00
|
|
|
|
using Serein.Library.Enums;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.NodeFlow.Base;
|
2024-09-16 19:53:36 +08:00
|
|
|
|
using Serein.NodeFlow.Tool.SereinExpression;
|
2024-09-15 22:07:10 +08:00
|
|
|
|
using System.Text;
|
2024-08-06 16:09:46 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Serein.NodeFlow.Model
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Expression Operation - 表达式操作
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public class SingleExpOpNode : NodeModelBase
|
2024-08-06 16:09:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表达式
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Expression { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-20 10:50:32 +08:00
|
|
|
|
//public override async Task<object?> Executing(IDynamicContext context)
|
|
|
|
|
|
public override Task<object?> ExecutingAsync(IDynamicContext context)
|
2024-08-06 16:09:46 +08:00
|
|
|
|
{
|
2024-09-22 14:10:13 +08:00
|
|
|
|
var data = PreviousNode?.GetFlowData();
|
2024-08-06 16:09:46 +08:00
|
|
|
|
|
2024-09-15 22:07:10 +08:00
|
|
|
|
try
|
2024-08-06 16:09:46 +08:00
|
|
|
|
{
|
2024-09-15 22:07:10 +08:00
|
|
|
|
var newData = SerinExpressionEvaluator.Evaluate(Expression, data, out bool isChange);
|
|
|
|
|
|
Console.WriteLine(newData);
|
|
|
|
|
|
object? result = null;
|
|
|
|
|
|
if (isChange)
|
|
|
|
|
|
{
|
|
|
|
|
|
result = newData;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-09-22 14:10:13 +08:00
|
|
|
|
result = data;
|
2024-09-15 22:07:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NextOrientation = ConnectionType.IsSucceed;
|
2024-09-20 10:50:32 +08:00
|
|
|
|
return Task.FromResult(result);
|
2024-08-06 16:09:46 +08:00
|
|
|
|
}
|
2024-09-15 22:07:10 +08:00
|
|
|
|
catch (Exception ex)
|
2024-08-06 16:09:46 +08:00
|
|
|
|
{
|
2024-09-15 22:07:10 +08:00
|
|
|
|
NextOrientation = ConnectionType.IsError;
|
|
|
|
|
|
RuningException = ex;
|
2024-09-22 14:10:13 +08:00
|
|
|
|
return Task.FromResult(data);
|
2024-08-06 16:09:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-09-17 14:20:27 +08:00
|
|
|
|
internal override Parameterdata[] GetParameterdatas()
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2024-09-17 14:20:27 +08:00
|
|
|
|
return [new Parameterdata{ Expression = Expression}];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-11 23:08:56 +08:00
|
|
|
|
public override NodeModelBase LoadInfo(NodeInfo nodeInfo)
|
2024-09-17 14:20:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
var node = this;
|
|
|
|
|
|
if (node != null)
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2024-09-17 14:20:27 +08:00
|
|
|
|
node.Guid = nodeInfo.Guid;
|
|
|
|
|
|
for (int i = 0; i < nodeInfo.ParameterData.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
node.Expression = nodeInfo.ParameterData[i].Expression;
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
2024-09-17 14:20:27 +08:00
|
|
|
|
return this;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
2024-08-06 16:09:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|