diff --git a/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj b/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj index 40c1d27..162f6f2 100644 --- a/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj +++ b/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj @@ -12,10 +12,6 @@ 一个Wpf的流程图控件 - - - - True diff --git a/AIStudio.Wpf.Flowchart/FlowchartService.cs b/AIStudio.Wpf.Flowchart/FlowchartService.cs index c500472..d2a5042 100644 --- a/AIStudio.Wpf.Flowchart/FlowchartService.cs +++ b/AIStudio.Wpf.Flowchart/FlowchartService.cs @@ -5,7 +5,10 @@ using System.Linq; using System.Windows; using System.Windows.Media; using AIStudio.Wpf.DiagramDesigner; -using Expression = org.mariuszgromada.math.mxparser.Expression; +using Microsoft.CSharp; +using System.CodeDom.Compiler; +using System.Reflection; +using System.Data; namespace AIStudio.Wpf.Flowchart { @@ -274,17 +277,19 @@ namespace AIStudio.Wpf.Flowchart try { //按条件选择一个分支 - string express = step.Value.Replace("data.Flag", nextNode.Text); - Expression e = new Expression(express); - var result = e.calculate(); - if (result == 1) + string expression = step.Value.Replace("data.Flag", nextNode.Text); + + var result = new DataTable().Compute(expression, ""); + if (result.Equals(true)) { SetStatus(nextNode, 100); Next(step.Key, nextNode); return; } } - catch { } + catch(Exception ex) + { + } } //如果表达式错了,就按第一个处理 Next(nextNode.SelectNextStep.FirstOrDefault().Key, nextNode); @@ -367,6 +372,6 @@ namespace AIStudio.Wpf.Flowchart public static void DisposeData(IDiagramViewModel viewModel) { FlowNodes.Remove(viewModel); - } + } } }