mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-15 04:16:34 +08:00
1. 重新设计了Generate项目及相关特性的命名,避免与其他类型混淆。
2. 补充了部分注释。 3. 修改了删除容器节点时,容器内子节点未正确删除的问题。
This commit is contained in:
@@ -54,11 +54,12 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
|
||||
|
||||
private FlowWorkManagement flowWorkManagement;
|
||||
private ISereinIOC externalIOC;
|
||||
private Action<ISereinIOC> setDefultMemberOnReset;
|
||||
private FlowWorkManagement? flowWorkManagement;
|
||||
private ISereinIOC? externalIOC;
|
||||
private Action<ISereinIOC>? setDefultMemberOnReset;
|
||||
private bool IsUseExternalIOC = false;
|
||||
private object lockObj = new object();
|
||||
private readonly object lockObj = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 如果全局触发器还在运行,则为 Running 。
|
||||
/// </summary>
|
||||
@@ -313,7 +314,7 @@ namespace Serein.NodeFlow.Env
|
||||
}*/
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void UseExternalIOC(ISereinIOC ioc, Action<ISereinIOC> setDefultMemberOnReset = null)
|
||||
public void UseExternalIOC(ISereinIOC ioc, Action<ISereinIOC>? setDefultMemberOnReset = null)
|
||||
{
|
||||
IOC = ioc; // 设置IOC容器
|
||||
this.setDefultMemberOnReset = setDefultMemberOnReset;
|
||||
|
||||
@@ -4,12 +4,13 @@ using Serein.Library.Api;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.NodeFlow.Model;
|
||||
using Serein.NodeFlow.Model.Nodes;
|
||||
using Serein.NodeFlow.Model.Operation;
|
||||
using Serein.NodeFlow.Model.Operations;
|
||||
using Serein.NodeFlow.Services;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using static Serein.Library.Api.IFlowEnvironment;
|
||||
using IOperation = Serein.NodeFlow.Model.Operation.IOperation;
|
||||
using IOperation = Serein.NodeFlow.Model.Operations.IOperation;
|
||||
|
||||
namespace Serein.NodeFlow.Env
|
||||
{
|
||||
@@ -47,7 +48,7 @@ namespace Serein.NodeFlow.Env
|
||||
private readonly FlowLibraryService flowLibraryManagement;
|
||||
private readonly FlowOperationService flowOperationService;
|
||||
private readonly FlowModelService flowModelService;
|
||||
private readonly NodeMVVMService nodeMVVMService;
|
||||
//private readonly NodeMVVMService nodeMVVMService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -74,17 +75,23 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 从Guid获取画布
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <returns>节点Model</returns>
|
||||
/// <exception cref="ArgumentNullException">无法获取节点、Guid/节点为null时报错</exception>
|
||||
public bool TryGetCanvasModel(string nodeGuid, out FlowCanvasDetails canvasDetails)
|
||||
/// <param name="nodeGuid">画布Guid</param>
|
||||
/// <param name="canvasDetails">画布model</param>
|
||||
/// <returns>是否获取成功</returns>
|
||||
public bool TryGetCanvasModel(string nodeGuid, [NotNullWhen(true)] out FlowCanvasDetails? canvasDetails)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nodeGuid))
|
||||
{
|
||||
canvasDetails = null;
|
||||
canvasDetails = default;
|
||||
return false;
|
||||
}
|
||||
return flowModelService.TryGetCanvasModel(nodeGuid, out canvasDetails);
|
||||
if(flowModelService.TryGetCanvasModel(nodeGuid, out var flowCanvas))
|
||||
{
|
||||
canvasDetails = flowCanvas;
|
||||
return true;
|
||||
}
|
||||
canvasDetails = default;
|
||||
return false ;
|
||||
|
||||
}
|
||||
|
||||
@@ -92,9 +99,9 @@ namespace Serein.NodeFlow.Env
|
||||
/// 从Guid获取节点
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <returns>节点Model</returns>
|
||||
/// <exception cref="ArgumentNullException">无法获取节点、Guid/节点为null时报错</exception>
|
||||
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
||||
/// <param name="nodeModel">节点Model</param>
|
||||
/// <returns>是否获取成功</returns>
|
||||
public bool TryGetNodeModel(string nodeGuid, [NotNullWhen(true)]out IFlowNode? nodeModel)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nodeGuid))
|
||||
{
|
||||
@@ -176,7 +183,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 创建节点
|
||||
/// </summary>
|
||||
/// <param name="nodeBase"></param>
|
||||
/// <param name="nodeModel"></param>
|
||||
private bool TryAddNode(IFlowNode nodeModel)
|
||||
{
|
||||
nodeModel.Guid ??= Guid.NewGuid().ToString();
|
||||
@@ -218,7 +225,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
};
|
||||
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void RemoveCanvas(string canvasGuid)
|
||||
@@ -227,7 +234,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
CanvasGuid = canvasGuid
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void ConnectInvokeNode(string canvasGuid, string fromNodeGuid, string toNodeGuid, JunctionType fromNodeJunctionType, JunctionType toNodeJunctionType, ConnectionInvokeType invokeType)
|
||||
@@ -244,7 +251,7 @@ namespace Serein.NodeFlow.Env
|
||||
JunctionOfConnectionType = JunctionOfConnectionType.Invoke,
|
||||
};
|
||||
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void ConnectArgSourceNode(string canvasGuid, string fromNodeGuid, string toNodeGuid, JunctionType fromNodeJunctionType, JunctionType toNodeJunctionType, ConnectionArgSourceType argSourceType, int argIndex)
|
||||
@@ -261,7 +268,7 @@ namespace Serein.NodeFlow.Env
|
||||
ChangeType = NodeConnectChangeEventArgs.ConnectChangeType.Create,
|
||||
JunctionOfConnectionType = JunctionOfConnectionType.Arg,
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void RemoveInvokeConnect(string canvasGuid, string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
||||
@@ -275,7 +282,7 @@ namespace Serein.NodeFlow.Env
|
||||
ChangeType = NodeConnectChangeEventArgs.ConnectChangeType.Remove,
|
||||
JunctionOfConnectionType = JunctionOfConnectionType.Invoke,
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void RemoveArgSourceConnect(string canvasGuid, string fromNodeGuid, string toNodeGuid, int argIndex)
|
||||
@@ -289,10 +296,10 @@ namespace Serein.NodeFlow.Env
|
||||
ChangeType = NodeConnectChangeEventArgs.ConnectChangeType.Remove,
|
||||
JunctionOfConnectionType = JunctionOfConnectionType.Arg,
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void CreateNode(string canvasGuid, NodeControlType nodeType, PositionOfUI position, MethodDetailsInfo methodDetailsInfo = null)
|
||||
public void CreateNode(string canvasGuid, NodeControlType nodeType, PositionOfUI position, MethodDetailsInfo? methodDetailsInfo = null)
|
||||
{
|
||||
IOperation operation = new CreateNodeOperation
|
||||
{
|
||||
@@ -301,7 +308,7 @@ namespace Serein.NodeFlow.Env
|
||||
Position = position,
|
||||
MethodDetailsInfo = methodDetailsInfo
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void RemoveNode(string canvasGuid, string nodeGuid)
|
||||
@@ -311,7 +318,7 @@ namespace Serein.NodeFlow.Env
|
||||
CanvasGuid = canvasGuid,
|
||||
NodeGuid = nodeGuid
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void PlaceNodeToContainer(string canvasGuid, string nodeGuid, string containerNodeGuid)
|
||||
@@ -322,7 +329,7 @@ namespace Serein.NodeFlow.Env
|
||||
NodeGuid = nodeGuid,
|
||||
ContainerNodeGuid = containerNodeGuid
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void TakeOutNodeToContainer(string canvasGuid, string nodeGuid)
|
||||
@@ -332,36 +339,17 @@ namespace Serein.NodeFlow.Env
|
||||
CanvasGuid = canvasGuid,
|
||||
NodeGuid = nodeGuid,
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void SetStartNode(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
|
||||
IOperation operation = new SetStartNodeOperation
|
||||
{
|
||||
CanvasGuid = canvasGuid,
|
||||
NewNodeGuid = nodeGuid,
|
||||
};
|
||||
_ = flowOperationService.Execute(operation);
|
||||
|
||||
return;
|
||||
if (!TryGetCanvasModel(canvasGuid, out var canvasModel) || !TryGetNodeModel(nodeGuid, out var newStartNodeModel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var oldNodeGuid = canvasModel.StartNode?.Guid;
|
||||
/*if(TryGetNodeModel(oldNodeGuid, out var newStartNodeModel))
|
||||
{
|
||||
newStartNode.IsStart = false;
|
||||
}*/
|
||||
canvasModel.StartNode = newStartNodeModel;
|
||||
//newStartNode.IsStart = true;
|
||||
|
||||
_ = SereinEnv.TriggerEvent(() =>
|
||||
flowEnvironmentEvent.OnStartNodeChanged(
|
||||
new StartNodeChangeEventArgs(canvasGuid, oldNodeGuid, newStartNodeModel.Guid)
|
||||
));
|
||||
return;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
@@ -376,7 +364,7 @@ namespace Serein.NodeFlow.Env
|
||||
ConnectionInvokeType = connectionType,
|
||||
ChangeType = NodeConnectChangeEventArgs.ConnectChangeType.Create
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void ChangeParameter(string nodeGuid, bool isAdd, int paramIndex)
|
||||
@@ -387,7 +375,7 @@ namespace Serein.NodeFlow.Env
|
||||
IsAdd = isAdd,
|
||||
ParamIndex = paramIndex
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
_ = flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -170,7 +170,6 @@ namespace Serein.NodeFlow.Env
|
||||
return (isConnect, remoteMsgUtil);
|
||||
}*/
|
||||
|
||||
/// <inheritdoc/>
|
||||
/* public async Task<bool> ExitFlowAsync()
|
||||
{
|
||||
return await currentFlowEnvironment.FlowControl.ExitFlowAsync();
|
||||
@@ -190,9 +189,9 @@ namespace Serein.NodeFlow.Env
|
||||
}*/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SereinProjectData> GetProjectInfoAsync()
|
||||
public SereinProjectData GetProjectInfoAsync()
|
||||
{
|
||||
return await currentFlowEnvironment.GetProjectInfoAsync();
|
||||
return currentFlowEnvironment.GetProjectInfoAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -3,112 +3,150 @@ using Serein.Library.Api;
|
||||
|
||||
namespace Serein.NodeFlow.Env
|
||||
{
|
||||
/// <summary>
|
||||
/// 流程环境事件类
|
||||
/// </summary>
|
||||
public class FlowEnvironmentEvent : IFlowEnvironmentEvent
|
||||
{
|
||||
public event LoadDllHandler DllLoad;
|
||||
public event ProjectLoadedHandler ProjectLoaded;
|
||||
public event ProjectSavingHandler ProjectSaving;
|
||||
public event NodeConnectChangeHandler NodeConnectChanged;
|
||||
public event CanvasCreateHandler CanvasCreated;
|
||||
public event CanvasRemoveHandler CanvasRemoved;
|
||||
public event NodeCreateHandler NodeCreated;
|
||||
public event NodeRemoveHandler NodeRemoved;
|
||||
public event NodePlaceHandler NodePlace;
|
||||
public event NodeTakeOutHandler NodeTakeOut;
|
||||
public event StartNodeChangeHandler StartNodeChanged;
|
||||
public event FlowRunCompleteHandler FlowRunComplete;
|
||||
public event MonitorObjectChangeHandler MonitorObjectChanged;
|
||||
public event NodeInterruptStateChangeHandler NodeInterruptStateChanged;
|
||||
public event ExpInterruptTriggerHandler InterruptTriggered;
|
||||
public event IOCMembersChangedHandler IOCMembersChanged;
|
||||
public event NodeLocatedHandler NodeLocated;
|
||||
public event EnvOutHandler EnvOutput;
|
||||
/// <inheritdoc/>
|
||||
public event LoadDllHandler? DllLoad;
|
||||
/// <inheritdoc/>
|
||||
public event ProjectLoadedHandler? ProjectLoaded;
|
||||
/// <inheritdoc/>
|
||||
public event ProjectSavingHandler? ProjectSaving;
|
||||
/// <inheritdoc/>
|
||||
public event NodeConnectChangeHandler? NodeConnectChanged;
|
||||
/// <inheritdoc/>
|
||||
public event CanvasCreateHandler? CanvasCreated;
|
||||
/// <inheritdoc/>
|
||||
public event CanvasRemoveHandler? CanvasRemoved;
|
||||
/// <inheritdoc/>
|
||||
public event NodeCreateHandler? NodeCreated;
|
||||
/// <inheritdoc/>
|
||||
public event NodeRemoveHandler? NodeRemoved;
|
||||
/// <inheritdoc/>
|
||||
public event NodePlaceHandler? NodePlace;
|
||||
/// <inheritdoc/>
|
||||
public event NodeTakeOutHandler? NodeTakeOut;
|
||||
/// <inheritdoc/>
|
||||
public event StartNodeChangeHandler? StartNodeChanged;
|
||||
/// <inheritdoc/>
|
||||
public event FlowRunCompleteHandler? FlowRunComplete;
|
||||
/// <inheritdoc/>
|
||||
public event MonitorObjectChangeHandler? MonitorObjectChanged;
|
||||
/// <inheritdoc/>
|
||||
public event NodeInterruptStateChangeHandler? NodeInterruptStateChanged;
|
||||
/// <inheritdoc/>
|
||||
public event ExpInterruptTriggerHandler? InterruptTriggered;
|
||||
/// <inheritdoc/>
|
||||
public event IOCMembersChangedHandler? IOCMembersChanged;
|
||||
/// <inheritdoc/>
|
||||
public event NodeLocatedHandler? NodeLocated;
|
||||
/// <inheritdoc/>
|
||||
public event EnvOutHandler? EnvOutput;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnDllLoad(LoadDllEventArgs eventArgs)
|
||||
{
|
||||
DllLoad?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||
{
|
||||
ProjectLoaded?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnProjectSaving(ProjectSavingEventArgs eventArgs)
|
||||
{
|
||||
ProjectSaving?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodeConnectChanged(NodeConnectChangeEventArgs eventArgs)
|
||||
{
|
||||
NodeConnectChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnCanvasCreated(CanvasCreateEventArgs eventArgs)
|
||||
{
|
||||
CanvasCreated?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnCanvasRemoved(CanvasRemoveEventArgs eventArgs)
|
||||
{
|
||||
CanvasRemoved?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodeCreated(NodeCreateEventArgs eventArgs)
|
||||
{
|
||||
NodeCreated?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodeRemoved(NodeRemoveEventArgs eventArgs)
|
||||
{
|
||||
NodeRemoved?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodePlace(NodePlaceEventArgs eventArgs)
|
||||
{
|
||||
NodePlace?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodeTakeOut(NodeTakeOutEventArgs eventArgs)
|
||||
{
|
||||
NodeTakeOut?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnStartNodeChanged(StartNodeChangeEventArgs eventArgs)
|
||||
{
|
||||
StartNodeChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnFlowRunComplete(FlowEventArgs eventArgs)
|
||||
{
|
||||
FlowRunComplete?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnMonitorObjectChanged(MonitorObjectEventArgs eventArgs)
|
||||
{
|
||||
MonitorObjectChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodeInterruptStateChanged(NodeInterruptStateChangeEventArgs eventArgs)
|
||||
{
|
||||
NodeInterruptStateChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnInterruptTriggered(InterruptTriggerEventArgs eventArgs)
|
||||
{
|
||||
InterruptTriggered?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnIOCMembersChanged(IOCMembersChangedEventArgs eventArgs)
|
||||
{
|
||||
IOCMembersChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnNodeLocated(NodeLocatedEventArgs eventArgs)
|
||||
{
|
||||
NodeLocated?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnEnvOutput(InfoType type, string value)
|
||||
{
|
||||
EnvOutput?.Invoke(type, value);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Serein.NodeFlow.Model.Nodes;
|
||||
using Serein.NodeFlow.Services;
|
||||
using Serein.NodeFlow.Tool;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace Serein.NodeFlow.Env
|
||||
@@ -64,7 +65,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// 打开远程管理
|
||||
/// </summary>
|
||||
/// <param name="port"></param>
|
||||
public async Task StartRemoteServerAsync(int port = 7525)
|
||||
public void StartRemoteServerAsync(int port = 7525)
|
||||
{
|
||||
/*if (clientMsgManage is null)
|
||||
{
|
||||
@@ -116,7 +117,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// UI线程操作类
|
||||
/// </summary>
|
||||
public UIContextOperation UIContextOperation { get; private set; }
|
||||
public UIContextOperation? UIContextOperation { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点MVVM管理服务
|
||||
@@ -173,15 +174,10 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
#region 私有变量
|
||||
|
||||
/// <summary>
|
||||
/// 装饰器运行环境类
|
||||
/// </summary>
|
||||
private readonly IFlowEnvironment mainFlowEnvironment;
|
||||
|
||||
/// <summary>
|
||||
/// 流程运行时的IOC容器
|
||||
/// </summary>
|
||||
private ISereinIOC flowRunIOC;
|
||||
private ISereinIOC? flowRunIOC;
|
||||
|
||||
/// <summary>
|
||||
/// local环境的IOC容器,主要用于注册本地环境的服务
|
||||
@@ -203,28 +199,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// </summary>
|
||||
private readonly FlowModelService _flowModelService;
|
||||
|
||||
/* /// <summary>
|
||||
/// 环境加载的节点集合
|
||||
/// Node Guid - Node Model
|
||||
/// </summary>
|
||||
private Dictionary<string, IFlowNode> NodeModels { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境加载的画布集合
|
||||
/// </summary>
|
||||
private Dictionary<string, FlowCanvasDetails> FlowCanvass { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 存放触发器节点(运行时全部调用)
|
||||
/// </summary>
|
||||
private List<SingleFlipflopNode> FlipflopNodes { get; } = [];
|
||||
*/
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务管理
|
||||
/// </summary>
|
||||
private FlowWorkManagement? flowTaskManagement;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -247,34 +222,15 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前环境信息(远程连接)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<FlowEnvInfo> GetEnvInfoAsync()
|
||||
{
|
||||
// 获取所有的程序集对应的方法信息(程序集相关的数据)
|
||||
var libraryMdss = this._flowLibraryService.GetAllLibraryMds().ToArray();
|
||||
// 获取当前项目的信息(节点相关的数据)
|
||||
var project = await GetProjectInfoAsync(); // 远程连接获取远程环境项目信息
|
||||
SereinEnv.WriteLine(InfoType.INFO, "已将当前环境信息发送到远程客户端");
|
||||
return new FlowEnvInfo
|
||||
{
|
||||
Project = project, // 项目信息
|
||||
LibraryMds = libraryMdss, // 环境方法
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存项目
|
||||
/// </summary>
|
||||
public void SaveProject()
|
||||
{
|
||||
var project = GetProjectInfoAsync();
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var project = await GetProjectInfoAsync();
|
||||
|
||||
await SereinEnv.TriggerEvent(() =>
|
||||
{
|
||||
Event.OnProjectSaving(new ProjectSavingEventArgs(project));
|
||||
@@ -316,27 +272,19 @@ namespace Serein.NodeFlow.Env
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
// 加载画布
|
||||
try
|
||||
foreach (var canvasInfo in projectData.Canvass)
|
||||
{
|
||||
foreach (var canvasInfo in projectData.Canvass)
|
||||
{
|
||||
await LoadCanvasAsync(canvasInfo);
|
||||
}
|
||||
var nodeInfos = projectData.Nodes.ToList();
|
||||
await FlowEdit.LoadNodeInfosAsync(nodeInfos); // 加载节点信息
|
||||
// 加载画布
|
||||
foreach (var canvasInfo in projectData.Canvass)
|
||||
{
|
||||
FlowEdit.SetStartNode(canvasInfo.Guid, canvasInfo.StartNode); // 设置起始节点
|
||||
}
|
||||
|
||||
Event.OnProjectLoaded(new ProjectLoadedEventArgs());
|
||||
await LoadCanvasAsync(canvasInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
var nodeInfos = projectData.Nodes.ToList();
|
||||
await FlowEdit.LoadNodeInfosAsync(nodeInfos); // 加载节点信息
|
||||
// 加载画布
|
||||
foreach (var canvasInfo in projectData.Canvass)
|
||||
{
|
||||
|
||||
throw;
|
||||
FlowEdit.SetStartNode(canvasInfo.Guid, canvasInfo.StartNode); // 设置起始节点
|
||||
}
|
||||
|
||||
Event.OnProjectLoaded(new ProjectLoadedEventArgs());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -382,56 +330,11 @@ namespace Serein.NodeFlow.Env
|
||||
Event.OnProjectLoaded(new ProjectLoadedEventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载远程环境
|
||||
/// </summary>
|
||||
/// <param name="addres">远程环境地址</param>
|
||||
/// <param name="port">远程环境端口</param>
|
||||
/// <param name="token">密码</param>
|
||||
/*public async Task<(bool, RemoteMsgUtil)> ConnectRemoteEnv(string addres, int port, string token)
|
||||
{
|
||||
throw new NotImplementedException("远程环境未实现的方法 ConnectRemoteEnv");
|
||||
*//*if (IsControlRemoteEnv)
|
||||
{
|
||||
await Console.Out.WriteLineAsync($"当前已经连接远程环境");
|
||||
return (false, null);
|
||||
}
|
||||
// 没有连接远程环境,可以重新连接
|
||||
|
||||
var controlConfiguration = new RemoteMsgUtil.ControlConfiguration
|
||||
{
|
||||
Addres = addres,
|
||||
Port = port,
|
||||
Token = token,
|
||||
*//*ThemeJsonKey = LocalFlowEnvironment.ThemeKey,
|
||||
MsgIdJsonKey = LocalFlowEnvironment.MsgIdKey,
|
||||
DataJsonKey = LocalFlowEnvironment.DataKey,*//*
|
||||
};
|
||||
var remoteMsgUtil = new RemoteMsgUtil(controlConfiguration);
|
||||
var result = await remoteMsgUtil.ConnectAsync();
|
||||
if (!result)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("连接失败,请检查地址与端口是否正确");
|
||||
return (false, null);
|
||||
}
|
||||
await Console.Out.WriteLineAsync("连接成功,开始验证Token");
|
||||
IsControlRemoteEnv = true;
|
||||
return (true, remoteMsgUtil);*//*
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// 退出远程环境
|
||||
/// </summary>
|
||||
public void ExitRemoteEnv()
|
||||
{
|
||||
IsControlRemoteEnv = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化当前项目的依赖信息、节点信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<SereinProjectData> GetProjectInfoAsync()
|
||||
public SereinProjectData GetProjectInfoAsync()
|
||||
{
|
||||
var projectData = new SereinProjectData()
|
||||
{
|
||||
@@ -466,28 +369,6 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
}
|
||||
|
||||
/* /// <summary>
|
||||
/// 加载本地程序集
|
||||
/// </summary>
|
||||
/// <param name="flowLibrary"></param>
|
||||
public void LoadLibrary(FlowLibraryCache flowLibrary)
|
||||
{
|
||||
try
|
||||
{
|
||||
libraryInfo = FlowLibraryService.LoadFlowLibrary(flowLibrary);
|
||||
if (mdInfos.Count > 0)
|
||||
{
|
||||
UIContextOperation?.Invoke(() => Event.OnDllLoad(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.ERROR, $"无法加载DLL文件:{ex.Message}");
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移除DLL
|
||||
/// </summary>
|
||||
@@ -572,9 +453,6 @@ namespace Serein.NodeFlow.Env
|
||||
//}
|
||||
}
|
||||
|
||||
private int _addCanvasCount = 0;
|
||||
|
||||
|
||||
private async Task<FlowCanvasDetails> LoadCanvasAsync(FlowCanvasDetailsInfo info)
|
||||
{
|
||||
var model = new FlowCanvasDetails(this);
|
||||
@@ -623,6 +501,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <para>异步方法:Func<object,object[],Task></para>
|
||||
/// <para>异步有返回值方法:Func<object,object[],Task<object>></para>
|
||||
/// </summary>
|
||||
/// <param name="assemblyName"></param>
|
||||
/// <param name="methodName"></param>
|
||||
/// <param name="delegateDetails"></param>
|
||||
/// <returns></returns>
|
||||
@@ -711,10 +590,11 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 从Guid获取画布
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <returns>节点Model</returns>
|
||||
/// <param name="nodeGuid">画布Guid</param>
|
||||
/// <param name="canvasDetails">画布实体</param>
|
||||
/// <returns>是否获取成功</returns>
|
||||
/// <exception cref="ArgumentNullException">无法获取节点、Guid/节点为null时报错</exception>
|
||||
public bool TryGetCanvasModel(string nodeGuid, out FlowCanvasDetails canvasDetails)
|
||||
public bool TryGetCanvasModel(string nodeGuid,[NotNullWhen(true)] out FlowCanvasDetails? canvasDetails)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nodeGuid))
|
||||
{
|
||||
@@ -729,9 +609,10 @@ namespace Serein.NodeFlow.Env
|
||||
/// 从Guid获取节点
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <param name="nodeModel">节点Guid</param>
|
||||
/// <returns>节点Model</returns>
|
||||
/// <exception cref="ArgumentNullException">无法获取节点、Guid/节点为null时报错</exception>
|
||||
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
||||
public bool TryGetNodeModel(string nodeGuid, [NotNullWhen(true)] out IFlowNode? nodeModel)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nodeGuid))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user