优化了输出提示

This commit is contained in:
fengjiayi
2024-12-10 23:58:49 +08:00
parent 0f46b7ef63
commit dbbaa10cc0
11 changed files with 84 additions and 49 deletions

View File

@@ -31,6 +31,11 @@
<ProjectReference Include="..\NodeFlow\Serein.NodeFlow.csproj" />
</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'">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>

View File

@@ -256,6 +256,7 @@ namespace Serein.Library
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"节点Guid{this.NodeModel.Guid}");
sb.AppendLine($"方法别名:{this.MethodAnotherName}");
sb.AppendLine($"方法名称:{this.MethodName}");
sb.AppendLine($"需要实例:{this.ActingInstanceType?.FullName}");

View File

@@ -262,7 +262,7 @@ namespace Serein.Library
catch (Exception ex)
{
newFlowData = null;
context.Env.WriteLine(InfoType.ERROR,$"节点[{this.Guid}]异常:" + ex);
context.Env.WriteLine(InfoType.ERROR, $"节点[{currentNode.Guid}]异常:" + ex);
context.NextOrientation = ConnectionInvokeType.IsError;
context.ExceptionOfRuning = ex;
}
@@ -400,7 +400,7 @@ namespace Serein.Library
#region []
object inputParameter; // 存放解析的临时参数
if (pd.IsExplicitData && !pd.DataValue.StartsWith("@get", StringComparison.OrdinalIgnoreCase)) // 判断是否使用显示的输入参数
if (pd.IsExplicitData && !pd.DataValue.StartsWith("@", StringComparison.OrdinalIgnoreCase)) // 判断是否使用显示的输入参数
{
// 使用输入的固定值
inputParameter = pd.DataValue;
@@ -447,14 +447,7 @@ 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
#region @Get / @DTC Data type conversion / @Data ()
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

View File

@@ -52,12 +52,12 @@ namespace Serein.Library.Utils.SereinExpression
/// <exception cref="NotSupportedException"></exception>
public static object Evaluate(string expression, object targetObJ, out bool isChange)
{
if (expression is null || targetObJ is null)
{
throw new Exception("表达式条件expression is null、 targetObJ is null");
}
//if (expression is null || targetObJ is null)
//{
// throw new Exception("表达式条件expression is null、 targetObJ is null");
//}
var parts = expression.Split(new[] { ' ' }, 2, StringSplitOptions.None);
if (parts.Length != 2)
if (parts.Length < 1)
{
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];
object result;
isChange = false;
if (operation == "@num")
{
result = ComputedNumber(targetObJ, operand);
}
else if (operation == "@call")
//if (operation == "@num")
//{
// result = ComputedNumber(targetObJ, operand);
//}
if (operation == "@call")
{
result = InvokeMethod(targetObJ, operand);
}

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Serein.Library;
using Serein.Library.Api;
using Serein.Library.Core;
@@ -348,6 +349,7 @@ namespace Serein.NodeFlow.Env
{
}
Console.WriteLine($"{DateTime.UtcNow} [{type}] : {message}{Environment.NewLine}");
OnEnvOut?.Invoke(type, message);
}

View File

@@ -254,7 +254,8 @@ namespace Serein.NodeFlow
try
{
await startNode.StartFlowAsync(Context); // 开始运行时从起始节点开始运行
if (flipflopNodes.Count > 0)
{
env.FlipFlopState = RunState.Running;
@@ -269,7 +270,8 @@ namespace Serein.NodeFlow
}).ToArray();
_ = Task.WhenAll(tasks);
}
await startNode.StartFlowAsync(Context); // 开始运行时从起始节点开始运行
// 等待结束
if(env.FlipFlopState == RunState.Running && _flipFlopCts is not null)
{
@@ -391,7 +393,7 @@ namespace Serein.NodeFlow
}
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)
{
break;
@@ -399,13 +401,9 @@ namespace Serein.NodeFlow
}
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);
}
finally
{
}
}
}

View File

@@ -47,20 +47,24 @@ namespace Serein.NodeFlow.Model
throw new Exception("不存在对应委托");
}
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)
@@ -69,14 +73,14 @@ namespace Serein.NodeFlow.Model
{
throw;
}
await Console.Out.WriteLineAsync($"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
SereinEnv.WriteLine(InfoType.ERROR, $"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
context.NextOrientation = ConnectionInvokeType.None;
context.ExceptionOfRuning = ex;
return null;
}
catch (Exception ex)
{
await Console.Out.WriteLineAsync($"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
SereinEnv.WriteLine(InfoType.ERROR, $"触发器[{this.MethodDetails.MethodName}]异常:" + ex);
context.NextOrientation = ConnectionInvokeType.IsError;
context.ExceptionOfRuning = ex;
return null;
@@ -84,7 +88,7 @@ namespace Serein.NodeFlow.Model
finally
{
// flipflopTask?.Dispose();
}
}*/
}
/// <summary>

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Serein.Library;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Threading;
@@ -15,7 +16,7 @@ namespace Serein.Workbench
{
#if DEBUG
if (1 == 0 )
if (1 == 1 )
{
string filePath;
filePath = @"F:\临时\project\linux\project.dnf";
@@ -80,6 +81,7 @@ namespace Serein.Workbench
MessageBox.Show($"读取文件时发生错误:{ex.Message}");
Shutdown(); // 关闭应用程序
}
}
this.LoadLocalProject();
@@ -143,7 +145,7 @@ namespace Serein.Workbench
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
expression = "@number (@+1)/100";

View File

@@ -57,6 +57,7 @@
<MenuItem Header="视图">
<MenuItem Header="输出窗口" Click="ButtonOpenConsoleOutWindow_Click"></MenuItem>
<MenuItem Header="重置画布" Click="ButtonResetCanvas_Click"></MenuItem>
<MenuItem Header="定位节点" Click="ButtonLocationNode_Click"></MenuItem>
</MenuItem>
<MenuItem Header="远程">
<MenuItem Header="启动远程服务" Click="ButtonStartRemoteServer_Click"></MenuItem>
@@ -100,7 +101,7 @@
<Grid Grid.Row="1" Grid.Column="2" x:Name="FlowChartStackGrid">
<StackPanel x:Name="FlowChartStackPanel"
ClipToBounds="True">
<Canvas
x:Name="FlowChartCanvas"
@@ -115,7 +116,8 @@
MouseMove="FlowChartCanvas_MouseMove"
MouseWheel="FlowChartCanvas_MouseWheel"
Drop="FlowChartCanvas_Drop"
DragOver="FlowChartCanvas_DragOver">
DragOver="FlowChartCanvas_DragOver"
VirtualizingStackPanel.IsVirtualizing="True">
<Rectangle x:Name="SelectionRectangle"
Stroke="Blue"

View File

@@ -2578,10 +2578,30 @@ namespace Serein.Workbench
scaleTransform.ScaleX = 1;
scaleTransform.ScaleY = 1;
}
/// <summary>
/// 查看输出日志窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOpenConsoleOutWindow_Click(object sender, RoutedEventArgs e)
{
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

View File

@@ -56,9 +56,9 @@
<ItemGroup>
<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="SqlSugarCoreNoDrive" Version="5.1.4.171" />-->
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.171" />
<!--<PackageReference Include="LivetCask2" Version="4.0.2" />-->
<!--<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />-->