diff --git a/Library/FlowNode/NodeModelBaseFunc.cs b/Library/FlowNode/NodeModelBaseFunc.cs index 35097e9..d8077a4 100644 --- a/Library/FlowNode/NodeModelBaseFunc.cs +++ b/Library/FlowNode/NodeModelBaseFunc.cs @@ -294,33 +294,6 @@ namespace Serein.Library // 从栈中弹出一个节点作为当前节点进行处理 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; // 重置上下文状态 object newFlowData; diff --git a/Library/Utils/SereinExpression/Resolver/BoolConditionResolver.cs b/Library/Utils/SereinExpression/Resolver/BoolConditionResolver.cs index c35fe02..7a2c5c2 100644 --- a/Library/Utils/SereinExpression/Resolver/BoolConditionResolver.cs +++ b/Library/Utils/SereinExpression/Resolver/BoolConditionResolver.cs @@ -18,20 +18,22 @@ namespace Serein.Library.Utils.SereinExpression.Resolver public Operator Op { get; set; } public bool Value { get; set; } + public bool Data { get; set; } public override bool Evaluate(object obj) { - if (obj is bool boolObj) - { - return boolObj == Value; - /*switch (Op) - { - case Operator.Is: - return boolObj == Value; - }*/ - } - return false; + return Value.Equals(Data); + //if (obj is bool boolObj && Value is bool boolValue) + //{ + + // /*switch (Op) + // { + // case Operator.Is: + // return boolObj == Value; + // }*/ + //} + //return false; } } diff --git a/Library/Utils/SereinExpression/Resolver/MemberConditionResolver.cs b/Library/Utils/SereinExpression/Resolver/MemberConditionResolver.cs index 8b2cd20..907bef5 100644 --- a/Library/Utils/SereinExpression/Resolver/MemberConditionResolver.cs +++ b/Library/Utils/SereinExpression/Resolver/MemberConditionResolver.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace Serein.Library.Utils.SereinExpression.Resolver @@ -24,14 +25,15 @@ namespace Serein.Library.Utils.SereinExpression.Resolver if (TargetObj is T typedObj) { - return new ValueTypeConditionResolver + var res = new ValueTypeConditionResolver { RangeStart = RangeStart, RangeEnd = RangeEnd, Op = Op, Value = Value, ArithmeticExpression = ArithmeticExpression, - }.Evaluate(typedObj); + }; + return res.Evaluate(typedObj); } return false; } diff --git a/Library/Utils/SereinExpression/SereinConditionParser.cs b/Library/Utils/SereinExpression/SereinConditionParser.cs index c426e3c..c108a97 100644 --- a/Library/Utils/SereinExpression/SereinConditionParser.cs +++ b/Library/Utils/SereinExpression/SereinConditionParser.cs @@ -317,12 +317,23 @@ namespace Serein.Library.Utils.SereinExpression #region 解析类型 bool else if (type == typeof(bool)) { - return new MemberConditionResolver + bool targetData = false; + if (targetObj is bool tmp) { - //MemberPath = memberPath, - TargetObj = targetObj, - Op = (ValueTypeConditionResolver.Operator)ParseBoolOperator(operatorStr) + targetData = tmp; + } + 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 #region 解析类型 string diff --git a/Library/Utils/SereinExpression/SerinExpressionEvaluator.cs b/Library/Utils/SereinExpression/SerinExpressionEvaluator.cs index 9a44ebc..298a4f4 100644 --- a/Library/Utils/SereinExpression/SerinExpressionEvaluator.cs +++ b/Library/Utils/SereinExpression/SerinExpressionEvaluator.cs @@ -5,6 +5,7 @@ using System.Data; using System.Diagnostics; using System.IO; using System.Linq; +using System.Net.Http.Headers; using System.Reflection; using System.Threading.Tasks; @@ -483,6 +484,10 @@ namespace Serein.Library.Utils.SereinExpression tempType = typeof(string); break; case "datetime": + if(valueStr.Equals("now", StringComparison.OrdinalIgnoreCase)) + { + return DateTime.Now; + } tempType = typeof(DateTime); break; default: diff --git a/NodeFlow/Env/FlowEnvironment.cs b/NodeFlow/Env/FlowEnvironment.cs index 1b7ecb0..784f1b6 100644 --- a/NodeFlow/Env/FlowEnvironment.cs +++ b/NodeFlow/Env/FlowEnvironment.cs @@ -210,7 +210,7 @@ namespace Serein.NodeFlow.Env /// /// 信息输出等级 /// - public InfoClass InfoClass { get ; set ; } = InfoClass.General; + public InfoClass InfoClass { get ; set ; } = InfoClass.Trivial; /// /// 如果没有全局触发器,且没有循环分支,流程执行完成后自动为 Completion 。 diff --git a/WorkBench/App.xaml.cs b/WorkBench/App.xaml.cs index 1e08f20..44530c4 100644 --- a/WorkBench/App.xaml.cs +++ b/WorkBench/App.xaml.cs @@ -2,11 +2,19 @@ using Serein.Library; using System.Diagnostics; using System.IO; +using System.Linq.Expressions; using System.Windows; using System.Windows.Threading; namespace Serein.Workbench { + //public class A + //{ + // public object Data { get; set; } + //} + + + /// /// Interaction logic for App.xaml /// @@ -18,14 +26,20 @@ namespace Serein.Workbench #if DEBUG if (1 == 1) { + //var A = new A(); + //A.Data = true; + //var expression = ".Data == True"; + //var pass = Serein.Library.Utils.SereinExpression.SereinConditionParser.To(A, expression); + + // 这里是我自己的测试代码,你可以删除 string filePath; filePath = @"F:\临时\project\linux\project.dnf"; filePath = @"F:\临时\project\linux\http\project.dnf"; filePath = @"F:\临时\project\yolo flow\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\banyunqi\project.dnf"; string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容 App.FlowProjectData = JsonConvert.DeserializeObject(content); App.FileDataPath = System.IO.Path.GetDirectoryName(filePath)!; // filePath;// diff --git a/WorkBench/MainWindow.xaml.cs b/WorkBench/MainWindow.xaml.cs index 1f57acd..abfdb48 100644 --- a/WorkBench/MainWindow.xaml.cs +++ b/WorkBench/MainWindow.xaml.cs @@ -2757,6 +2757,10 @@ namespace Serein.Workbench // 遍历当前已选节点 foreach (var node in dictSelection.Values.ToArray()) { + if(node.ChildNodeGuids is null) + { + continue; + } // 遍历这些节点的子节点,获得完整的已选节点信息 foreach (var childNodeGuid in node.ChildNodeGuids) { @@ -2780,7 +2784,7 @@ namespace Serein.Workbench { //Clipboard.SetDataObject(result, true); // 持久性设置 Clipboard.SetDataObject(jsonText, true); // 持久性设置 - SereinEnv.WriteLine(InfoType.INFO, $"复制已选节点({dictSelection.Count}个)"); + SereinEnv.WriteLine(InfoType.INFO, $"复制已选节点({dictSelection.Count}个)"); } catch (Exception ex) {