mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
忘记改啥了*1
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
using Serein.Library.Utils;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Serein.Library.Core.NodeFlow
|
||||
namespace Serein.Library.Core
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 动态流程上下文
|
||||
/// </summary>
|
||||
public class DynamicContext: IDynamicContext
|
||||
public class DynamicContext : IDynamicContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态流程上下文
|
||||
@@ -30,6 +30,11 @@ namespace Serein.Library.Core.NodeFlow
|
||||
/// </summary>
|
||||
public RunState RunState { get; set; } = RunState.NoStart;
|
||||
|
||||
/// <summary>
|
||||
/// 用来在当前流程上下文间传递数据
|
||||
/// </summary>
|
||||
public Dictionary<string, object> ContextShareData { get; } = new Dictionary<string, object>();
|
||||
|
||||
/// <summary>
|
||||
/// 当前节点执行完成后,设置该属性,让运行环境判断接下来要执行哪个分支的节点。
|
||||
/// </summary>
|
||||
@@ -52,7 +57,7 @@ namespace Serein.Library.Core.NodeFlow
|
||||
/// <param name="PreviousNode">上一节点</param>
|
||||
public void SetPreviousNode(NodeModelBase currentNodeModel, NodeModelBase PreviousNode)
|
||||
{
|
||||
dictPreviousNodes.AddOrUpdate(currentNodeModel, (_)=> PreviousNode, (_,_) => PreviousNode);
|
||||
dictPreviousNodes.AddOrUpdate(currentNodeModel, (_) => PreviousNode, (_, _) => PreviousNode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,7 +85,7 @@ namespace Serein.Library.Core.NodeFlow
|
||||
/// <returns></returns>
|
||||
public object? GetFlowData(string nodeGuid)
|
||||
{
|
||||
if(dictNodeFlowData.TryGetValue(nodeGuid, out var data))
|
||||
if (dictNodeFlowData.TryGetValue(nodeGuid, out var data))
|
||||
{
|
||||
return data;
|
||||
}
|
||||
@@ -98,7 +103,7 @@ namespace Serein.Library.Core.NodeFlow
|
||||
public void AddOrUpdate(string nodeGuid, object? flowData)
|
||||
{
|
||||
// this.dictNodeFlowData.TryGetValue(nodeGuid, out var oldFlowData);
|
||||
this.dictNodeFlowData.AddOrUpdate(nodeGuid, _ => flowData, (_, _) => flowData);
|
||||
dictNodeFlowData.AddOrUpdate(nodeGuid, _ => flowData, (_, _) => flowData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,12 +113,12 @@ namespace Serein.Library.Core.NodeFlow
|
||||
public object? TransmissionData(NodeModelBase nodeModel)
|
||||
{
|
||||
if (dictPreviousNodes.TryGetValue(nodeModel, out var previousNode)) // 首先获取当前节点的上一节点
|
||||
{
|
||||
if (dictNodeFlowData.TryGetValue(previousNode.Guid, out var data)) // 其次获取上一节点的数据
|
||||
{
|
||||
{
|
||||
if (dictNodeFlowData.TryGetValue(previousNode.Guid, out var data)) // 其次获取上一节点的数据
|
||||
{
|
||||
return data;
|
||||
//AddOrUpdate(nodeModel.Guid, data); // 然后作为当前节点的数据记录在上下文中
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -134,7 +139,22 @@ namespace Serein.Library.Core.NodeFlow
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var nodeObj in ContextShareData.Values)
|
||||
{
|
||||
if (nodeObj is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof(IDisposable).IsAssignableFrom(nodeObj?.GetType()) && nodeObj is IDisposable disposable)
|
||||
{
|
||||
disposable?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.dictNodeFlowData?.Clear();
|
||||
this.ContextShareData?.Clear();
|
||||
RunState = RunState.Completion;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Serein.Library.Api;
|
||||
|
||||
namespace Serein.Library.Core.NodeFlow
|
||||
namespace Serein.Library.Core
|
||||
{
|
||||
public static class FlipflopFunc
|
||||
{
|
||||
@@ -56,7 +56,7 @@ namespace Serein.Library.Core.NodeFlow
|
||||
//if (innerType == typeof(IFlipflopContext))
|
||||
//if (innerType.IsGenericType && innerType.GetGenericTypeDefinition() == typeof(FlipflopContext<>))
|
||||
//{
|
||||
//return true;
|
||||
//return true;
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.0.15</Version>
|
||||
<Version>1.0.16</Version>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -23,7 +23,6 @@
|
||||
<Compile Remove="Flow\**" />
|
||||
<Compile Remove="Http\**" />
|
||||
<Compile Remove="IOC\**" />
|
||||
<Compile Remove="NodeFlow\Tool\**" />
|
||||
<Compile Remove="obj\**" />
|
||||
<Compile Remove="SerinExpression\**" />
|
||||
<Compile Remove="Tool\**" />
|
||||
@@ -31,7 +30,6 @@
|
||||
<EmbeddedResource Remove="Flow\**" />
|
||||
<EmbeddedResource Remove="Http\**" />
|
||||
<EmbeddedResource Remove="IOC\**" />
|
||||
<EmbeddedResource Remove="NodeFlow\Tool\**" />
|
||||
<EmbeddedResource Remove="obj\**" />
|
||||
<EmbeddedResource Remove="SerinExpression\**" />
|
||||
<EmbeddedResource Remove="Tool\**" />
|
||||
@@ -39,15 +37,12 @@
|
||||
<None Remove="Flow\**" />
|
||||
<None Remove="Http\**" />
|
||||
<None Remove="IOC\**" />
|
||||
<None Remove="NodeFlow\Tool\**" />
|
||||
<None Remove="obj\**" />
|
||||
<None Remove="SerinExpression\**" />
|
||||
<None Remove="Tool\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="NodeFlow\DynamicNodeCoreType.cs" />
|
||||
<Compile Remove="NodeFlow\FlowStateType.cs" />
|
||||
<Compile Remove="ServiceContainer.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user