mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-17 05:16:35 +08:00
优化FlowEnv
This commit is contained in:
63
NodeFlow/Services/FlowApiService.cs
Normal file
63
NodeFlow/Services/FlowApiService.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Serein.Library.Api;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser;
|
||||
|
||||
namespace Serein.NodeFlow.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 流程API服务,用于外部调用流程接口
|
||||
/// </summary>
|
||||
public class FlowApiService
|
||||
{
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
private readonly FlowModelService flowModelService;
|
||||
|
||||
/// <summary>
|
||||
/// 流程API服务构造函数
|
||||
/// </summary>
|
||||
/// <param name="flowEnvironment"></param>
|
||||
/// <param name="flowModelService"></param>
|
||||
public FlowApiService(IFlowEnvironment flowEnvironment,
|
||||
FlowModelService flowModelService)
|
||||
{
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
this.flowModelService = flowModelService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* object result = flowApiService.Invoke("", params);
|
||||
TResult result = flowApiService.Invoke<TResult>("", params);
|
||||
object result = await flowApiService.InvokeAsync("", params);
|
||||
TResult result = await flowApiService.InvokeAsync<TResult>("", params);*/
|
||||
|
||||
|
||||
public object Invoke(string apiName, object[] param)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public TResult Invoke<TResult>(string apiName, object[] param)
|
||||
{
|
||||
return default(TResult);
|
||||
}
|
||||
|
||||
public async Task<object> InvokeAsync(string apiName, object[] param)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<TResult> InvokeAsync<TResult>(string apiName, object[] param)
|
||||
{
|
||||
return default(TResult);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Services
|
||||
{
|
||||
internal class FlowModelService
|
||||
/// <summary>
|
||||
/// 流程模型服务
|
||||
/// </summary>
|
||||
public class FlowModelService
|
||||
{
|
||||
private readonly IFlowEnvironment environment;
|
||||
|
||||
@@ -91,9 +94,24 @@ namespace Serein.NodeFlow.Services
|
||||
}
|
||||
|
||||
public List<IFlowNode> GetAllNodeModel() => [.. NodeModels.Values];
|
||||
public List<IFlowNode> GetAllNodeModel(string canvasGuid) =>
|
||||
NodeModels.Values.Where(x => x.CanvasDetails.Guid == canvasGuid).ToList();
|
||||
public List<FlowCanvasDetails> GetAllCanvasModel() => [.. FlowCanvass.Values];
|
||||
|
||||
|
||||
|
||||
public bool IsExsitCanvas()
|
||||
{
|
||||
return FlowCanvass.Count > 0;
|
||||
}
|
||||
public bool IsExsitNodeOnCanvas(string canvasGuid)
|
||||
{
|
||||
if (!FlowCanvass.TryGetValue(canvasGuid, out var flowCanvasDetails))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return flowCanvasDetails.Nodes.Count > 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,10 +266,9 @@ namespace Serein.NodeFlow.Services
|
||||
/// <summary>
|
||||
/// 从选定的节点开始运行
|
||||
/// </summary>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="startNode"></param>
|
||||
/// <returns></returns>
|
||||
public async Task StartFlowInSelectNodeAsync(IFlowEnvironment env, IFlowNode startNode)
|
||||
public async Task StartFlowInSelectNodeAsync(IFlowNode startNode)
|
||||
{
|
||||
var pool = WorkOptions.FlowContextPool;
|
||||
var context = pool.Allocate();
|
||||
|
||||
Reference in New Issue
Block a user