mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-09 01:16:34 +08:00
优化了输出提示
This commit is contained in:
@@ -31,6 +31,11 @@
|
|||||||
<ProjectReference Include="..\NodeFlow\Serein.NodeFlow.csproj" />
|
<ProjectReference Include="..\NodeFlow\Serein.NodeFlow.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MySqlConnector" Version="2.4.0" />
|
||||||
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
|
||||||
|
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.171" />
|
||||||
|
</ItemGroup>
|
||||||
<!--<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
|
<!--<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ namespace Serein.Library
|
|||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendLine($"节点Guid:{this.NodeModel.Guid}");
|
||||||
sb.AppendLine($"方法别名:{this.MethodAnotherName}");
|
sb.AppendLine($"方法别名:{this.MethodAnotherName}");
|
||||||
sb.AppendLine($"方法名称:{this.MethodName}");
|
sb.AppendLine($"方法名称:{this.MethodName}");
|
||||||
sb.AppendLine($"需要实例:{this.ActingInstanceType?.FullName}");
|
sb.AppendLine($"需要实例:{this.ActingInstanceType?.FullName}");
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ namespace Serein.Library
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
newFlowData = null;
|
newFlowData = null;
|
||||||
context.Env.WriteLine(InfoType.ERROR,$"节点[{this.Guid}]异常:" + ex);
|
context.Env.WriteLine(InfoType.ERROR, $"节点[{currentNode.Guid}]异常:" + ex);
|
||||||
context.NextOrientation = ConnectionInvokeType.IsError;
|
context.NextOrientation = ConnectionInvokeType.IsError;
|
||||||
context.ExceptionOfRuning = ex;
|
context.ExceptionOfRuning = ex;
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,7 @@ namespace Serein.Library
|
|||||||
|
|
||||||
#region 确定[预入参]数据
|
#region 确定[预入参]数据
|
||||||
object inputParameter; // 存放解析的临时参数
|
object inputParameter; // 存放解析的临时参数
|
||||||
if (pd.IsExplicitData && !pd.DataValue.StartsWith("@get", StringComparison.OrdinalIgnoreCase)) // 判断是否使用显示的输入参数
|
if (pd.IsExplicitData && !pd.DataValue.StartsWith("@", StringComparison.OrdinalIgnoreCase)) // 判断是否使用显示的输入参数
|
||||||
{
|
{
|
||||||
// 使用输入的固定值
|
// 使用输入的固定值
|
||||||
inputParameter = pd.DataValue;
|
inputParameter = pd.DataValue;
|
||||||
@@ -447,14 +447,7 @@ namespace Serein.Library
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 对于非值类型的null检查
|
|
||||||
if (!argDataType.IsValueType && inputParameter is null)
|
|
||||||
{
|
|
||||||
parameters[i] = null;
|
|
||||||
throw new Exception($"[arg{pd.Index}][{pd.Name}][{argDataType}]参数不能为null");
|
|
||||||
// continue;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 处理 @Get / @DTC 表达式 (Data type conversion) / @Data (全局数据)
|
#region 处理 @Get / @DTC 表达式 (Data type conversion) / @Data (全局数据)
|
||||||
if (pd.IsExplicitData)
|
if (pd.IsExplicitData)
|
||||||
@@ -480,7 +473,15 @@ namespace Serein.Library
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 对于非值类型的null检查
|
||||||
|
if (!argDataType.IsValueType && inputParameter is null)
|
||||||
|
{
|
||||||
|
parameters[i] = null;
|
||||||
|
throw new Exception($"[arg{pd.Index}][{pd.Name}][{argDataType}]参数不能为null");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ namespace Serein.Library.Utils.SereinExpression
|
|||||||
/// <exception cref="NotSupportedException"></exception>
|
/// <exception cref="NotSupportedException"></exception>
|
||||||
public static object Evaluate(string expression, object targetObJ, out bool isChange)
|
public static object Evaluate(string expression, object targetObJ, out bool isChange)
|
||||||
{
|
{
|
||||||
if (expression is null || targetObJ is null)
|
//if (expression is null || targetObJ is null)
|
||||||
{
|
//{
|
||||||
throw new Exception("表达式条件expression is null、 targetObJ is null");
|
// throw new Exception("表达式条件expression is null、 targetObJ is null");
|
||||||
}
|
//}
|
||||||
var parts = expression.Split(new[] { ' ' }, 2, StringSplitOptions.None);
|
var parts = expression.Split(new[] { ' ' }, 2, StringSplitOptions.None);
|
||||||
if (parts.Length != 2)
|
if (parts.Length < 1)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Invalid expression format.");
|
throw new ArgumentException("Invalid expression format.");
|
||||||
}
|
}
|
||||||
@@ -66,11 +66,11 @@ namespace Serein.Library.Utils.SereinExpression
|
|||||||
var operand = parts[1][0] == '.' ? parts[1].Substring(1) : parts[1];
|
var operand = parts[1][0] == '.' ? parts[1].Substring(1) : parts[1];
|
||||||
object result;
|
object result;
|
||||||
isChange = false;
|
isChange = false;
|
||||||
if (operation == "@num")
|
//if (operation == "@num")
|
||||||
{
|
//{
|
||||||
result = ComputedNumber(targetObJ, operand);
|
// result = ComputedNumber(targetObJ, operand);
|
||||||
}
|
//}
|
||||||
else if (operation == "@call")
|
if (operation == "@call")
|
||||||
{
|
{
|
||||||
result = InvokeMethod(targetObJ, operand);
|
result = InvokeMethod(targetObJ, operand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using Serein.Library;
|
using Serein.Library;
|
||||||
using Serein.Library.Api;
|
using Serein.Library.Api;
|
||||||
using Serein.Library.Core;
|
using Serein.Library.Core;
|
||||||
@@ -348,6 +349,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Console.WriteLine($"{DateTime.UtcNow} [{type}] : {message}{Environment.NewLine}");
|
||||||
OnEnvOut?.Invoke(type, message);
|
OnEnvOut?.Invoke(type, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ namespace Serein.NodeFlow
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
await startNode.StartFlowAsync(Context); // 开始运行时从起始节点开始运行
|
||||||
|
|
||||||
if (flipflopNodes.Count > 0)
|
if (flipflopNodes.Count > 0)
|
||||||
{
|
{
|
||||||
env.FlipFlopState = RunState.Running;
|
env.FlipFlopState = RunState.Running;
|
||||||
@@ -269,7 +270,8 @@ namespace Serein.NodeFlow
|
|||||||
}).ToArray();
|
}).ToArray();
|
||||||
_ = Task.WhenAll(tasks);
|
_ = Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
await startNode.StartFlowAsync(Context); // 开始运行时从起始节点开始运行
|
|
||||||
|
|
||||||
// 等待结束
|
// 等待结束
|
||||||
if(env.FlipFlopState == RunState.Running && _flipFlopCts is not null)
|
if(env.FlipFlopState == RunState.Running && _flipFlopCts is not null)
|
||||||
{
|
{
|
||||||
@@ -391,7 +393,7 @@ namespace Serein.NodeFlow
|
|||||||
}
|
}
|
||||||
catch (FlipflopException ex)
|
catch (FlipflopException ex)
|
||||||
{
|
{
|
||||||
env.WriteLine(InfoType.ERROR,$"触发器[{singleFlipFlopNode.MethodDetails.MethodName}]因非预期异常终止。"+ex.Message);
|
SereinEnv.WriteLine(InfoType.ERROR,$"触发器[{singleFlipFlopNode.MethodDetails.MethodName}]因非预期异常终止。"+ex.Message);
|
||||||
if (ex.Type == FlipflopException.CancelClass.CancelFlow)
|
if (ex.Type == FlipflopException.CancelClass.CancelFlow)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -399,13 +401,9 @@ namespace Serein.NodeFlow
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
env.WriteLine(InfoType.ERROR, $"触发器[{singleFlipFlopNode.Guid}]异常。"+ ex.Message);
|
SereinEnv.WriteLine(InfoType.ERROR, $"触发器[{singleFlipFlopNode.Guid}]异常。"+ ex.Message);
|
||||||
//await Console.Out.WriteLineAsync(ex.Message);
|
//await Console.Out.WriteLineAsync(ex.Message);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,20 +47,24 @@ namespace Serein.NodeFlow.Model
|
|||||||
throw new Exception("不存在对应委托");
|
throw new Exception("不存在对应委托");
|
||||||
}
|
}
|
||||||
object instance = md.ActingInstance;
|
object instance = md.ActingInstance;
|
||||||
try
|
|
||||||
|
var args = await GetParametersAsync(context, this, md);
|
||||||
|
// 因为这里会返回不确定的泛型 IFlipflopContext<TRsult>
|
||||||
|
// 而我们只需要获取到 State 和 Value(返回的数据)
|
||||||
|
// 所以使用 dynamic 类型接收
|
||||||
|
dynamic dynamicFlipflopContext = await dd.InvokeAsync(md.ActingInstance, args);
|
||||||
|
FlipflopStateType flipflopStateType = dynamicFlipflopContext.State;
|
||||||
|
context.NextOrientation = flipflopStateType.ToContentType();
|
||||||
|
if (dynamicFlipflopContext.Type == TriggerType.Overtime)
|
||||||
|
{
|
||||||
|
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
|
||||||
|
}
|
||||||
|
return dynamicFlipflopContext.Value;
|
||||||
|
|
||||||
|
/*try
|
||||||
{
|
{
|
||||||
|
|
||||||
var args = await GetParametersAsync(context, this, md);
|
|
||||||
// 因为这里会返回不确定的泛型 IFlipflopContext<TRsult>
|
|
||||||
// 而我们只需要获取到 State 和 Value(返回的数据)
|
|
||||||
dynamic dynamicFlipflopContext = await dd.InvokeAsync(md.ActingInstance, args);
|
|
||||||
FlipflopStateType flipflopStateType = dynamicFlipflopContext.State;
|
|
||||||
context.NextOrientation = flipflopStateType.ToContentType();
|
|
||||||
if (dynamicFlipflopContext.Type == TriggerType.Overtime)
|
|
||||||
{
|
|
||||||
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
|
|
||||||
}
|
|
||||||
return dynamicFlipflopContext.Value;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (FlipflopException ex)
|
catch (FlipflopException ex)
|
||||||
@@ -69,14 +73,14 @@ namespace Serein.NodeFlow.Model
|
|||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
await Console.Out.WriteLineAsync($"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
|
SereinEnv.WriteLine(InfoType.ERROR, $"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
|
||||||
context.NextOrientation = ConnectionInvokeType.None;
|
context.NextOrientation = ConnectionInvokeType.None;
|
||||||
context.ExceptionOfRuning = ex;
|
context.ExceptionOfRuning = ex;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await Console.Out.WriteLineAsync($"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
|
SereinEnv.WriteLine(InfoType.ERROR, $"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
|
||||||
context.NextOrientation = ConnectionInvokeType.IsError;
|
context.NextOrientation = ConnectionInvokeType.IsError;
|
||||||
context.ExceptionOfRuning = ex;
|
context.ExceptionOfRuning = ex;
|
||||||
return null;
|
return null;
|
||||||
@@ -84,7 +88,7 @@ namespace Serein.NodeFlow.Model
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// flipflopTask?.Dispose();
|
// flipflopTask?.Dispose();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Serein.Library;
|
using Serein.Library;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
@@ -15,7 +16,7 @@ namespace Serein.Workbench
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (1 == 0 )
|
if (1 == 1 )
|
||||||
{
|
{
|
||||||
string filePath;
|
string filePath;
|
||||||
filePath = @"F:\临时\project\linux\project.dnf";
|
filePath = @"F:\临时\project\linux\project.dnf";
|
||||||
@@ -80,6 +81,7 @@ namespace Serein.Workbench
|
|||||||
MessageBox.Show($"读取文件时发生错误:{ex.Message}");
|
MessageBox.Show($"读取文件时发生错误:{ex.Message}");
|
||||||
Shutdown(); // 关闭应用程序
|
Shutdown(); // 关闭应用程序
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
this.LoadLocalProject();
|
this.LoadLocalProject();
|
||||||
|
|
||||||
@@ -143,7 +145,7 @@ namespace Serein.Workbench
|
|||||||
|
|
||||||
SerinExpressionEvaluator.Evaluate("set .Data.Tips = 123", testObj);
|
SerinExpressionEvaluator.Evaluate("set .Data.Tips = 123", testObj);
|
||||||
// 调用对象方法
|
// 调用对象方法
|
||||||
result = SerinExpressionEvaluator.Evaluate($"invoke .ToUpper({SerinExpressionEvaluator.Evaluate("get .Data.Tips", testObj)})", testObj);
|
result = SerinExpressionEvaluator.Evaluate($"call .ToUpper({SerinExpressionEvaluator.Evaluate("get .Data.Tips", testObj)})", testObj);
|
||||||
Debug.WriteLine(result); // HELLO
|
Debug.WriteLine(result); // HELLO
|
||||||
|
|
||||||
expression = "@number (@+1)/100";
|
expression = "@number (@+1)/100";
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<MenuItem Header="视图">
|
<MenuItem Header="视图">
|
||||||
<MenuItem Header="输出窗口" Click="ButtonOpenConsoleOutWindow_Click"></MenuItem>
|
<MenuItem Header="输出窗口" Click="ButtonOpenConsoleOutWindow_Click"></MenuItem>
|
||||||
<MenuItem Header="重置画布" Click="ButtonResetCanvas_Click"></MenuItem>
|
<MenuItem Header="重置画布" Click="ButtonResetCanvas_Click"></MenuItem>
|
||||||
|
<MenuItem Header="定位节点" Click="ButtonLocationNode_Click"></MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem Header="远程">
|
<MenuItem Header="远程">
|
||||||
<MenuItem Header="启动远程服务" Click="ButtonStartRemoteServer_Click"></MenuItem>
|
<MenuItem Header="启动远程服务" Click="ButtonStartRemoteServer_Click"></MenuItem>
|
||||||
@@ -100,7 +101,7 @@
|
|||||||
<Grid Grid.Row="1" Grid.Column="2" x:Name="FlowChartStackGrid">
|
<Grid Grid.Row="1" Grid.Column="2" x:Name="FlowChartStackGrid">
|
||||||
|
|
||||||
<StackPanel x:Name="FlowChartStackPanel"
|
<StackPanel x:Name="FlowChartStackPanel"
|
||||||
|
|
||||||
ClipToBounds="True">
|
ClipToBounds="True">
|
||||||
<Canvas
|
<Canvas
|
||||||
x:Name="FlowChartCanvas"
|
x:Name="FlowChartCanvas"
|
||||||
@@ -115,7 +116,8 @@
|
|||||||
MouseMove="FlowChartCanvas_MouseMove"
|
MouseMove="FlowChartCanvas_MouseMove"
|
||||||
MouseWheel="FlowChartCanvas_MouseWheel"
|
MouseWheel="FlowChartCanvas_MouseWheel"
|
||||||
Drop="FlowChartCanvas_Drop"
|
Drop="FlowChartCanvas_Drop"
|
||||||
DragOver="FlowChartCanvas_DragOver">
|
DragOver="FlowChartCanvas_DragOver"
|
||||||
|
VirtualizingStackPanel.IsVirtualizing="True">
|
||||||
|
|
||||||
<Rectangle x:Name="SelectionRectangle"
|
<Rectangle x:Name="SelectionRectangle"
|
||||||
Stroke="Blue"
|
Stroke="Blue"
|
||||||
|
|||||||
@@ -2578,10 +2578,30 @@ namespace Serein.Workbench
|
|||||||
scaleTransform.ScaleX = 1;
|
scaleTransform.ScaleX = 1;
|
||||||
scaleTransform.ScaleY = 1;
|
scaleTransform.ScaleY = 1;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查看输出日志窗口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void ButtonOpenConsoleOutWindow_Click(object sender, RoutedEventArgs e)
|
private void ButtonOpenConsoleOutWindow_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
LogOutWindow?.Show();
|
LogOutWindow?.Show();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 定位节点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonLocationNode_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
InputDialog inputDialog = new InputDialog();
|
||||||
|
inputDialog.Closed += (s, e) =>
|
||||||
|
{
|
||||||
|
var nodeGuid = inputDialog.InputValue;
|
||||||
|
EnvDecorator.NodeLocated(nodeGuid);
|
||||||
|
};
|
||||||
|
inputDialog.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
|
||||||
<!--<PackageReference Include="MySqlConnector" Version="2.4.0" />
|
<PackageReference Include="MySqlConnector" Version="2.4.0" />
|
||||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
|
||||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.171" />-->
|
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.171" />
|
||||||
|
|
||||||
<!--<PackageReference Include="LivetCask2" Version="4.0.2" />-->
|
<!--<PackageReference Include="LivetCask2" Version="4.0.2" />-->
|
||||||
<!--<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />-->
|
<!--<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />-->
|
||||||
|
|||||||
Reference in New Issue
Block a user