mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-20 16:26:34 +08:00
优化了流程的进行
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Serein.Library.Api
|
||||
{
|
||||
public interface IFlipflopContext
|
||||
{
|
||||
FlowStateType State { get; set; }
|
||||
FlipflopStateType State { get; set; }
|
||||
object Data { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ namespace Serein.Library.Enums
|
||||
{
|
||||
public enum ConnectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// 不执行分支
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 真分支
|
||||
/// </summary>
|
||||
|
||||
@@ -7,12 +7,8 @@ using System.Threading.Tasks;
|
||||
namespace Serein.Library.Enums
|
||||
{
|
||||
|
||||
public enum FlowStateType
|
||||
public enum FlipflopStateType
|
||||
{
|
||||
/// <summary>
|
||||
/// 待执行
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 成功(方法成功执行)
|
||||
/// </summary>
|
||||
@@ -25,5 +21,11 @@ namespace Serein.Library.Enums
|
||||
/// 异常(节点没有成功执行,执行时发生非预期的错误)
|
||||
/// </summary>
|
||||
Error,
|
||||
/// <summary>
|
||||
/// 取消
|
||||
/// </summary>
|
||||
Cancel,
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
16
Library/Ex/FlipflopException.cs
Normal file
16
Library/Ex/FlipflopException.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Serein.Library.Ex
|
||||
{
|
||||
/// <summary>
|
||||
/// 触发器
|
||||
/// </summary>
|
||||
public class FlipflopException: Exception
|
||||
{
|
||||
public bool IsCancel { get; }
|
||||
public FlipflopException(string message, bool isCancel = true) :base(message)
|
||||
{
|
||||
IsCancel = isCancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace Serein.Library.Attributes
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 标记一个方法是什么类型,加载dll后用来拖拽到画布中
|
||||
/// 建议触发器手动设置返回类型
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class NodeActionAttribute : Attribute
|
||||
@@ -45,9 +45,6 @@ namespace Serein.Library.Attributes
|
||||
public bool Scan;
|
||||
public string MethodTips;
|
||||
public NodeType MethodDynamicType;
|
||||
/// <summary>
|
||||
/// 推荐触发器手动设置返回类型
|
||||
/// </summary>
|
||||
public Type ReturnType;
|
||||
public string LockName;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Serein.Library.Ex;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Library.Core.NodeFlow.Tool
|
||||
{
|
||||
@@ -13,9 +14,8 @@ namespace Serein.Library.Core.NodeFlow.Tool
|
||||
// }
|
||||
//}
|
||||
|
||||
public class TcsSignal<TSignal> where TSignal : struct, Enum
|
||||
public class TcsSignalFlipflop<TSignal> where TSignal : struct, Enum
|
||||
{
|
||||
//public ConcurrentDictionary<TSignal, Queue<TaskCompletionSource<object>>> TcsEvent { get; } = new();
|
||||
public ConcurrentDictionary<TSignal, TaskCompletionSource<object>> TcsEvent { get; } = new ConcurrentDictionary<TSignal, TaskCompletionSource<object>>();
|
||||
|
||||
public ConcurrentDictionary<TSignal, object> TcsLock { get; } = new ConcurrentDictionary<TSignal, object>();
|
||||
@@ -56,7 +56,7 @@ namespace Serein.Library.Core.NodeFlow.Tool
|
||||
{
|
||||
foreach (var tcs in TcsEvent.Values)
|
||||
{
|
||||
tcs.SetException(new Exception("任务取消"));
|
||||
tcs.SetException(new FlipflopException("任务取消"));
|
||||
}
|
||||
TcsEvent.Clear();
|
||||
}
|
||||
Reference in New Issue
Block a user