mirror of
https://gitee.com/wang-yin1/wpf-visual-process-framework
synced 2026-03-02 15:50:51 +08:00
添加项目文件。
This commit is contained in:
68
LogicControl/DecisionNodeModel.cs
Normal file
68
LogicControl/DecisionNodeModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user