2025-01-22 21:09:52 +08:00
|
|
|
|
using Serein.Library;
|
2024-09-17 14:20:27 +08:00
|
|
|
|
using Serein.Library.Api;
|
2025-03-22 18:14:48 +08:00
|
|
|
|
using Serein.Library.FlowNode;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.Library.Utils;
|
|
|
|
|
|
using Serein.NodeFlow.Tool;
|
2025-03-18 11:52:54 +08:00
|
|
|
|
using System.Reflection;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-10-20 12:10:57 +08:00
|
|
|
|
namespace Serein.NodeFlow.Env
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 流程运行环境
|
2024-09-15 12:15:32 +08:00
|
|
|
|
/// </summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
public class FlowEnvironment : IFlowEnvironment, IFlowEnvironmentEvent
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2025-01-22 21:09:52 +08:00
|
|
|
|
public FlowEnvironment()
|
2024-09-20 10:50:32 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
flowEnvironment = new LocalFlowEnvironment();
|
|
|
|
|
|
// 默认使用本地环境
|
|
|
|
|
|
currentFlowEnvironment = flowEnvironment;
|
|
|
|
|
|
currentFlowEnvironmentEvent = flowEnvironment;
|
|
|
|
|
|
SereinEnv.SetEnv(currentFlowEnvironment);
|
2024-10-15 21:56:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 本地环境
|
2024-10-15 21:56:09 +08:00
|
|
|
|
/// </summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
private readonly LocalFlowEnvironment flowEnvironment;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-12-12 20:31:50 +08:00
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 远程环境
|
2024-12-12 20:31:50 +08:00
|
|
|
|
/// </summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
private RemoteFlowEnvironment remoteFlowEnvironment;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 本地环境事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-05-26 23:55:23 +08:00
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 远程环境事件
|
2025-05-26 23:55:23 +08:00
|
|
|
|
/// </summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
private IFlowEnvironmentEvent remoteFlowEnvironmentEvent;
|
2025-05-26 23:55:23 +08:00
|
|
|
|
|
2025-03-21 18:26:01 +08:00
|
|
|
|
|
2024-09-22 14:10:13 +08:00
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 管理当前环境
|
2024-09-22 14:10:13 +08:00
|
|
|
|
/// </summary>
|
2025-03-21 18:26:01 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
private IFlowEnvironment currentFlowEnvironment;
|
2024-09-22 17:37:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 管理当前环境事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private IFlowEnvironmentEvent currentFlowEnvironmentEvent;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
private int _loadingProjectFlag = 0; // 使用原子自增代替锁
|
2024-11-02 16:48:40 +08:00
|
|
|
|
|
2024-12-09 22:57:06 +08:00
|
|
|
|
|
2024-11-02 16:48:40 +08:00
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 传入false时,将停止数据通知。传入true时,
|
2024-11-02 16:48:40 +08:00
|
|
|
|
/// </summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
|
public void SetProjectLoadingFlag(bool value)
|
2024-11-02 16:48:40 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
Interlocked.Exchange(ref _loadingProjectFlag, value ? 1 : 0);
|
2024-11-02 16:48:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// 判断是否正在加载项目
|
2024-11-02 16:48:40 +08:00
|
|
|
|
/// </summary>
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool IsLoadingProject()
|
2024-11-02 16:48:40 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return Interlocked.CompareExchange(ref _loadingProjectFlag, 1, 1) == 1;
|
2024-11-02 16:48:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public IFlowEnvironment CurrentEnv { get => currentFlowEnvironment; }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public UIContextOperation UIContextOperation => currentFlowEnvironment.UIContextOperation;
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public NodeMVVMManagement NodeMVVMManagement => currentFlowEnvironment.NodeMVVMManagement;
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public ISereinIOC IOC => (ISereinIOC)currentFlowEnvironment;
|
2024-11-02 16:48:40 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string EnvName => currentFlowEnvironment.EnvName;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string ProjectFileLocation => currentFlowEnvironment.EnvName;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool IsGlobalInterrupt => currentFlowEnvironment.IsGlobalInterrupt;
|
2024-10-10 10:45:53 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool IsControlRemoteEnv => currentFlowEnvironment.IsControlRemoteEnv;
|
2024-11-03 18:28:16 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public InfoClass InfoClass { get => currentFlowEnvironment.InfoClass; set => currentFlowEnvironment.InfoClass = value; }
|
2024-11-03 18:28:16 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public RunState FlowState { get => currentFlowEnvironment.FlowState; set => currentFlowEnvironment.FlowState = value; }
|
2024-09-30 02:45:49 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event LoadDllHandler OnDllLoad {
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnDllLoad += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnDllLoad -= value; }
|
|
|
|
|
|
}
|
2024-11-03 18:28:16 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event ProjectLoadedHandler OnProjectLoaded
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnProjectLoaded += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnProjectLoaded -= value; }
|
|
|
|
|
|
}
|
2024-11-03 18:28:16 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event ProjectSavingHandler? OnProjectSaving
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnProjectSaving += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnProjectSaving -= value; }
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeConnectChangeHandler OnNodeConnectChange
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeConnectChange += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeConnectChange -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event CanvasCreateHandler OnCanvasCreate
|
2025-05-30 15:42:59 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
add { currentFlowEnvironmentEvent.OnCanvasCreate += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnCanvasCreate -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event CanvasRemoveHandler OnCanvasRemove
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnCanvasRemove += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnCanvasRemove -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeCreateHandler OnNodeCreate
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeCreate += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeCreate -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeRemoveHandler OnNodeRemove
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeRemove += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeRemove -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodePlaceHandler OnNodePlace
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodePlace += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodePlace -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeTakeOutHandler OnNodeTakeOut
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeTakeOut += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeTakeOut -= value; }
|
2025-05-30 15:42:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event StartNodeChangeHandler OnStartNodeChange
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnStartNodeChange += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnStartNodeChange -= value; }
|
|
|
|
|
|
}
|
2025-05-30 15:42:59 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event FlowRunCompleteHandler OnFlowRunComplete
|
2024-10-10 16:49:37 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
add { currentFlowEnvironmentEvent.OnFlowRunComplete += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnFlowRunComplete -= value; }
|
|
|
|
|
|
}
|
2024-09-30 02:45:49 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event MonitorObjectChangeHandler OnMonitorObjectChange
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnMonitorObjectChange += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnMonitorObjectChange -= value; }
|
|
|
|
|
|
}
|
2024-10-20 21:59:42 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeInterruptStateChangeHandler OnNodeInterruptStateChange
|
2024-10-27 00:54:10 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeInterruptStateChange += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeInterruptStateChange -= value; }
|
|
|
|
|
|
}
|
2024-10-20 21:59:42 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event ExpInterruptTriggerHandler OnInterruptTrigger
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnInterruptTrigger += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnInterruptTrigger -= value; }
|
2024-10-10 16:49:37 +08:00
|
|
|
|
}
|
2024-09-30 02:45:49 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event IOCMembersChangedHandler OnIOCMembersChanged
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnIOCMembersChanged += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnIOCMembersChanged -= value; }
|
|
|
|
|
|
}
|
2024-09-28 23:55:19 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeLocatedHandler OnNodeLocated
|
2024-10-20 12:10:57 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeLocated += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeLocated -= value; }
|
|
|
|
|
|
}
|
2024-09-17 14:20:27 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event NodeMovedHandler OnNodeMoved
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnNodeMoved += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnNodeMoved -= value; }
|
2024-09-17 14:20:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public event EnvOutHandler OnEnvOut
|
|
|
|
|
|
{
|
|
|
|
|
|
add { currentFlowEnvironmentEvent.OnEnvOut += value; }
|
|
|
|
|
|
remove { currentFlowEnvironmentEvent.OnEnvOut -= value; }
|
2024-10-24 23:32:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void ActivateFlipflopNode(string nodeGuid)
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
currentFlowEnvironment.ActivateFlipflopNode(nodeGuid);
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<FlowCanvasDetailsInfo> CreateCanvasAsync(string canvasName, int width, int height)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.CreateCanvasAsync(canvasName, width, height);
|
|
|
|
|
|
}
|
2024-09-28 23:55:19 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> RemoveCanvasAsync(string canvasGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.RemoveCanvasAsync(canvasGuid);
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> ConnectInvokeNodeAsync(string canvasGuid,
|
|
|
|
|
|
string fromNodeGuid,
|
|
|
|
|
|
string toNodeGuid,
|
|
|
|
|
|
JunctionType fromNodeJunctionType,
|
|
|
|
|
|
JunctionType toNodeJunctionType,
|
|
|
|
|
|
ConnectionInvokeType invokeType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.ConnectInvokeNodeAsync(canvasGuid, fromNodeGuid, toNodeGuid, fromNodeJunctionType, toNodeJunctionType, invokeType);
|
|
|
|
|
|
}
|
2024-10-20 21:59:42 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> ConnectArgSourceNodeAsync(string canvasGuid,
|
|
|
|
|
|
string fromNodeGuid,
|
|
|
|
|
|
string toNodeGuid,
|
|
|
|
|
|
JunctionType fromNodeJunctionType,
|
|
|
|
|
|
JunctionType toNodeJunctionType,
|
|
|
|
|
|
ConnectionArgSourceType argSourceType,
|
|
|
|
|
|
int argIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.ConnectArgSourceNodeAsync(canvasGuid, fromNodeGuid, toNodeGuid, fromNodeJunctionType, toNodeJunctionType, argSourceType, argIndex);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<(bool, RemoteMsgUtil)> ConnectRemoteEnv(string addres, int port, string token)
|
2024-10-24 23:32:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
// 连接成功,切换远程环境
|
|
|
|
|
|
(var isConnect, var remoteMsgUtil) = await currentFlowEnvironment.ConnectRemoteEnv(addres, port, token);
|
|
|
|
|
|
if (isConnect)
|
2025-03-22 18:14:48 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
remoteFlowEnvironment ??= new RemoteFlowEnvironment(remoteMsgUtil, this.UIContextOperation);
|
|
|
|
|
|
currentFlowEnvironment = remoteFlowEnvironment;
|
2025-03-22 18:14:48 +08:00
|
|
|
|
}
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return (isConnect, remoteMsgUtil);
|
|
|
|
|
|
}
|
2025-03-22 18:14:48 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task LoadNodeInfosAsync(List<NodeInfo> nodeInfos)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProjectLoadingFlag(false);
|
|
|
|
|
|
await currentFlowEnvironment.LoadNodeInfosAsync(nodeInfos); // 装饰器调用
|
|
|
|
|
|
SetProjectLoadingFlag(true);
|
|
|
|
|
|
}
|
2025-05-30 01:02:25 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<NodeInfo> CreateNodeAsync(string canvasGuid, NodeControlType nodeBase, PositionOfUI position, MethodDetailsInfo methodDetailsInfo = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProjectLoadingFlag(false);
|
|
|
|
|
|
var result = await currentFlowEnvironment.CreateNodeAsync(canvasGuid, nodeBase, position, methodDetailsInfo); // 装饰器调用
|
|
|
|
|
|
SetProjectLoadingFlag(true);
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2025-05-30 01:02:25 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> PlaceNodeToContainerAsync(string canvasGuid, string nodeGuid, string containerNodeGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProjectLoadingFlag(false);
|
|
|
|
|
|
var result = await currentFlowEnvironment.PlaceNodeToContainerAsync(canvasGuid, nodeGuid, containerNodeGuid); // 装饰器调用
|
|
|
|
|
|
SetProjectLoadingFlag(true);
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2025-05-30 01:02:25 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> TakeOutNodeToContainerAsync(string canvasGuid, string nodeGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProjectLoadingFlag(false);
|
|
|
|
|
|
var result = await currentFlowEnvironment.TakeOutNodeToContainerAsync(canvasGuid,nodeGuid); // 装饰器调用
|
|
|
|
|
|
SetProjectLoadingFlag(true);
|
|
|
|
|
|
return result;
|
2024-10-24 23:32:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> ExitFlowAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.ExitFlowAsync();
|
|
|
|
|
|
}
|
2024-10-24 23:32:43 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void ExitRemoteEnv()
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
currentFlowEnvironment.ExitRemoteEnv();
|
|
|
|
|
|
}
|
2024-12-26 00:26:50 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<FlowEnvInfo> GetEnvInfoAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.GetEnvInfoAsync();
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
2024-09-17 14:20:27 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<SereinProjectData> GetProjectInfoAsync()
|
2024-12-26 22:24:44 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.GetProjectInfoAsync();
|
2024-12-26 22:24:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void LoadLibrary(string dllPath)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.LoadLibrary(dllPath);
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void SaveProject()
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.SaveProject();
|
|
|
|
|
|
}
|
2024-09-27 23:47:25 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void LoadProject(FlowEnvInfo flowEnvInfo, string filePath)
|
2024-09-27 23:47:25 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
if (flowEnvInfo is null) return;
|
|
|
|
|
|
SetProjectLoadingFlag(false);
|
|
|
|
|
|
currentFlowEnvironment.LoadProject(flowEnvInfo, filePath);
|
|
|
|
|
|
SetProjectLoadingFlag(true);
|
2024-09-27 23:47:25 +08:00
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void MonitorObjectNotification(string nodeGuid, object monitorData, MonitorObjectEventArgs.ObjSourceType sourceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.MonitorObjectNotification(nodeGuid, monitorData, sourceType);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void MoveNode(string canvasGuid, string nodeGuid, double x, double y)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.MoveNode(canvasGuid, nodeGuid, x, y);
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void NodeLocated(string nodeGuid)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
currentFlowEnvironment.NodeLocated(nodeGuid);
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool TryUnloadLibrary(string assemblyName)
|
2025-06-02 15:16:23 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return currentFlowEnvironment.TryUnloadLibrary(assemblyName);
|
2025-06-02 15:16:23 +08:00
|
|
|
|
}
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> SetConnectPriorityInvoke(string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.SetConnectPriorityInvoke(fromNodeGuid, toNodeGuid, connectionType);
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> RemoveConnectInvokeAsync(string canvasGuid, string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.RemoveConnectInvokeAsync(canvasGuid, fromNodeGuid, toNodeGuid, connectionType);
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> RemoveConnectArgSourceAsync(string canvasGuid, string fromNodeGuid, string toNodeGuid, int argIndex)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.RemoveConnectArgSourceAsync(canvasGuid, fromNodeGuid, toNodeGuid, argIndex);
|
2025-06-02 15:16:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> RemoveNodeAsync(string canvasGuid, string nodeGuid)
|
2025-06-02 15:16:23 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.RemoveNodeAsync(canvasGuid, nodeGuid);
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 输出信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="message">日志内容</param>
|
|
|
|
|
|
/// <param name="type">日志类别</param>
|
|
|
|
|
|
/// <param name="class">日志级别</param>
|
|
|
|
|
|
public void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.WriteLine(type, message, @class);
|
|
|
|
|
|
}
|
2024-09-24 22:39:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
#region MyRegion
|
|
|
|
|
|
#if false
|
|
|
|
|
|
public async Task<bool> AddInterruptExpressionAsync(string key, string expression)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.AddInterruptExpressionAsync(key, expression);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-24 22:39:43 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
public async Task<(bool, string[])> CheckObjMonitorStateAsync(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.CheckObjMonitorStateAsync(key);
|
|
|
|
|
|
}
|
|
|
|
|
|
public async Task<ChannelFlowInterrupt.CancelType> GetOrCreateGlobalInterruptAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.InterruptNode();
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
public void SetMonitorObjState(string key, bool isMonitor)
|
2024-09-30 02:45:49 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
currentFlowEnvironment.SetMonitorObjState(key, isMonitor);
|
2024-09-30 02:45:49 +08:00
|
|
|
|
}
|
2024-09-24 22:39:43 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
public async Task<bool> SetNodeInterruptAsync(string nodeGuid, bool isInterrupt)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.SetNodeInterruptAsync(nodeGuid, isInterrupt);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2024-10-11 19:31:34 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
#endregion
|
2024-12-26 22:24:44 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<string> SetStartNodeAsync(string canvasGuid, string nodeGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.SetStartNodeAsync(canvasGuid, nodeGuid);
|
|
|
|
|
|
}
|
2024-09-24 22:39:43 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> StartFlowAsync(string[] canvasGuids)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.StartFlowAsync(canvasGuids);
|
2024-09-30 02:45:49 +08:00
|
|
|
|
}
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> StartFlowFromSelectNodeAsync(string startNodeGuid)
|
2024-09-30 02:45:49 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
return await currentFlowEnvironment.StartFlowFromSelectNodeAsync(startNodeGuid);
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
2025-06-02 16:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task StartRemoteServerAsync(int port = 7525)
|
2024-09-24 22:39:43 +08:00
|
|
|
|
{
|
2025-06-02 16:38:37 +08:00
|
|
|
|
await currentFlowEnvironment.StartRemoteServerAsync(port);
|
2024-09-24 22:39:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void StopRemoteServer()
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.StopRemoteServer();
|
|
|
|
|
|
}
|
2024-09-24 22:39:43 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void TerminateFlipflopNode(string nodeGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.TerminateFlipflopNode(nodeGuid);
|
|
|
|
|
|
}
|
2024-09-24 22:39:43 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.TriggerInterrupt(nodeGuid, expression, type);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void SetUIContextOperation(UIContextOperation uiContextOperation)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.SetUIContextOperation(uiContextOperation);
|
|
|
|
|
|
}
|
2024-10-15 21:56:09 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void UseExternalIOC(ISereinIOC ioc)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.UseExternalIOC(ioc);
|
|
|
|
|
|
}
|
2024-10-15 21:56:09 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return currentFlowEnvironment.TryGetNodeModel(nodeGuid, out nodeModel);
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool TryGetDelegateDetails(string libraryName, string methodName, out DelegateDetails del)
|
|
|
|
|
|
{
|
|
|
|
|
|
return currentFlowEnvironment.TryGetDelegateDetails(libraryName, methodName, out del);
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool TryGetMethodDetailsInfo(string libraryName, string methodName, out MethodDetailsInfo mdInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
return currentFlowEnvironment.TryGetMethodDetailsInfo(libraryName, methodName, out mdInfo);
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task NotificationNodeValueChangeAsync(string nodeGuid, string path, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsLoadingProject())
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (currentFlowEnvironment.IsControlRemoteEnv)
|
|
|
|
|
|
{
|
|
|
|
|
|
await currentFlowEnvironment.NotificationNodeValueChangeAsync(nodeGuid, path, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public async Task<bool> ChangeParameter(string nodeGuid, bool isAdd, int paramIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await currentFlowEnvironment.ChangeParameter(nodeGuid, isAdd, paramIndex);
|
|
|
|
|
|
}
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
#region 流程依赖类库的接口
|
2024-10-20 12:10:57 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool LoadNativeLibraryOfRuning(string file)
|
|
|
|
|
|
{
|
|
|
|
|
|
return currentFlowEnvironment.LoadNativeLibraryOfRuning(file);
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public void LoadAllNativeLibraryOfRuning(string path, bool isRecurrence = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentFlowEnvironment.LoadAllNativeLibraryOfRuning(path,isRecurrence);
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
#endregion
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2025-06-02 16:38:37 +08:00
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|