mirror of
https://gitee.com/wang-yin1/wpf-visual-process-framework
synced 2026-03-03 00:00:56 +08:00
69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
|
|
using System.Data;
|
|
using VisionFrame.Base;
|
|
|
|
namespace LogicControl
|
|
{
|
|
public class DecisionNodeModel : DecisionNodeModelBase
|
|
{
|
|
public DecisionNodeModel()
|
|
{
|
|
// 某个变量值 == 什么值 > < >= <= != 关系运算符
|
|
//
|
|
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
|
{
|
|
ArgName = "判断目标",
|
|
ArgType = "Any",
|
|
Direction = "输入"
|
|
});
|
|
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
|
{
|
|
ArgName = "判断方式",
|
|
ArgType = "String",
|
|
Direction = "输入",
|
|
ValueMode = 3
|
|
});
|
|
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
|
{
|
|
ArgName = "判断值",
|
|
ArgType = "Any",
|
|
Direction = "输入",
|
|
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("判断目标参数未配置");
|
|
if (this.Arguments[1].ArgValue == null)
|
|
throw new Exception("判断方式参数未配置");
|
|
if (this.Arguments[2].ArgValue == null)
|
|
throw new Exception("判断值参数未配置");
|
|
|
|
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";
|
|
}
|
|
}
|
|
|
|
}
|