mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
refactor: 去掉流程实例的ActivityType,重构节点类型相关代码
This commit is contained in:
@@ -33,7 +33,6 @@ namespace OpenAuth.App.Flow
|
|||||||
InitNodes(schemeContentJson);
|
InitNodes(schemeContentJson);
|
||||||
|
|
||||||
currentNodeId = instance.ActivityId == "" ? startNodeId : instance.ActivityId;
|
currentNodeId = instance.ActivityId == "" ? startNodeId : instance.ActivityId;
|
||||||
currentNodeType = GetNodeType(currentNodeId);
|
|
||||||
FrmData = instance.FrmData;
|
FrmData = instance.FrmData;
|
||||||
title = schemeContentJson.title;
|
title = schemeContentJson.title;
|
||||||
initNum = schemeContentJson.initNum ?? 0;
|
initNum = schemeContentJson.initNum ?? 0;
|
||||||
@@ -41,15 +40,13 @@ namespace OpenAuth.App.Flow
|
|||||||
flowInstanceId = instance.Id;
|
flowInstanceId = instance.Id;
|
||||||
|
|
||||||
//会签开始节点和流程结束节点没有下一步
|
//会签开始节点和流程结束节点没有下一步
|
||||||
if (currentNodeType == 0 || currentNodeType == 4)
|
if (GetCurrentNodeType() == Define.NODE_TYPE_FORK || GetCurrentNodeType() == Define.NODE_TYPE_END)
|
||||||
{
|
{
|
||||||
nextNodeId = "-1";
|
nextNodeId = "-1";
|
||||||
nextNodeType = -1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nextNodeId = GetNextNodeId(); //下一个节点
|
nextNodeId = GetNextNodeId(); //下一个节点
|
||||||
nextNodeType = GetNodeType(nextNodeId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,14 +151,14 @@ namespace OpenAuth.App.Flow
|
|||||||
/// 获取实例接下来运行的状态
|
/// 获取实例接下来运行的状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束</returns>
|
/// <returns>-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束</returns>
|
||||||
public int GetNextNodeType()
|
public string GetNextNodeType()
|
||||||
{
|
{
|
||||||
if (nextNodeId != "-1")
|
if (nextNodeId != "-1")
|
||||||
{
|
{
|
||||||
return GetNodeType(nextNodeId);
|
return GetNodeType(nextNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -169,26 +166,18 @@ namespace OpenAuth.App.Flow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nodeId"></param>
|
/// <param name="nodeId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int GetNodeType(string nodeId)
|
public string GetNodeType(string nodeId)
|
||||||
{
|
{
|
||||||
switch (Nodes[nodeId].type)
|
return Nodes[nodeId].type;
|
||||||
{
|
}
|
||||||
//会签开始节点
|
|
||||||
case Define.NODE_TYPE_FORK:
|
|
||||||
return 0;
|
|
||||||
//会签结束节点
|
|
||||||
case Define.NODE_TYPE_JOIN:
|
|
||||||
return 1;
|
|
||||||
//结束节点
|
|
||||||
case Define.NODE_TYPE_END:
|
|
||||||
return 4;
|
|
||||||
//开始节点
|
|
||||||
case Define.NODE_TYPE_START:
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
default:
|
/// <summary>
|
||||||
return 2;
|
/// 获取当前节点类型
|
||||||
}
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetCurrentNodeType()
|
||||||
|
{
|
||||||
|
return GetNodeType(currentNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -305,12 +294,10 @@ namespace OpenAuth.App.Flow
|
|||||||
tag.Taged = (int)TagState.Ok;
|
tag.Taged = (int)TagState.Ok;
|
||||||
MakeTagNode(nextNode.id, tag);
|
MakeTagNode(nextNode.id, tag);
|
||||||
nextNodeId = res;
|
nextNodeId = res;
|
||||||
nextNodeType = GetNodeType(res);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nextNodeId = nextNode.id;
|
nextNodeId = nextNode.id;
|
||||||
nextNodeType = GetNodeType(nextNode.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(res)) //会签结束节点配置了回调,则发起通知
|
if (!string.IsNullOrEmpty(res)) //会签结束节点配置了回调,则发起通知
|
||||||
@@ -378,7 +365,6 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
flowInstance.ActivityId = rejectNode;
|
flowInstance.ActivityId = rejectNode;
|
||||||
flowInstance.ActivityType = GetNodeType(rejectNode);
|
|
||||||
flowInstance.ActivityName = Nodes[rejectNode].name;
|
flowInstance.ActivityName = Nodes[rejectNode].name;
|
||||||
flowInstance.MakerList =
|
flowInstance.MakerList =
|
||||||
GetNodeMarkers(Nodes[rejectNode], flowInstance.CreateUserId);
|
GetNodeMarkers(Nodes[rejectNode], flowInstance.CreateUserId);
|
||||||
@@ -409,7 +395,6 @@ namespace OpenAuth.App.Flow
|
|||||||
flowInstance.IsFinish = FlowInstanceStatus.Draft;
|
flowInstance.IsFinish = FlowInstanceStatus.Draft;
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
flowInstance.ActivityId = startNodeId;
|
flowInstance.ActivityId = startNodeId;
|
||||||
flowInstance.ActivityType = GetNodeType(startNodeId);
|
|
||||||
flowInstance.ActivityName = Nodes[startNodeId].name;
|
flowInstance.ActivityName = Nodes[startNodeId].name;
|
||||||
flowInstance.MakerList = GetNodeMarkers(Nodes[startNodeId], flowInstance.CreateUserId);
|
flowInstance.MakerList = GetNodeMarkers(Nodes[startNodeId], flowInstance.CreateUserId);
|
||||||
|
|
||||||
@@ -501,11 +486,11 @@ namespace OpenAuth.App.Flow
|
|||||||
CreateUserName = user.Name,
|
CreateUserName = user.Name,
|
||||||
FromNodeId = currentNodeId,
|
FromNodeId = currentNodeId,
|
||||||
FromNodeName = currentNode.name,
|
FromNodeName = currentNode.name,
|
||||||
FromNodeType = currentNodeType,
|
// FromNodeType = GetCurrentNodeType(),
|
||||||
ToNodeId = nextNodeId,
|
ToNodeId = nextNodeId,
|
||||||
ToNodeName = nextNode?.name,
|
ToNodeName = nextNode?.name,
|
||||||
ToNodeType = nextNodeType,
|
// ToNodeType = GetNextNodeType(),
|
||||||
IsFinish = nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
|
IsFinish = GetNextNodeType() == Define.NODE_TYPE_END ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
|
||||||
TransitionSate = 0
|
TransitionSate = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -576,7 +561,6 @@ namespace OpenAuth.App.Flow
|
|||||||
// 恢复到上一个节点
|
// 恢复到上一个节点
|
||||||
currentNodeId = flowInstance.PreviousId;
|
currentNodeId = flowInstance.PreviousId;
|
||||||
flowInstance.ActivityId = currentNodeId;
|
flowInstance.ActivityId = currentNodeId;
|
||||||
flowInstance.ActivityType = GetNodeType(currentNodeId);
|
|
||||||
flowInstance.ActivityName = Nodes[currentNodeId].name;
|
flowInstance.ActivityName = Nodes[currentNodeId].name;
|
||||||
//向前查找ActivityId的前一个结点,即连线指向ActivityId的节点
|
//向前查找ActivityId的前一个结点,即连线指向ActivityId的节点
|
||||||
flowInstance.PreviousId = GetPreNode().id;
|
flowInstance.PreviousId = GetPreNode().id;
|
||||||
@@ -624,7 +608,7 @@ namespace OpenAuth.App.Flow
|
|||||||
throw new Exception("无法寻找到下一个节点");
|
throw new Exception("无法寻找到下一个节点");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextNodeType == 0) //如果是会签节点
|
if (GetNextNodeType() == Define.NODE_TYPE_FORK) //如果是会签节点
|
||||||
{
|
{
|
||||||
makerList = GetForkNodeMakers(nextNodeId);
|
makerList = GetForkNodeMakers(nextNodeId);
|
||||||
}
|
}
|
||||||
@@ -908,12 +892,7 @@ namespace OpenAuth.App.Flow
|
|||||||
/// 到达节点的线段集合
|
/// 到达节点的线段集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<string, List<FlowLine>> ToNodeLines { get; set; }
|
private Dictionary<string, List<FlowLine>> ToNodeLines { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 当前节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
|
|
||||||
/// </summary>
|
|
||||||
private int currentNodeType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 表单数据
|
/// 表单数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -939,12 +918,6 @@ namespace OpenAuth.App.Flow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string nextNodeId { get; set; }
|
public string nextNodeId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 下一个节点类型 -1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The type of the next node.</value>
|
|
||||||
public int nextNodeType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下一个节点对象
|
/// 下一个节点对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -112,7 +112,6 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
#region 根据运行实例改变当前节点状态
|
#region 根据运行实例改变当前节点状态
|
||||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||||
flowInstance.ActivityType = wfruntime.GetNextNodeType();
|
|
||||||
flowInstance.ActivityName = wfruntime.nextNode.name;
|
flowInstance.ActivityName = wfruntime.nextNode.name;
|
||||||
flowInstance.PreviousId = wfruntime.currentNodeId;
|
flowInstance.PreviousId = wfruntime.currentNodeId;
|
||||||
flowInstance.CreateUserId = user.User.Id;
|
flowInstance.CreateUserId = user.User.Id;
|
||||||
@@ -121,8 +120,8 @@ namespace OpenAuth.App
|
|||||||
addFlowInstanceReq.CreateUserName = user.User.Account;
|
addFlowInstanceReq.CreateUserName = user.User.Account;
|
||||||
|
|
||||||
flowInstance.MakerList =
|
flowInstance.MakerList =
|
||||||
wfruntime.GetNextNodeType() != 4 ? wfruntime.GetNextMakers(addFlowInstanceReq) : "";
|
wfruntime.GetNextNodeType() != Define.NODE_TYPE_END ? wfruntime.GetNextMakers(addFlowInstanceReq) : "";
|
||||||
flowInstance.IsFinish = wfruntime.GetNextNodeType() == 4
|
flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END
|
||||||
? FlowInstanceStatus.Finished
|
? FlowInstanceStatus.Finished
|
||||||
: FlowInstanceStatus.Running;
|
: FlowInstanceStatus.Running;
|
||||||
|
|
||||||
@@ -329,7 +328,7 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
||||||
|
|
||||||
if (flowInstance.ActivityType == 0) //当前节点是会签节点
|
if (wfruntime.GetCurrentNodeType() == Define.NODE_TYPE_FORK) //当前节点是网关开始节点
|
||||||
{
|
{
|
||||||
CounterSign(wfruntime, tag, flowInstance);
|
CounterSign(wfruntime, tag, flowInstance);
|
||||||
}
|
}
|
||||||
@@ -403,13 +402,12 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||||
flowInstance.ActivityType = wfruntime.nextNodeType;
|
|
||||||
flowInstance.ActivityName = wfruntime.nextNode.name;
|
flowInstance.ActivityName = wfruntime.nextNode.name;
|
||||||
flowInstance.IsFinish = wfruntime.nextNodeType == 4
|
flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END
|
||||||
? FlowInstanceStatus.Finished
|
? FlowInstanceStatus.Finished
|
||||||
: FlowInstanceStatus.Running;
|
: FlowInstanceStatus.Running;
|
||||||
flowInstance.MakerList =
|
flowInstance.MakerList =
|
||||||
wfruntime.nextNodeType == 4 ? "" : wfruntime.GetNextMakers();
|
wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? "" : wfruntime.GetNextMakers();
|
||||||
|
|
||||||
wfruntime.SaveTransitionHis();
|
wfruntime.SaveTransitionHis();
|
||||||
}
|
}
|
||||||
@@ -503,10 +501,9 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||||
flowInstance.ActivityType = wfruntime.nextNodeType;
|
|
||||||
flowInstance.ActivityName = wfruntime.nextNode.name;
|
flowInstance.ActivityName = wfruntime.nextNode.name;
|
||||||
flowInstance.MakerList = wfruntime.nextNodeType == 4 ? "" : wfruntime.GetNextMakers(request);
|
flowInstance.MakerList = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? "" : wfruntime.GetNextMakers(request);
|
||||||
flowInstance.IsFinish = wfruntime.nextNodeType == 4
|
flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END
|
||||||
? FlowInstanceStatus.Finished
|
? FlowInstanceStatus.Finished
|
||||||
: FlowInstanceStatus.Running;
|
: FlowInstanceStatus.Running;
|
||||||
}
|
}
|
||||||
@@ -515,7 +512,6 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
flowInstance.IsFinish = FlowInstanceStatus.Disagree;
|
flowInstance.IsFinish = FlowInstanceStatus.Disagree;
|
||||||
wfruntime.nextNodeId = "-1";
|
wfruntime.nextNodeId = "-1";
|
||||||
wfruntime.nextNodeType = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var content =
|
var content =
|
||||||
@@ -641,7 +637,7 @@ namespace OpenAuth.App
|
|||||||
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runtime.nextNode != null && runtime.nextNode.setInfo != null && runtime.nextNodeType != 4)
|
if (runtime.nextNode != null && runtime.nextNode.setInfo != null && runtime.GetNextNodeType() != Define.NODE_TYPE_END)
|
||||||
{
|
{
|
||||||
resp.NextNodeDesignateType = runtime.nextNode.setInfo.NodeDesignate;
|
resp.NextNodeDesignateType = runtime.nextNode.setInfo.NodeDesignate;
|
||||||
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds;
|
||||||
@@ -869,13 +865,12 @@ namespace OpenAuth.App
|
|||||||
#region 根据运行实例改变当前节点状态
|
#region 根据运行实例改变当前节点状态
|
||||||
|
|
||||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||||
flowInstance.ActivityType = wfruntime.GetNextNodeType();
|
|
||||||
flowInstance.ActivityName = wfruntime.nextNode.name;
|
flowInstance.ActivityName = wfruntime.nextNode.name;
|
||||||
flowInstance.PreviousId = wfruntime.currentNodeId;
|
flowInstance.PreviousId = wfruntime.currentNodeId;
|
||||||
flowInstance.CreateUserId = user.User.Id;
|
flowInstance.CreateUserId = user.User.Id;
|
||||||
flowInstance.CreateUserName = user.User.Account;
|
flowInstance.CreateUserName = user.User.Account;
|
||||||
flowInstance.MakerList = wfruntime.GetNextNodeType() != 4 ? wfruntime.GetNextMakers() : "";
|
flowInstance.MakerList = wfruntime.GetNextNodeType() != Define.NODE_TYPE_END ? wfruntime.GetNextMakers() : "";
|
||||||
flowInstance.IsFinish = wfruntime.GetNextNodeType() == 4
|
flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END
|
||||||
? FlowInstanceStatus.Finished
|
? FlowInstanceStatus.Finished
|
||||||
: FlowInstanceStatus.Running;
|
: FlowInstanceStatus.Running;
|
||||||
|
|
||||||
|
@@ -70,11 +70,6 @@ namespace OpenAuth.Repository.Domain
|
|||||||
[Description("当前节点ID")]
|
[Description("当前节点ID")]
|
||||||
public string ActivityId { get; set; }
|
public string ActivityId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前节点类型(0会签节点)
|
|
||||||
/// </summary>
|
|
||||||
[Description("当前节点类型(0会签节点)")]
|
|
||||||
public int? ActivityType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 当前节点名称
|
/// 当前节点名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("当前节点名称")]
|
[Description("当前节点名称")]
|
||||||
|
@@ -50,7 +50,7 @@ namespace OpenAuth.Repository.Domain
|
|||||||
/// 开始节点类型
|
/// 开始节点类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("开始节点类型")]
|
[Description("开始节点类型")]
|
||||||
public int? FromNodeType { get; set; }
|
public string FromNodeType { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始节点名称
|
/// 开始节点名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -65,7 +65,7 @@ namespace OpenAuth.Repository.Domain
|
|||||||
/// 结束节点类型
|
/// 结束节点类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("结束节点类型")]
|
[Description("结束节点类型")]
|
||||||
public int? ToNodeType { get; set; }
|
public string ToNodeType { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 结束节点名称
|
/// 结束节点名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Reference in New Issue
Block a user