mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-26 01:37:54 +08:00
修复了条件表达式".xxx<bool> = true/false"执行了错误分支,优化了流程的运行。
This commit is contained in:
@@ -294,33 +294,6 @@ namespace Serein.Library
|
|||||||
|
|
||||||
// 从栈中弹出一个节点作为当前节点进行处理
|
// 从栈中弹出一个节点作为当前节点进行处理
|
||||||
var currentNode = stack.Pop();
|
var currentNode = stack.Pop();
|
||||||
#if false
|
|
||||||
// 筛选出上游分支
|
|
||||||
var upstreamNodes = currentNode.SuccessorNodes[ConnectionInvokeType.Upstream].ToArray();
|
|
||||||
for (int index = 0; index < upstreamNodes.Length; index++)
|
|
||||||
{
|
|
||||||
NodeModelBase upstreamNode = upstreamNodes[index];
|
|
||||||
if (!(upstreamNode is null) && upstreamNode.DebugSetting.IsEnable)
|
|
||||||
{
|
|
||||||
if (upstreamNode.DebugSetting.IsInterrupt) // 执行触发前
|
|
||||||
{
|
|
||||||
var cancelType = await upstreamNode.DebugSetting.GetInterruptTask();
|
|
||||||
await Console.Out.WriteLineAsync($"[{upstreamNode.MethodDetails?.MethodName}]中断已{cancelType},开始执行后继分支");
|
|
||||||
}
|
|
||||||
context.SetPreviousNode(upstreamNode, currentNode);
|
|
||||||
await upstreamNode.StartFlowAsync(context); // 执行流程节点的上游分支
|
|
||||||
if (context.NextOrientation == ConnectionInvokeType.IsError)
|
|
||||||
{
|
|
||||||
// 如果上游分支执行失败,不再继续执行
|
|
||||||
// 使上游节点(仅上游节点本身,不包含上游节点的后继节点)
|
|
||||||
// 具备通过抛出异常中断流程的能力
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// 上游分支执行完成,才执行当前节点
|
|
||||||
if (IsBradk(context, flowCts)) break; // 退出执行
|
|
||||||
context.NextOrientation = ConnectionInvokeType.None; // 重置上下文状态
|
context.NextOrientation = ConnectionInvokeType.None; // 重置上下文状态
|
||||||
|
|
||||||
object newFlowData;
|
object newFlowData;
|
||||||
|
|||||||
@@ -18,20 +18,22 @@ namespace Serein.Library.Utils.SereinExpression.Resolver
|
|||||||
|
|
||||||
public Operator Op { get; set; }
|
public Operator Op { get; set; }
|
||||||
public bool Value { get; set; }
|
public bool Value { get; set; }
|
||||||
|
public bool Data { get; set; }
|
||||||
|
|
||||||
public override bool Evaluate(object obj)
|
public override bool Evaluate(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (obj is bool boolObj)
|
return Value.Equals(Data);
|
||||||
{
|
//if (obj is bool boolObj && Value is bool boolValue)
|
||||||
return boolObj == Value;
|
//{
|
||||||
/*switch (Op)
|
|
||||||
{
|
// /*switch (Op)
|
||||||
case Operator.Is:
|
// {
|
||||||
return boolObj == Value;
|
// case Operator.Is:
|
||||||
}*/
|
// return boolObj == Value;
|
||||||
}
|
// }*/
|
||||||
return false;
|
//}
|
||||||
|
//return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Serein.Library.Utils.SereinExpression.Resolver
|
namespace Serein.Library.Utils.SereinExpression.Resolver
|
||||||
@@ -24,14 +25,15 @@ namespace Serein.Library.Utils.SereinExpression.Resolver
|
|||||||
|
|
||||||
if (TargetObj is T typedObj)
|
if (TargetObj is T typedObj)
|
||||||
{
|
{
|
||||||
return new ValueTypeConditionResolver<T>
|
var res = new ValueTypeConditionResolver<T>
|
||||||
{
|
{
|
||||||
RangeStart = RangeStart,
|
RangeStart = RangeStart,
|
||||||
RangeEnd = RangeEnd,
|
RangeEnd = RangeEnd,
|
||||||
Op = Op,
|
Op = Op,
|
||||||
Value = Value,
|
Value = Value,
|
||||||
ArithmeticExpression = ArithmeticExpression,
|
ArithmeticExpression = ArithmeticExpression,
|
||||||
}.Evaluate(typedObj);
|
};
|
||||||
|
return res.Evaluate(typedObj);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,12 +317,23 @@ namespace Serein.Library.Utils.SereinExpression
|
|||||||
#region 解析类型 bool
|
#region 解析类型 bool
|
||||||
else if (type == typeof(bool))
|
else if (type == typeof(bool))
|
||||||
{
|
{
|
||||||
return new MemberConditionResolver<bool>
|
bool targetData = false;
|
||||||
|
if (targetObj is bool tmp)
|
||||||
{
|
{
|
||||||
//MemberPath = memberPath,
|
targetData = tmp;
|
||||||
TargetObj = targetObj,
|
}
|
||||||
Op = (ValueTypeConditionResolver<bool>.Operator)ParseBoolOperator(operatorStr)
|
else
|
||||||
|
{
|
||||||
|
targetObj = bool.Parse(targetObj.ToString());
|
||||||
|
}
|
||||||
|
return new BoolConditionResolver
|
||||||
|
{
|
||||||
|
//Value = bool.Parse(targetObj.ToString()),
|
||||||
|
Value = bool.Parse(valueStr),
|
||||||
|
Data = targetData,
|
||||||
|
Op = BoolConditionResolver.Operator.Is
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region 解析类型 string
|
#region 解析类型 string
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Data;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -483,6 +484,10 @@ namespace Serein.Library.Utils.SereinExpression
|
|||||||
tempType = typeof(string);
|
tempType = typeof(string);
|
||||||
break;
|
break;
|
||||||
case "datetime":
|
case "datetime":
|
||||||
|
if(valueStr.Equals("now", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return DateTime.Now;
|
||||||
|
}
|
||||||
tempType = typeof(DateTime);
|
tempType = typeof(DateTime);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 信息输出等级
|
/// 信息输出等级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InfoClass InfoClass { get ; set ; } = InfoClass.General;
|
public InfoClass InfoClass { get ; set ; } = InfoClass.Trivial;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 如果没有全局触发器,且没有循环分支,流程执行完成后自动为 Completion 。
|
/// 如果没有全局触发器,且没有循环分支,流程执行完成后自动为 Completion 。
|
||||||
|
|||||||
@@ -2,11 +2,19 @@
|
|||||||
using Serein.Library;
|
using Serein.Library;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace Serein.Workbench
|
namespace Serein.Workbench
|
||||||
{
|
{
|
||||||
|
//public class A
|
||||||
|
//{
|
||||||
|
// public object Data { get; set; }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for App.xaml
|
/// Interaction logic for App.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -18,14 +26,20 @@ namespace Serein.Workbench
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (1 == 1)
|
if (1 == 1)
|
||||||
{
|
{
|
||||||
|
//var A = new A();
|
||||||
|
//A.Data = true;
|
||||||
|
//var expression = ".Data<bool> == True";
|
||||||
|
//var pass = Serein.Library.Utils.SereinExpression.SereinConditionParser.To(A, expression);
|
||||||
|
|
||||||
|
|
||||||
// 这里是我自己的测试代码,你可以删除
|
// 这里是我自己的测试代码,你可以删除
|
||||||
string filePath;
|
string filePath;
|
||||||
filePath = @"F:\临时\project\linux\project.dnf";
|
filePath = @"F:\临时\project\linux\project.dnf";
|
||||||
filePath = @"F:\临时\project\linux\http\project.dnf";
|
filePath = @"F:\临时\project\linux\http\project.dnf";
|
||||||
filePath = @"F:\临时\project\yolo flow\project.dnf";
|
filePath = @"F:\临时\project\yolo flow\project.dnf";
|
||||||
filePath = @"F:\临时\project\data\project.dnf";
|
filePath = @"F:\临时\project\data\project.dnf";
|
||||||
filePath = @"C:\Users\Az\source\repos\CLBanyunqiState\CLBanyunqiState\bin\Release\net8.0\project.dnf";
|
|
||||||
filePath = @"C:\Users\Az\source\repos\CLBanyunqiState\CLBanyunqiState\bin\Release\net8.0\PLCproject.dnf";
|
filePath = @"C:\Users\Az\source\repos\CLBanyunqiState\CLBanyunqiState\bin\Release\net8.0\PLCproject.dnf";
|
||||||
|
filePath = @"C:\Users\Az\source\repos\CLBanyunqiState\CLBanyunqiState\bin\Release\banyunqi\project.dnf";
|
||||||
string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容
|
string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容
|
||||||
App.FlowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
|
App.FlowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
|
||||||
App.FileDataPath = System.IO.Path.GetDirectoryName(filePath)!; // filePath;//
|
App.FileDataPath = System.IO.Path.GetDirectoryName(filePath)!; // filePath;//
|
||||||
|
|||||||
@@ -2757,6 +2757,10 @@ namespace Serein.Workbench
|
|||||||
// 遍历当前已选节点
|
// 遍历当前已选节点
|
||||||
foreach (var node in dictSelection.Values.ToArray())
|
foreach (var node in dictSelection.Values.ToArray())
|
||||||
{
|
{
|
||||||
|
if(node.ChildNodeGuids is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 遍历这些节点的子节点,获得完整的已选节点信息
|
// 遍历这些节点的子节点,获得完整的已选节点信息
|
||||||
foreach (var childNodeGuid in node.ChildNodeGuids)
|
foreach (var childNodeGuid in node.ChildNodeGuids)
|
||||||
{
|
{
|
||||||
@@ -2780,7 +2784,7 @@ namespace Serein.Workbench
|
|||||||
{
|
{
|
||||||
//Clipboard.SetDataObject(result, true); // 持久性设置
|
//Clipboard.SetDataObject(result, true); // 持久性设置
|
||||||
Clipboard.SetDataObject(jsonText, true); // 持久性设置
|
Clipboard.SetDataObject(jsonText, true); // 持久性设置
|
||||||
SereinEnv.WriteLine(InfoType.INFO, $"复制已选节点({dictSelection.Count}个)");
|
SereinEnv.WriteLine(InfoType.INFO, $"复制已选节点({dictSelection.Count}个)");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user