mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-13 19:36:34 +08:00
1. 重新设计了Generate项目及相关特性的命名,避免与其他类型混淆。
2. 补充了部分注释。 3. 修改了删除容器节点时,容器内子节点未正确删除的问题。
This commit is contained in:
@@ -77,6 +77,7 @@ namespace Serein.NodeFlow.Services
|
||||
/// 生成完全的xml注释
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="retractCount"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToXmlComments(this string context, int retractCount = 0)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Serein.NodeFlow.Services
|
||||
/// <summary>
|
||||
/// 流程API服务,用于外部调用流程接口
|
||||
/// </summary>
|
||||
public class FlowApiService
|
||||
internal class FlowApiService
|
||||
{
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
private readonly FlowModelService flowModelService;
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace Serein.NodeFlow.Services
|
||||
private readonly FlowModelService flowModelService;
|
||||
private readonly FlowLibraryService flowLibraryService;
|
||||
|
||||
/// <summary>
|
||||
/// 流程代码生成服务
|
||||
/// </summary>
|
||||
/// <param name="flowModelService"></param>
|
||||
/// <param name="flowLibraryService"></param>
|
||||
public FlowCoreGenerateService(FlowModelService flowModelService ,FlowLibraryService flowLibraryService )
|
||||
{
|
||||
this.flowModelService = flowModelService;
|
||||
@@ -429,7 +434,6 @@ namespace Serein.NodeFlow.Services
|
||||
if (param is null) return;
|
||||
if (pds is null) return;
|
||||
|
||||
bool isGetPreviousNode = false;
|
||||
for (int index = 0; index < pds.Length; index++)
|
||||
{
|
||||
ParameterDetails? pd = pds[index];
|
||||
@@ -798,7 +802,6 @@ namespace Serein.NodeFlow.Services
|
||||
if (param is null) return;
|
||||
if (pds is null) return;
|
||||
|
||||
bool isGetPreviousNode = false;
|
||||
for (int index = 0; index < pds.Length; index++)
|
||||
{
|
||||
ParameterDetails? pd = pds[index];
|
||||
@@ -998,17 +1001,18 @@ namespace Serein.NodeFlow.Services
|
||||
sb.AppendCode(1, $"}}");
|
||||
}
|
||||
|
||||
public class SereinGlobalDataInfo
|
||||
|
||||
private class SereinGlobalDataInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局数据节点
|
||||
/// </summary>
|
||||
public SingleGlobalDataNode Node { get; set; }
|
||||
public required SingleGlobalDataNode Node { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全局数据的来源节点
|
||||
/// </summary>
|
||||
public IFlowNode DataSourceNode { get; set; }
|
||||
public required IFlowNode DataSourceNode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全局数据的键名
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace Serein.NodeFlow.Services
|
||||
/// </summary>
|
||||
public class FlowLibraryService
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数,初始化流程依赖
|
||||
/// </summary>
|
||||
/// <param name="flowEnvironment"></param>
|
||||
public FlowLibraryService(IFlowEnvironment flowEnvironment)
|
||||
{
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
@@ -35,10 +39,12 @@ namespace Serein.NodeFlow.Services
|
||||
/// 每个类库下面至少需要有“Serein.Library.dll”类库依赖
|
||||
/// </summary>
|
||||
/// <param name="libraryfilePath"></param>
|
||||
/// <param name="baseLibraryPath"></param>
|
||||
/// <returns></returns>
|
||||
private bool CheckBaseLibrary(string libraryfilePath, out string baseLibraryPath)
|
||||
{
|
||||
var dir = Path.GetDirectoryName(libraryfilePath); // 获取目录路径
|
||||
ArgumentNullException.ThrowIfNullOrWhiteSpace(dir);
|
||||
var sereinFlowBaseLibraryPath = Path.Combine(dir, SereinBaseLibrary);
|
||||
if (!Path.Exists(sereinFlowBaseLibraryPath))
|
||||
{
|
||||
@@ -146,7 +152,7 @@ namespace Serein.NodeFlow.Services
|
||||
/// </summary>
|
||||
/// <param name="assemblyName">程序集名称</param>
|
||||
/// <param name="methodName">方法名称</param>
|
||||
/// <param name="md">返回的方法描述</param>
|
||||
/// <param name="methodInfo">返回的方法描述</param>
|
||||
/// <returns>是否获取成功</returns>
|
||||
public bool TryGetMethodInfo(string assemblyName, string methodName, [MaybeNullWhen(false)] out MethodInfo methodInfo)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Model;
|
||||
using Serein.NodeFlow.Model.Nodes;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Serein.NodeFlow.Services
|
||||
{
|
||||
@@ -13,6 +14,11 @@ namespace Serein.NodeFlow.Services
|
||||
private readonly IFlowEnvironment environment;
|
||||
private readonly FlowLibraryService flowLibraryService;
|
||||
|
||||
/// <summary>
|
||||
/// 流程模型服务构造函数
|
||||
/// </summary>
|
||||
/// <param name="environment"></param>
|
||||
/// <param name="flowLibraryService"></param>
|
||||
public FlowModelService(IFlowEnvironment environment, FlowLibraryService flowLibraryService)
|
||||
{
|
||||
this.environment = environment;
|
||||
@@ -35,72 +41,156 @@ namespace Serein.NodeFlow.Services
|
||||
/// </summary>
|
||||
private List<SingleFlipflopNode> FlipflopNodes { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 获取节点模型
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <returns></returns>
|
||||
public IFlowNode? GetNodeModel(string guid)
|
||||
{
|
||||
NodeModels.TryGetValue(guid, out var nodeModel);
|
||||
return nodeModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取画布模型
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <returns></returns>
|
||||
public FlowCanvasDetails? GetCanvasModel(string guid)
|
||||
{
|
||||
FlowCanvass.TryGetValue(guid, out var nodeModel);
|
||||
return nodeModel;
|
||||
}
|
||||
|
||||
public bool TryGetNodeModel(string guid, out IFlowNode flowNode)
|
||||
/// <summary>
|
||||
/// 尝试获取节点模型
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="flowNode"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryGetNodeModel(string guid, [NotNullWhen(true)] out IFlowNode? flowNode)
|
||||
{
|
||||
return NodeModels.TryGetValue(guid, out flowNode!);
|
||||
}
|
||||
|
||||
public bool TryGetCanvasModel(string guid, out FlowCanvasDetails flowCanvas)
|
||||
/// <summary>
|
||||
/// 尝试获取画布模型
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="flowCanvas"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryGetCanvasModel(string guid, [NotNullWhen(true)] out FlowCanvasDetails? flowCanvas)
|
||||
{
|
||||
return FlowCanvass.TryGetValue(guid, out flowCanvas!); ;
|
||||
if(FlowCanvass.TryGetValue(guid, out var details))
|
||||
{
|
||||
flowCanvas = details;
|
||||
return true;
|
||||
}
|
||||
flowCanvas = details;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含节点模型
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <returns></returns>
|
||||
public bool ContainsNodeModel(string guid)
|
||||
{
|
||||
return NodeModels.ContainsKey(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否包含画布模型
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <returns></returns>
|
||||
public bool ContainsCanvasModel(string guid)
|
||||
{
|
||||
return FlowCanvass.ContainsKey(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加节点模型
|
||||
/// </summary>
|
||||
/// <param name="flowNode"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddNodeModel(IFlowNode flowNode)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(flowNode);
|
||||
ArgumentNullException.ThrowIfNull(flowNode.Guid);
|
||||
return NodeModels.TryAdd(flowNode.Guid, flowNode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加画布模型
|
||||
/// </summary>
|
||||
/// <param name="flowCanvasDetails"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddCanvasModel(FlowCanvasDetails flowCanvasDetails)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(flowCanvasDetails);
|
||||
ArgumentNullException.ThrowIfNull(flowCanvasDetails.Guid);
|
||||
return FlowCanvass.TryAdd(flowCanvasDetails.Guid, flowCanvasDetails);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除节点模型
|
||||
/// </summary>
|
||||
/// <param name="flowNode"></param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveNodeModel(IFlowNode flowNode)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(flowNode.Guid);
|
||||
return NodeModels.Remove(flowNode.Guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除画布模型
|
||||
/// </summary>
|
||||
/// <param name="flowCanvasDetails"></param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveCanvasModel(FlowCanvasDetails flowCanvasDetails)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(flowCanvasDetails.Guid);
|
||||
return FlowCanvass.Remove(flowCanvasDetails.Guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有节点模型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<IFlowNode> GetAllNodeModel() => [.. NodeModels.Values];
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定画布上的所有节点模型
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid"></param>
|
||||
/// <returns></returns>
|
||||
public List<IFlowNode> GetAllNodeModel(string canvasGuid) =>
|
||||
NodeModels.Values.Where(x => x.CanvasDetails.Guid == canvasGuid).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有画布模型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<FlowCanvasDetails> GetAllCanvasModel() => [.. FlowCanvass.Values];
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否存在画布模型
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsExsitCanvas()
|
||||
{
|
||||
return FlowCanvass.Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查指定画布上是否存在节点模型
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsExsitNodeOnCanvas(string canvasGuid)
|
||||
{
|
||||
if (!FlowCanvass.TryGetValue(canvasGuid, out var flowCanvasDetails))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Model.Operation;
|
||||
using Serein.NodeFlow.Model.Operations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
Reference in New Issue
Block a user