From 8fc69bc96d0a7f8e71e9646011367c46ff62cf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=89=BE=E7=AB=B9?= Date: Sat, 7 Jan 2023 12:08:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=B0=B1=E7=94=A8DataTable=E8=87=AA=E5=B8=A6?= =?UTF-8?q?=E7=9A=84=E5=A5=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AIStudio.Wpf.Flowchart.csproj | 4 ---- AIStudio.Wpf.Flowchart/FlowchartService.cs | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) 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); - } + } } }