mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
优化了输出提示
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user