2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.Library.Entity;
|
|
|
|
|
|
using Serein.Library.Enums;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Serein.Library.Api
|
|
|
|
|
|
{
|
2024-09-16 21:38:34 +08:00
|
|
|
|
#region 环境委托
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 流程运行完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="eventArgs"></param>
|
|
|
|
|
|
public delegate void FlowRunCompleteHandler(FlowEventArgs eventArgs);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
2024-09-17 14:20:27 +08:00
|
|
|
|
/// 项目加载完成
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// </summary>
|
2024-09-17 14:20:27 +08:00
|
|
|
|
public delegate void ProjectLoadedHandler(ProjectLoadedEventArgs eventArgs);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载项目文件时成功加载了DLL文件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public delegate void LoadDLLHandler(LoadDLLEventArgs eventArgs);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 运行环境节点连接发生了改变
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fromNodeGuid"></param>
|
|
|
|
|
|
/// <param name="toNodeGuid"></param>
|
|
|
|
|
|
/// <param name="connectionType"></param>
|
|
|
|
|
|
public delegate void NodeConnectChangeHandler(NodeConnectChangeEventArgs eventArgs);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 环境中加载了一个节点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fromNodeGuid"></param>
|
|
|
|
|
|
/// <param name="toNodeGuid"></param>
|
|
|
|
|
|
/// <param name="connectionType"></param>
|
|
|
|
|
|
public delegate void NodeCreateHandler(NodeCreateEventArgs eventArgs);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 环境中流程起始节点发生了改变
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="eventArgs"></param>
|
|
|
|
|
|
public delegate void StartNodeChangeHandler(StartNodeChangeEventArgs eventArgs);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 环境事件签名
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// 流程事件签名基类
|
2024-09-15 12:15:32 +08:00
|
|
|
|
/// </summary>
|
2024-09-16 21:38:34 +08:00
|
|
|
|
public class FlowEventArgs : EventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsSucceed { get; protected set; } = true;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 错误提示
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string ErrorTips { get; protected set; } = string.Empty;
|
|
|
|
|
|
}
|
2024-09-17 14:20:27 +08:00
|
|
|
|
|
|
|
|
|
|
//public class LoadNodeEventArgs : FlowEventArgs
|
|
|
|
|
|
//{
|
|
|
|
|
|
// public LoadNodeEventArgs(NodeInfo NodeInfo, MethodDetails MethodDetailss)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// this.NodeInfo = NodeInfo;
|
|
|
|
|
|
// this.MethodDetailss = MethodDetailss;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// /// <summary>
|
|
|
|
|
|
// /// 项目文件节点信息参数
|
|
|
|
|
|
// /// </summary>
|
|
|
|
|
|
// public NodeInfo NodeInfo { get; protected set; }
|
|
|
|
|
|
// /// <summary>
|
|
|
|
|
|
// /// 已加载在环境中的方法描述
|
|
|
|
|
|
// /// </summary>
|
|
|
|
|
|
// public MethodDetails MethodDetailss { get; protected set; }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public class ProjectLoadedEventArgs : FlowEventArgs
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2024-09-17 14:20:27 +08:00
|
|
|
|
public ProjectLoadedEventArgs()
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LoadDLLEventArgs : FlowEventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
public LoadDLLEventArgs(Assembly Assembly, List<MethodDetails> MethodDetailss)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Assembly = Assembly;
|
|
|
|
|
|
this.MethodDetailss = MethodDetailss;
|
|
|
|
|
|
}
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 已加载了的程序集
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public Assembly Assembly { get; protected set; }
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// dll文件中有效的流程方法描述
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public List<MethodDetails> MethodDetailss { get; protected set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public class NodeConnectChangeEventArgs : FlowEventArgs
|
|
|
|
|
|
{
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 连接关系改变类型
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum ConnectChangeType
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
Create,
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 移除
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
Remote,
|
|
|
|
|
|
}
|
2024-09-16 21:38:34 +08:00
|
|
|
|
public NodeConnectChangeEventArgs(string fromNodeGuid, string toNodeGuid, ConnectionType connectionType, ConnectChangeType changeType)
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.FromNodeGuid = fromNodeGuid;
|
|
|
|
|
|
this.ToNodeGuid = toNodeGuid;
|
|
|
|
|
|
this.ConnectionType = connectionType;
|
|
|
|
|
|
this.ChangeType = changeType;
|
|
|
|
|
|
}
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 连接关系中始节点的Guid
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public string FromNodeGuid { get; protected set; }
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 连接关系中目标节点的Guid
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public string ToNodeGuid { get; protected set; }
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 连接类型
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public ConnectionType ConnectionType { get; protected set; }
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示此次需要在两个节点之间创建连接关系,或是移除连接关系
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ConnectChangeType ChangeType { get; protected set; }
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public class NodeCreateEventArgs : FlowEventArgs
|
|
|
|
|
|
{
|
2024-09-17 14:20:27 +08:00
|
|
|
|
public NodeCreateEventArgs(object nodeModel, Position position)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.NodeModel = nodeModel;
|
|
|
|
|
|
this.Position = position;
|
|
|
|
|
|
}
|
|
|
|
|
|
public NodeCreateEventArgs(object nodeModel, bool isAddInRegion, string regeionGuid)
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.NodeModel = nodeModel;
|
2024-09-17 14:20:27 +08:00
|
|
|
|
this.RegeionGuid = regeionGuid;
|
|
|
|
|
|
this.IsAddInRegion = isAddInRegion;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
2024-09-17 14:20:27 +08:00
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 节点Model对象,目前需要手动转换对应的类型
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public object NodeModel { get; private set; }
|
2024-09-17 14:20:27 +08:00
|
|
|
|
public Position Position { get; private set; }
|
|
|
|
|
|
public bool IsAddInRegion { get; private set; }
|
|
|
|
|
|
public string RegeionGuid { get; private set; }
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 环境中移除了一个节点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="eventArgs"></param>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
public delegate void NodeRemoteHandler(NodeRemoteEventArgs eventArgs);
|
|
|
|
|
|
public class NodeRemoteEventArgs : FlowEventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
public NodeRemoteEventArgs(string nodeGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.NodeGuid = nodeGuid;
|
|
|
|
|
|
}
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 被移除节点的Guid
|
|
|
|
|
|
/// </summary>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public string NodeGuid { get; private set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-16 21:38:34 +08:00
|
|
|
|
public class StartNodeChangeEventArgs : FlowEventArgs
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
public StartNodeChangeEventArgs(string oldNodeGuid, string newNodeGuid)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.OldNodeGuid = oldNodeGuid;
|
|
|
|
|
|
this.NewNodeGuid = newNodeGuid; ;
|
|
|
|
|
|
}
|
2024-09-16 21:38:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 原来的起始节点Guid
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string OldNodeGuid { get; private set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新的起始节点Guid
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string NewNodeGuid { get; private set; }
|
2024-09-17 14:20:27 +08:00
|
|
|
|
}
|
2024-09-16 21:38:34 +08:00
|
|
|
|
#endregion
|
2024-09-15 12:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
public interface IFlowEnvironment
|
|
|
|
|
|
{
|
2024-09-17 14:20:27 +08:00
|
|
|
|
|
2024-09-15 12:15:32 +08:00
|
|
|
|
event FlowRunCompleteHandler OnFlowRunComplete;
|
2024-09-17 14:20:27 +08:00
|
|
|
|
event ProjectLoadedHandler OnProjectLoaded;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
event LoadDLLHandler OnDllLoad;
|
|
|
|
|
|
event NodeConnectChangeHandler OnNodeConnectChange;
|
|
|
|
|
|
event NodeCreateHandler OnNodeCreate;
|
|
|
|
|
|
event NodeRemoteHandler OnNodeRemote;
|
|
|
|
|
|
event StartNodeChangeHandler OnStartNodeChange;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存当前项目
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2024-09-17 14:20:27 +08:00
|
|
|
|
SereinProjectData SaveProject();
|
2024-09-15 12:15:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载项目文件
|
|
|
|
|
|
/// </summary>
|
2024-09-17 15:58:37 +08:00
|
|
|
|
/// <param name="projectFile"></param>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
/// <param name="filePath"></param>
|
2024-09-17 15:58:37 +08:00
|
|
|
|
void LoadProject(SereinProjectData projectFile, string filePath);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从文件中加载Dll
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dllPath"></param>
|
|
|
|
|
|
void LoadDll(string dllPath);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清理加载的DLL(待更改)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void ClearAll();
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取方法描述
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <param name="md"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
bool TryGetMethodDetails(string methodName,out MethodDetails md);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开始运行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Task StartAsync();
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 结束运行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void Exit();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置流程起点节点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="nodeGuid"></param>
|
|
|
|
|
|
void SetStartNode(string nodeGuid);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在两个节点之间创建连接关系
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fromNodeGuid">起始节点Guid</param>
|
|
|
|
|
|
/// <param name="toNodeGuid">目标节点Guid</param>
|
|
|
|
|
|
/// <param name="connectionType">连接类型</param>
|
|
|
|
|
|
void ConnectNode(string fromNodeGuid, string toNodeGuid, ConnectionType connectionType);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建节点/区域/基础控件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="nodeBase">节点/区域/基础控件</param>
|
|
|
|
|
|
/// <param name="methodDetails">节点绑定的方法说明(</param>
|
2024-09-17 14:20:27 +08:00
|
|
|
|
void CreateNode(NodeControlType nodeBase, Position position, MethodDetails methodDetails = null);
|
2024-09-15 12:15:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 移除两个节点之间的连接关系
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fromNodeGuid">起始节点</param>
|
|
|
|
|
|
/// <param name="toNodeGuid">目标节点</param>
|
|
|
|
|
|
/// <param name="connectionType">连接类型</param>
|
|
|
|
|
|
void RemoteConnect(string fromNodeGuid, string toNodeGuid, ConnectionType connectionType);
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 移除节点/区域/基础控件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="nodeGuid">待移除的节点Guid</param>
|
|
|
|
|
|
void RemoteNode(string nodeGuid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|