mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-05 01:00:48 +08:00
LocalFlowEnvironment文件丢失,需要重写
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Model.Operation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 将调用顺序置为优先
|
||||
/// </summary>
|
||||
internal class SetConnectPriorityInvokeOperation : OperationBase
|
||||
{
|
||||
public override string Theme => nameof(SetConnectPriorityInvokeOperation);
|
||||
|
||||
public string FromNodeGuid { get; set; }
|
||||
public string ToNodeGuid { get; set; }
|
||||
public ConnectionInvokeType ConnectionType { get; set; }
|
||||
|
||||
private IFlowNode FromNode;
|
||||
private IFlowNode ToNode;
|
||||
private int lastIdx = -1;
|
||||
|
||||
public override bool ValidationParameter()
|
||||
{
|
||||
if (ConnectionType == ConnectionInvokeType.None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// 获取起始节点与目标节点
|
||||
if (!flowModelService.TryGetNodeModel(FromNodeGuid, out var fromNode) || !flowModelService.TryGetNodeModel(ToNodeGuid, out var toNode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (fromNode is null || toNode is null) return false;
|
||||
|
||||
FromNode = fromNode;
|
||||
ToNode = toNode;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成为首项
|
||||
/// </summary>
|
||||
public override bool Execute()
|
||||
{
|
||||
if(!ValidationParameter()) return false;
|
||||
|
||||
if (FromNode.SuccessorNodes.TryGetValue(ConnectionType, out var nodes))
|
||||
{
|
||||
var idx = nodes.IndexOf(ToNode);
|
||||
if (idx > -1)
|
||||
{
|
||||
lastIdx = idx;
|
||||
nodes.RemoveAt(idx);
|
||||
nodes.Insert(0, ToNode);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复原来的位置
|
||||
/// </summary>
|
||||
public override bool Undo()
|
||||
{
|
||||
if (FromNode.SuccessorNodes.TryGetValue(ConnectionType, out var nodes))
|
||||
{
|
||||
var idx = nodes.IndexOf(ToNode);
|
||||
if (idx > -1)
|
||||
{
|
||||
nodes.RemoveAt(idx);
|
||||
nodes.Insert(lastIdx, ToNode);
|
||||
lastIdx = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ToInfo()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user