Files
wpf-visual-process-framework/LogicControl/DecisionNodeModel.cs

69 lines
2.3 KiB
C#
Raw Normal View History

2025-07-14 21:08:46 +08:00
using System.Data;
using VisionFrame.Base;
namespace LogicControl
{
public class DecisionNodeModel : DecisionNodeModelBase
{
public DecisionNodeModel()
{
// ij<><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ == ʲôֵ > < >= <= != <20><>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
{
ArgName = "<22>ж<EFBFBD>Ŀ<EFBFBD><C4BF>",
ArgType = "Any",
Direction = "<22><><EFBFBD><EFBFBD>"
});
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
{
ArgName = "<22>жϷ<D0B6>ʽ",
ArgType = "String",
Direction = "<22><><EFBFBD><EFBFBD>",
ValueMode = 3
});
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
{
ArgName = "<22>ж<EFBFBD>ֵ",
ArgType = "Any",
Direction = "<22><><EFBFBD><EFBFBD>",
ValueMode = 1
});
}
public override bool Decision(IFlowContext context)
{
//int temp = 1;
//return new DataTable().Compute("1<=2", "").ToString() == "True";
if (this.Arguments[0].ArgValue == null)
throw new Exception("<22>ж<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>");
if (this.Arguments[1].ArgValue == null)
throw new Exception("<22>жϷ<D0B6>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>");
if (this.Arguments[2].ArgValue == null)
throw new Exception("<22>ж<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>");
string org_value = "";
var am = context.ArgumentList
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
if (am != null)
org_value = am.Value.ToString();
string value = this.Arguments[2].ArgValue.ToString();
if (this.Arguments[2].ValueMode == 0)
{
am = context.ArgumentList
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
if (am != null)
value = am.Value.ToString();
}
string compare = org_value + this.Arguments[1].ArgValue.ToString() + value;
// "0x5235443==32432"
// "1==2"
return new DataTable().Compute(compare, "").ToString() == "True";
}
}
}