routine update

This commit is contained in:
yubaolee 2018-03-21 17:36:31 +08:00
parent 33f02fdeec
commit 9edd6930b4
9 changed files with 201 additions and 496 deletions

View File

@ -1,11 +1,8 @@
using System; namespace OpenAuth.App.Flow
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.Flow
{ {
/// <summary>
/// 流程连线
/// </summary>
public class FlowLine public class FlowLine
{ {
public string id { get; set; } public string id { get; set; }

View File

@ -1,11 +1,8 @@
using System; namespace OpenAuth.App.Flow
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.Flow
{ {
/// <summary>
/// 流程节点
/// </summary>
public class FlowNode public class FlowNode
{ {
public const string START = "start round mix"; public const string START = "start round mix";
@ -18,6 +15,30 @@ namespace OpenAuth.App.Flow
public string type { get; set; } public string type { get; set; }
/// <summary>
/// 节点的附加数据项
/// </summary>
/// <value>The set information.</value>
public Setinfo setInfo { get; set; }
} }
public class Setinfo
{
public Nodedesignatedata NodeDesignateData { get; set; }
public string NodeCode { get; set; }
public string NodeName { get; set; }
}
/// <summary>
/// 节点执行人
/// </summary>
public class Nodedesignatedata
{
public string[] users { get; set; }
public string[] role { get; set; }
public string[] org { get; set; }
}
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Infrastructure; using Infrastructure;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App.Flow namespace OpenAuth.App.Flow
{ {
@ -11,22 +12,20 @@ namespace OpenAuth.App.Flow
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="schemeContent">流程模板</param>
/// <param name="currentNodeId">当前节点</param> /// <param name="currentNodeId">当前节点</param>
/// <param name="frmData">表单数据</param> /// <param name="frmData">表单数据</param>
public FlowRuntime(FlowRuntimeInitModel flowRuntimeInitModel) /// <param name="instance"></param>
public FlowRuntime(FlowInstance instance)
{ {
_runtimeModel = new FlowRuntimeModel(); _runtimeModel = new FlowRuntimeModel();
dynamic schemeContentJson = flowRuntimeInitModel.schemeContent.ToJson();//获取工作流模板内容的json对象; dynamic schemeContentJson = instance.SchemeContent.ToJson();//获取工作流模板内容的json对象;
_runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象 _runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象
_runtimeModel.nodeDictionary = GetNodeDictionary(schemeContentJson);//节点集合 _runtimeModel.nodes = GetNodeDictionary(schemeContentJson);//节点集合
_runtimeModel.lineDictionary = GetLineDictionary(schemeContentJson);//线条集合 _runtimeModel.lines = GetLineDictionary(schemeContentJson);//线条集合
_runtimeModel.currentNodeId = (flowRuntimeInitModel.currentNodeId == "" ? _runtimeModel.startNodeId : flowRuntimeInitModel.currentNodeId); _runtimeModel.currentNodeId = (instance.ActivityId == "" ? _runtimeModel.startNodeId : instance.ActivityId);
_runtimeModel.currentNodeType = GetNodeStatus(_runtimeModel.currentNodeId); _runtimeModel.currentNodeType = GetNodeType(_runtimeModel.currentNodeId);
_runtimeModel.frmData = flowRuntimeInitModel.frmData; //todo:要获取表单数据
// _runtimeModel.frmData = flowRuntimeInitModel.frmData;
// flowRuntimeInitModel.frmData = GetNodeFrmData(getFrmData);
if (_runtimeModel.currentNodeType == 0 || _runtimeModel.currentNodeType == 4) if (_runtimeModel.currentNodeType == 0 || _runtimeModel.currentNodeType == 4)
{ {
@ -35,13 +34,12 @@ namespace OpenAuth.App.Flow
} }
else else
{ {
_runtimeModel.nextNodeId = GetNextNode(flowRuntimeInitModel.frmData);//下一个节点 _runtimeModel.nextNodeId = GetNextNode(_runtimeModel.frmData);//下一个节点
_runtimeModel.nextNodeType = GetNodeStatus(_runtimeModel.nextNodeId); _runtimeModel.nextNodeType = GetNodeType(_runtimeModel.nextNodeId);
} }
_runtimeModel.previousId = flowRuntimeInitModel.previousId; _runtimeModel.previousId = instance.PreviousId;
_runtimeModel.flowInstanceId = instance.Id;
_runtimeModel.flowInstanceId = flowRuntimeInitModel.processId.ToString();
} }
@ -51,16 +49,16 @@ namespace OpenAuth.App.Flow
/// </summary> /// </summary>
/// <param name="schemeContentJson"></param> /// <param name="schemeContentJson"></param>
/// <returns></returns> /// <returns></returns>
private Dictionary<string, dynamic> GetNodeDictionary(dynamic schemeContentJson) private Dictionary<string, FlowNode> GetNodeDictionary(dynamic schemeContentJson)
{ {
Dictionary<string, dynamic> nodeDictionary = new Dictionary<string, dynamic>(); Dictionary<string, FlowNode> nodeDictionary = new Dictionary<string, FlowNode>();
foreach (var item in schemeContentJson.Flow.nodes) foreach (var item in schemeContentJson.Flow.nodes)
{ {
if (!nodeDictionary.ContainsKey(item.id.Value)) if (!nodeDictionary.ContainsKey(item.id.Value))
{ {
nodeDictionary.Add(item.id.Value, item); nodeDictionary.Add(item.id.Value, item);
} }
if (item.type == "startround") if (item.type == FlowNode.START)
{ {
this._runtimeModel.startNodeId = item.id.Value; this._runtimeModel.startNodeId = item.id.Value;
} }
@ -72,15 +70,14 @@ namespace OpenAuth.App.Flow
/// </summary> /// </summary>
/// <param name="schemeContentJson"></param> /// <param name="schemeContentJson"></param>
/// <returns></returns> /// <returns></returns>
private Dictionary<string, List<dynamic>> GetLineDictionary(dynamic schemeContentJson) private Dictionary<string, List<FlowLine>> GetLineDictionary(dynamic schemeContentJson)
{ {
Dictionary<string, List<dynamic>> lineDictionary = new Dictionary<string, List<dynamic>>(); Dictionary<string, List<FlowLine>> lineDictionary = new Dictionary<string, List<FlowLine>>();
foreach (var item in schemeContentJson.Flow.lines) foreach (var item in schemeContentJson.Flow.lines)
{ {
if (!lineDictionary.ContainsKey(item.from.Value)) if (!lineDictionary.ContainsKey(item.from.Value))
{ {
List<dynamic> d = new List<dynamic>(); List<FlowLine> d = new List<FlowLine> { item };
d.Add(item);
lineDictionary.Add(item.from.Value, d); lineDictionary.Add(item.from.Value, d);
} }
else else
@ -95,15 +92,14 @@ namespace OpenAuth.App.Flow
/// </summary> /// </summary>
/// <param name="schemeContentJson"></param> /// <param name="schemeContentJson"></param>
/// <returns></returns> /// <returns></returns>
private Dictionary<string, List<dynamic>> GetToLineDictionary(dynamic schemeContentJson) private Dictionary<string, List<FlowLine>> GetToLineDictionary(dynamic schemeContentJson)
{ {
Dictionary<string, List<dynamic>> lineDictionary = new Dictionary<string, List<dynamic>>(); Dictionary<string, List<FlowLine>> lineDictionary = new Dictionary<string, List<FlowLine>>();
foreach (var item in schemeContentJson.Flow.lines) foreach (var item in schemeContentJson.Flow.lines)
{ {
if (!lineDictionary.ContainsKey(item.to.Value)) if (!lineDictionary.ContainsKey(item.to.Value))
{ {
List<dynamic> d = new List<dynamic>(); List<FlowLine> d = new List<FlowLine> { item };
d.Add(item);
lineDictionary.Add(item.to.Value, d); lineDictionary.Add(item.to.Value, d);
} }
else else
@ -113,82 +109,6 @@ namespace OpenAuth.App.Flow
} }
return lineDictionary; return lineDictionary;
} }
/// <summary>
/// 工作流流转条件比较函数
/// </summary>
/// <param name="frmvalue">表单数据</param>
/// <param name="operation"></param>
/// <param name="paramValue"></param>
/// <returns></returns>
private bool LineCompared(string frmvalue, string operation, string paramValue)
{
bool res = false;
switch (operation)
{
case "Equal"://等于
if (decimal.Parse(frmvalue) == decimal.Parse(paramValue))
{
res = true;
}
break;
case "NotEqual"://不等于
if (decimal.Parse(frmvalue) != decimal.Parse(paramValue))
{
res = true;
}
break;
case "Greater"://大于
if (decimal.Parse(frmvalue) > decimal.Parse(paramValue))
{
res = true;
}
break;
case "GreaterThan"://大于等于
if (decimal.Parse(frmvalue) >= decimal.Parse(paramValue))
{
res = true;
}
break;
case "Less"://小于
if (decimal.Parse(frmvalue) < decimal.Parse(paramValue))
{
res = true;
}
break;
case "LessThan"://小于等于
if (decimal.Parse(frmvalue) <= decimal.Parse(paramValue))
{
res = true;
}
break;
case "Null"://为空
if (string.IsNullOrEmpty(frmvalue))
{
res = true;
}
break;
case "NotNull"://不为空
if (!string.IsNullOrEmpty(frmvalue))
{
res = true;
}
break;
case "Like"://包含
if (frmvalue.IndexOf(paramValue) != -1)
{
res = true;
}
break;
case "NotLike"://不包含
if (frmvalue.IndexOf(paramValue) == -1)
{
res = true;
}
break;
}
return res;
}
/// <summary> /// <summary>
/// 获取下一个节点 /// 获取下一个节点
@ -196,71 +116,36 @@ namespace OpenAuth.App.Flow
/// <param name="frmData">表单数据(用于判断流转条件)</param> /// <param name="frmData">表单数据(用于判断流转条件)</param>
private string GetNextNode(string frmData, string nodeId = null) private string GetNextNode(string frmData, string nodeId = null)
{ {
try List<FlowLine> LineList = null;
{
List<dynamic> LineList = null;
if (nodeId == null) if (nodeId == null)
{ {
LineList = runtimeModel.lineDictionary[runtimeModel.currentNodeId]; LineList = runtimeModel.lines[runtimeModel.currentNodeId];
} }
else else
{ {
LineList = runtimeModel.lineDictionary[nodeId]; LineList = runtimeModel.lines[nodeId];
} }
if (LineList.Count == 1) if (LineList.Count == 1) //只有一条流程
{ {
return LineList[0].to.Value; return LineList[0].to;
} }
else if (frmData != "")
if (frmData != "") //有分支的情况
{ {
frmData = frmData.ToLower();//统一转小写 frmData = frmData.ToLower();//统一转小写
var frmDataJson = frmData.ToJObject();//获取数据内容 var frmDataJson = frmData.ToJObject();//获取数据内容
bool flag = false; bool flag = false;
foreach (var item in LineList)//轮训该节点所有连接的线路 foreach (var item in LineList)//轮训该节点所有连接的线路
{ {
if (item.setInfo == null)//表示该线路没有设置条件,所以流转到下一个节点
{
return item.to.Value;
}
foreach (var _item in item.setInfo.ConditionValueJson)//轮询该线条上的所有条件
{
if (!string.IsNullOrEmpty(frmDataJson[_item.ParamName.Value.ToLower()].Value))
{
string frmvalue = frmDataJson[_item.ParamName.Value.ToLower()].ToString();
string operation = _item.Operation.Value;
string paramValue = _item.ParamValue.Value;
bool compareValue = LineCompared(frmvalue, operation, paramValue);
if (_item.Operation.Value == "AND") return item.to;
{
flag = compareValue;
if (!compareValue)
{
break;
}
}
else
{
if (compareValue)
{
flag = compareValue;
}
}
}
}
if (flag)//如果满足条件,
{
return item.to.Value;
}
} }
} }
return "-1";//表示寻找不到节点 return "-1";//表示寻找不到节点
} }
catch
{
throw;
}
}
#endregion #endregion
#region API #region API
@ -276,52 +161,35 @@ namespace OpenAuth.App.Flow
/// 获取实例接下来运行的状态 /// 获取实例接下来运行的状态
/// </summary> /// </summary>
/// <returns>-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束</returns> /// <returns>-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束</returns>
public int GetStatus() public int GetNextNodeType()
{ {
if (_runtimeModel.nextNodeId != "-1") if (_runtimeModel.nextNodeId != "-1")
{ {
if (_runtimeModel.nextNode.type == "shuntnode")//会签开始节点 return GetNodeType(_runtimeModel.nextNodeId);
{
return 0;
} }
else if (_runtimeModel.nextNode.type == "confluencenode")//会签结束节点
{
return 1;
}
else if (_runtimeModel.nextNode.type == "endround")//结束节点
{
return 4;
}
else
{
return 2;
}
}
else
{
return -1; return -1;
} }
}
/// <summary> /// <summary>
/// 获取节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束 /// 获取节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
/// </summary> /// </summary>
/// <param name="nodeId"></param> /// <param name="nodeId"></param>
/// <returns></returns> /// <returns></returns>
public int GetNodeStatus(string nodeId) public int GetNodeType(string nodeId)
{ {
if (_runtimeModel.nodeDictionary[nodeId].type == "shuntnode")//会签开始节点 if (_runtimeModel.nodes[nodeId].type == "shuntnode")//会签开始节点
{ {
return 0; return 0;
} }
else if (_runtimeModel.nodeDictionary[nodeId].type == "confluencenode")//会签结束节点 else if (_runtimeModel.nodes[nodeId].type == "confluencenode")//会签结束节点
{ {
return 1; return 1;
} }
else if (_runtimeModel.nodeDictionary[nodeId].type == "endround")//结束节点 else if (_runtimeModel.nodes[nodeId].type == FlowNode.END)//结束节点
{ {
return 4; return 4;
} }
else if (_runtimeModel.nodeDictionary[nodeId].type == "startround")//开始节点 else if (_runtimeModel.nodes[nodeId].type == FlowNode.START)//开始节点
{ {
return 3; return 3;
} }
@ -336,33 +204,24 @@ namespace OpenAuth.App.Flow
/// <param name="shuntnodeId"></param> /// <param name="shuntnodeId"></param>
/// <returns></returns> /// <returns></returns>
public List<string> GetCountersigningNodeIdList(string shuntnodeId) public List<string> GetCountersigningNodeIdList(string shuntnodeId)
{
try
{ {
List<string> list = new List<string>(); List<string> list = new List<string>();
List<dynamic> listline = _runtimeModel.lineDictionary[shuntnodeId]; List<FlowLine> listline = _runtimeModel.lines[shuntnodeId];
foreach (var item in listline) foreach (var item in listline)
{ {
list.Add(item.to.Value); list.Add(item.to);
} }
return list; return list;
} }
catch
{
throw;
}
}
/// <summary> /// <summary>
/// 通过节点Id获取下一个节点Id /// 通过节点Id获取下一个节点Id
/// </summary> /// </summary>
/// <param name="nodeId"></param> /// <param name="nodeId"></param>
/// <returns></returns> /// <returns></returns>
public string GetNextNodeByNodeId(string nodeId) public string GetNextNodeByNodeId(string nodeId)
{
try
{ {
string frmData = ""; string frmData = "";
@ -370,11 +229,6 @@ namespace OpenAuth.App.Flow
return GetNextNode(frmData, nodeId); return GetNextNode(frmData, nodeId);
} }
catch
{
throw;
}
}
/// <summary> /// <summary>
/// 节点会签审核 /// 节点会签审核
/// </summary> /// </summary>
@ -398,7 +252,7 @@ namespace OpenAuth.App.Flow
string _nextNodeId = GetNextNodeByNodeId(nodeId);//获取下一个节点 string _nextNodeId = GetNextNodeByNodeId(nodeId);//获取下一个节点
if (_nextNodeId != "-1") if (_nextNodeId != "-1")
{ {
Dictionary<string, List<dynamic>> toLines = GetToLineDictionary(_runtimeModel.schemeContentJson); Dictionary<string, List<FlowLine>> toLines = GetToLineDictionary(_runtimeModel.schemeContentJson);
int allnum = toLines[_nextNodeId].Count; int allnum = toLines[_nextNodeId].Count;
int i = 0; int i = 0;
foreach (var item in _runtimeModel.schemeContentJson.Flow.nodes) foreach (var item in _runtimeModel.schemeContentJson.Flow.nodes)
@ -510,12 +364,12 @@ namespace OpenAuth.App.Flow
{ {
MakeTagNode(_nextNodeId, 1, userId); MakeTagNode(_nextNodeId, 1, userId);
_runtimeModel.nextNodeId = res; _runtimeModel.nextNodeId = res;
_runtimeModel.nextNodeType = GetNodeStatus(res); _runtimeModel.nextNodeType = GetNodeType(res);
} }
else else
{ {
_runtimeModel.nextNodeId = _nextNodeId; _runtimeModel.nextNodeId = _nextNodeId;
_runtimeModel.nextNodeType = GetNodeStatus(_nextNodeId); _runtimeModel.nextNodeType = GetNodeType(_nextNodeId);
} }
return res; return res;
} }
@ -546,7 +400,7 @@ namespace OpenAuth.App.Flow
{ {
try try
{ {
dynamic _node = _runtimeModel.nodeDictionary[nodeId]; dynamic _node = _runtimeModel.nodes[nodeId];
if (_node.setInfo != null) if (_node.setInfo != null)
{ {
if (_node.setInfo.NodeRejectType.Value == "0") if (_node.setInfo.NodeRejectType.Value == "0")

View File

@ -1,27 +0,0 @@
namespace OpenAuth.App.Flow
{
public class FlowRuntimeInitModel
{
/// <summary>
/// GUID
/// </summary>
public string processId { get; set; }
/// <summary>
/// 工作流模板内容
/// </summary>
public string schemeContent { get; set; }
/// <summary>
/// 当前运行节点(默认开始节点)
/// </summary>
public string currentNodeId { get; set; }
/// <summary>
/// 提交的表单数据
/// </summary>
public string frmData { get; set; }
/// <summary>
/// 上一个节点
/// </summary>
public string previousId { get; set; }
}
}

View File

@ -24,7 +24,7 @@ namespace OpenAuth.App.Flow
/// <summary> /// <summary>
/// 当前节点的对象 /// 当前节点的对象
/// </summary> /// </summary>
public dynamic currentNode { get { return this.nodeDictionary[this.currentNodeId]; } } public dynamic currentNode { get { return nodes[currentNodeId]; } }
/// <summary> /// <summary>
/// 下一个节点 /// 下一个节点
/// </summary> /// </summary>
@ -32,11 +32,12 @@ namespace OpenAuth.App.Flow
/// <summary> /// <summary>
/// 下一个节点类型 /// 下一个节点类型
/// </summary> /// </summary>
/// <value>The type of the next node.</value>
public int nextNodeType { get; set; } public int nextNodeType { get; set; }
/// <summary> /// <summary>
/// 下一个节点对象 /// 下一个节点对象
/// </summary> /// </summary>
public FlowNode nextNode { get { return nodeDictionary[this.nextNodeId]; } } public FlowNode nextNode { get { return nodes[nextNodeId]; } }
/// <summary> /// <summary>
/// 上一个节点 /// 上一个节点
@ -46,11 +47,11 @@ namespace OpenAuth.App.Flow
/// <summary> /// <summary>
/// 实例节点集合 /// 实例节点集合
/// </summary> /// </summary>
public Dictionary<string, FlowNode> nodeDictionary { get; set; } public Dictionary<string, FlowNode> nodes { get; set; }
/// <summary> /// <summary>
/// 流转的线段集合 /// 流转的线段集合
/// </summary> /// </summary>
public Dictionary<string, List<dynamic>> lineDictionary { get; set; } public Dictionary<string, List<FlowLine>> lines { get; set; }
/// <summary> /// <summary>
/// 模板json数据 /// 模板json数据

View File

@ -15,99 +15,8 @@ namespace OpenAuth.App
/// </summary> /// </summary>
public class FlowInstanceApp :BaseApp<FlowInstance> public class FlowInstanceApp :BaseApp<FlowInstance>
{ {
#region
/// <summary>
/// 获取实例进程信息实体
/// </summary>
/// <param name="keyVlaue">The key vlaue.</param>
/// <returns>FlowInstance.</returns>
public FlowInstance GetEntity(string keyVlaue)
{
try
{
return UnitWork.FindSingle<FlowInstance>(u =>u.Id == keyVlaue);
}
catch
{
throw;
}
}
#endregion
#region #region
/// <summary>
/// 存储工作流实例进程(编辑草稿用)
/// </summary>
/// <param name="flowInstance"></param>
/// <param name="wfOperationHistoryEntity"></param>
/// <returns></returns>
public int SaveProcess(string processId, FlowInstance flowInstance, FlowInstanceOperationHistory wfOperationHistoryEntity = null)
{
try
{
if (string.Empty ==(flowInstance.Id))
{
UnitWork.Add(flowInstance);
}
else
{
flowInstance.Id = (processId);
UnitWork.Update(flowInstance);
}
if (wfOperationHistoryEntity != null)
{
wfOperationHistoryEntity.InstanceId = processId;
UnitWork.Add(wfOperationHistoryEntity);
}
UnitWork.Save();
return 1;
}
catch
{
throw;
}
}
/// <summary>
/// 存储工作流实例进程(创建实例进程)
/// </summary>
/// <param name="flowRuntimeModel"></param>
/// <param name="flowInstance"></param>
/// <param name="processOperationHistoryEntity"></param>
/// <returns></returns>
public int SaveProcess(FlowRuntimeModel flowRuntimeModel, FlowInstance flowInstance, FlowInstanceOperationHistory processOperationHistoryEntity, FlowInstanceTransitionHistory processTransitionHistoryEntity)
{
try
{
if (string.Empty == (flowInstance.Id))
{
flowInstance.Id = (string)(flowRuntimeModel.flowInstanceId);
UnitWork.Add(flowInstance);
}
else
{
flowInstance.Id =(flowInstance.Id);
UnitWork.Update(flowInstance);
}
processOperationHistoryEntity.InstanceId = flowInstance.Id;
UnitWork.Add(processOperationHistoryEntity);
if (processTransitionHistoryEntity != null)
{
processTransitionHistoryEntity.InstanceId = flowInstance.Id;
UnitWork.Add(processTransitionHistoryEntity);
}
UnitWork.Save();
return 1;
}
catch
{
throw;
}
}
/// <summary> /// <summary>
/// 存储工作流实例进程(审核驳回重新提交) /// 存储工作流实例进程(审核驳回重新提交)
/// </summary> /// </summary>
@ -197,83 +106,62 @@ namespace OpenAuth.App
/// <param name="description">备注</param> /// <param name="description">备注</param>
/// <param name="frmData">表单数据信息</param> /// <param name="frmData">表单数据信息</param>
/// <returns></returns> /// <returns></returns>
public bool CreateInstance(string processId, string schemeInfoId, FlowInstance FlowInstance, string frmData = null) public bool CreateInstance(FlowInstance flowInstance, string frmData = null)
{ {
try
{
FlowScheme FlowScheme = UnitWork.FindSingle<FlowScheme>(u => u.Id == schemeInfoId);
FlowRuntimeInitModel flowRuntimeInitModel = new FlowRuntimeInitModel()
{
schemeContent = FlowScheme.SchemeContent,
currentNodeId = "",
frmData = frmData,
processId = processId
};
FlowRuntime wfruntime = null;
if (frmData == null) if (frmData == null)
{ {
throw new Exception("自定义表单需要提交表单数据"); throw new Exception("自定义表单需要提交表单数据");
} }
else var wfruntime = new FlowRuntime(flowInstance);
{
wfruntime = new FlowRuntime(flowRuntimeInitModel);
}
var user = AuthUtil.GetCurrentUser(); var user = AuthUtil.GetCurrentUser();
#region #region
FlowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId; flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
FlowInstance.ActivityType = wfruntime.GetStatus();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束 flowInstance.ActivityType = wfruntime.GetNextNodeType();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
FlowInstance.ActivityName = wfruntime.runtimeModel.nextNode.name; flowInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
FlowInstance.PreviousId = wfruntime.runtimeModel.currentNodeId; flowInstance.PreviousId = wfruntime.runtimeModel.currentNodeId;
FlowInstance.SchemeType = FlowScheme.SchemeType; flowInstance.CreateUserId = user.User.Id;
FlowInstance.FrmType = FlowScheme.FrmType; flowInstance.CreateUserName = user.User.Account;
FlowInstance.Disabled = 0;//正式运行 flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
FlowInstance.CreateUserId = user.User.Id.ToString(); flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4 ? 1 : 0);
FlowInstance.CreateUserName = user.User.Account;
FlowInstance.MakerList = (wfruntime.GetStatus() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
FlowInstance.IsFinish = (wfruntime.GetStatus() == 4 ? 1 : 0);
FlowInstance.SchemeContent = FlowScheme.SchemeContent;
#endregion #endregion
#region #region
FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory(); FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
processOperationHistoryEntity.Content = "【创建】" + user.User.Name + "创建了一个流程进程【" + FlowInstance.Code + "/" + FlowInstance.CustomName + "】"; {
InstanceId = flowInstance.Id,
Content = "【创建】"
+ user.User.Name
+ "创建了一个流程进程【"
+ flowInstance.Code + "/"
+ flowInstance.CustomName + "】"
};
#endregion #endregion
#region #region
FlowInstanceTransitionHistory processTransitionHistoryEntity = new FlowInstanceTransitionHistory();
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId; FlowInstanceTransitionHistory processTransitionHistoryEntity = new FlowInstanceTransitionHistory
processTransitionHistoryEntity.FromNodeName = wfruntime.runtimeModel.currentNode.name.Value; {
processTransitionHistoryEntity.FromNodeType = wfruntime.runtimeModel.currentNodeType; InstanceId = flowInstance.Id,
processTransitionHistoryEntity.ToNodeId = wfruntime.runtimeModel.nextNodeId; FromNodeId = wfruntime.runtimeModel.currentNodeId,
processTransitionHistoryEntity.ToNodeName = wfruntime.runtimeModel.nextNode.name; FromNodeName = wfruntime.runtimeModel.currentNode.name.Value,
processTransitionHistoryEntity.ToNodeType = wfruntime.runtimeModel.nextNodeType; FromNodeType = wfruntime.runtimeModel.currentNodeType,
processTransitionHistoryEntity.TransitionSate = 0; ToNodeId = wfruntime.runtimeModel.nextNodeId,
ToNodeName = wfruntime.runtimeModel.nextNode.name,
ToNodeType = wfruntime.runtimeModel.nextNodeType,
TransitionSate = 0
};
processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0); processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
#endregion #endregion
#region UnitWork.Add(flowInstance);
//List<WFDelegateRecord> delegateRecordEntitylist = GetDelegateRecordList(schemeInfoId, FlowInstance.Code, FlowInstance.CustomName, FlowInstance.MakerList); UnitWork.Add(processOperationHistoryEntity);
//FlowInstance.MakerList += delegateUserList; UnitWork.Add(processTransitionHistoryEntity);
#endregion UnitWork.Save();
SaveProcess(wfruntime.runtimeModel, FlowInstance, processOperationHistoryEntity, processTransitionHistoryEntity);
return true; return true;
} }
catch
{
throw;
}
}
/// <summary> /// <summary>
/// 节点审核 /// 节点审核
@ -286,17 +174,11 @@ namespace OpenAuth.App
try try
{ {
string _sqlstr = "", _dbbaseId = ""; string _sqlstr = "", _dbbaseId = "";
FlowInstance FlowInstance = GetEntity(processId); FlowInstance FlowInstance = Get(processId);
FlowInstanceOperationHistory FlowInstanceOperationHistory = new FlowInstanceOperationHistory();//操作记录 FlowInstanceOperationHistory FlowInstanceOperationHistory = new FlowInstanceOperationHistory();//操作记录
FlowInstanceTransitionHistory processTransitionHistoryEntity = null;//流转记录 FlowInstanceTransitionHistory processTransitionHistoryEntity = null;//流转记录
FlowRuntimeInitModel flowRuntimeInitModel = new FlowRuntimeInitModel() FlowRuntime wfruntime = new FlowRuntime(FlowInstance);
{
currentNodeId = FlowInstance.ActivityId,
previousId = FlowInstance.PreviousId,
processId = processId
};
FlowRuntime wfruntime = new FlowRuntime(flowRuntimeInitModel);
#region #region
@ -309,10 +191,10 @@ namespace OpenAuth.App
string _makerList = ""; string _makerList = "";
foreach (string item in _nodelist) foreach (string item in _nodelist)
{ {
_makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.flowInstanceId); _makerList = GetMakerList(wfruntime.runtimeModel.nodes[item], wfruntime.runtimeModel.flowInstanceId);
if (_makerList != "-1") if (_makerList != "-1")
{ {
var id = AuthUtil.GetCurrentUser().User.Id.ToString(); var id = AuthUtil.GetCurrentUser().User.Id;
foreach (string one in _makerList.Split(',')) foreach (string one in _makerList.Split(','))
{ {
if (id == one || id.IndexOf(one) != -1) if (id == one || id.IndexOf(one) != -1)
@ -328,18 +210,17 @@ namespace OpenAuth.App
{ {
if (flag) if (flag)
{ {
FlowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodeDictionary[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description; FlowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodes[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
} }
else else
{ {
FlowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodeDictionary[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description; FlowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodes[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
} }
string _Confluenceres = wfruntime.NodeConfluence(_VerificationNodeId, flag, AuthUtil.GetCurrentUser().User.Id.ToString(), description); string _Confluenceres = wfruntime.NodeConfluence(_VerificationNodeId, flag, AuthUtil.GetCurrentUser().User.Id, description);
var _data = new var _data = new
{ {
SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(), SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(), wfruntime.runtimeModel.frmData
frmData = wfruntime.runtimeModel.frmData
}; };
switch (_Confluenceres) switch (_Confluenceres)
{ {
@ -390,7 +271,7 @@ namespace OpenAuth.App
{ {
if (flag) if (flag)
{ {
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1, AuthUtil.GetCurrentUser().User.Id.ToString(), description); wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1, AuthUtil.GetCurrentUser().User.Id, description);
FlowInstance.PreviousId = FlowInstance.ActivityId; FlowInstance.PreviousId = FlowInstance.ActivityId;
FlowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId; FlowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
FlowInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束 FlowInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
@ -431,8 +312,7 @@ namespace OpenAuth.App
} }
var data = new var data = new
{ {
SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(), SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(), wfruntime.runtimeModel.frmData
frmData = wfruntime.runtimeModel.frmData
}; };
} }
#endregion #endregion
@ -457,16 +337,11 @@ namespace OpenAuth.App
{ {
try try
{ {
FlowInstance FlowInstance = GetEntity(processId); FlowInstance flowInstance = Get(processId);
FlowInstanceOperationHistory FlowInstanceOperationHistory = new FlowInstanceOperationHistory(); FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory();
FlowInstanceTransitionHistory processTransitionHistoryEntity = null; FlowInstanceTransitionHistory processTransitionHistoryEntity = null;
FlowRuntimeInitModel flowRuntimeInitModel = new FlowRuntimeInitModel()
{ FlowRuntime wfruntime = new FlowRuntime(flowInstance);
currentNodeId = FlowInstance.ActivityId,
previousId = FlowInstance.PreviousId,
processId = processId
};
FlowRuntime wfruntime = new FlowRuntime(flowRuntimeInitModel);
string resnode = ""; string resnode = "";
@ -479,14 +354,14 @@ namespace OpenAuth.App
resnode = nodeId; resnode = nodeId;
} }
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 0, AuthUtil.GetUserName(), description); wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 0, AuthUtil.GetUserName(), description);
FlowInstance.IsFinish = 4;//4表示驳回需要申请者重新提交表单 flowInstance.IsFinish = 4;//4表示驳回需要申请者重新提交表单
if (resnode != "") if (resnode != "")
{ {
FlowInstance.PreviousId = FlowInstance.ActivityId; flowInstance.PreviousId = flowInstance.ActivityId;
FlowInstance.ActivityId = resnode; flowInstance.ActivityId = resnode;
FlowInstance.ActivityType = wfruntime.GetNodeStatus(resnode);//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束 flowInstance.ActivityType = wfruntime.GetNodeType(resnode);//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
FlowInstance.ActivityName = wfruntime.runtimeModel.nodeDictionary[resnode].name; flowInstance.ActivityName = wfruntime.runtimeModel.nodes[resnode].name;
FlowInstance.MakerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[resnode], FlowInstance.PreviousId);//当前节点可执行的人信息 flowInstance.MakerList = GetMakerList(wfruntime.runtimeModel.nodes[resnode], flowInstance.PreviousId);//当前节点可执行的人信息
#region #region
processTransitionHistoryEntity = new FlowInstanceTransitionHistory(); processTransitionHistoryEntity = new FlowInstanceTransitionHistory();
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId; processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId;
@ -502,11 +377,11 @@ namespace OpenAuth.App
var data = new var data = new
{ {
SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(), SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
frmData = (FlowInstance.FrmType == 0 ? wfruntime.runtimeModel.frmData : null) frmData = (flowInstance.FrmType == 0 ? wfruntime.runtimeModel.frmData : null)
}; };
FlowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + description; flowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + description;
SaveProcess(FlowInstance, FlowInstanceOperationHistory, processTransitionHistoryEntity); SaveProcess(flowInstance, flowInstanceOperationHistory, processTransitionHistoryEntity);
return true; return true;
} }
catch catch
@ -536,17 +411,15 @@ namespace OpenAuth.App
string _makerList = ""; string _makerList = "";
foreach (string item in _nodelist) foreach (string item in _nodelist)
{ {
_makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.flowInstanceId); _makerList = GetMakerList(wfruntime.runtimeModel.nodes[item], wfruntime.runtimeModel.flowInstanceId);
if (_makerList == "-1") if (_makerList == "-1")
{ {
throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!")); throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!"));
} }
else if (_makerList == "1") if (_makerList == "1")
{ {
throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!")); throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!"));
} }
else
{
if (makerList != "") if (makerList != "")
{ {
makerList += ","; makerList += ",";
@ -554,7 +427,6 @@ namespace OpenAuth.App
makerList += _makerList; makerList += _makerList;
} }
} }
}
else else
{ {
makerList = GetMakerList(wfruntime.runtimeModel.nextNode, wfruntime.runtimeModel.flowInstanceId); makerList = GetMakerList(wfruntime.runtimeModel.nextNode, wfruntime.runtimeModel.flowInstanceId);
@ -724,17 +596,9 @@ namespace OpenAuth.App
} }
public void Add(FlowInstance instance)
{
Repository.Add(instance);
}
public void Update(FlowInstance flowScheme) public void Update(FlowInstance flowScheme)
{ {
Repository.Update(u => u.Id == flowScheme.Id, u => new FlowInstance Repository.Update(u => u.Id == flowScheme.Id, u => new FlowInstance());
{
//todo:要修改的
});
} }
public TableData Load(QueryFlowInstanceListReq request) public TableData Load(QueryFlowInstanceListReq request)

View File

@ -108,7 +108,6 @@
<Compile Include="CategoryApp.cs" /> <Compile Include="CategoryApp.cs" />
<Compile Include="Define.cs" /> <Compile Include="Define.cs" />
<Compile Include="Flow\FlowRuntime.cs" /> <Compile Include="Flow\FlowRuntime.cs" />
<Compile Include="Flow\FlowRuntimeInitModel.cs" />
<Compile Include="Flow\FlowRuntimeModel.cs" /> <Compile Include="Flow\FlowRuntimeModel.cs" />
<Compile Include="Flow\FlowLine.cs" /> <Compile Include="Flow\FlowLine.cs" />
<Compile Include="Flow\FlowNode.cs" /> <Compile Include="Flow\FlowNode.cs" />

View File

@ -47,8 +47,7 @@ namespace OpenAuth.Mvc.Controllers
{ {
try try
{ {
App.Add(obj); App.CreateInstance(obj, null);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -25,10 +25,7 @@ namespace OpenAuth.UnitTest
[TestMethod] [TestMethod]
public void AddProcessInstance() public void AddProcessInstance()
{ {
string name = "请假" + DateTime.Now.ToString("yy-mm-dd_HH_mm_ss");
string str ="{\"Code\":\"请病假\",\"CustomName\":\""+name+"\",\"wfLevel1\":\"1\",\"wfLevel2\":\"2\",\"wfLevel3\":\"3\",\"Description\":\"&nbsp;\",\"EnabledMark\":1,\"wfLevel\":\"2\"}";
string frmData ="{\"4fcd4c6f-eb6b-6a6d-eb4e-7948763c5bba\":\"\",\"88061dda-642e-bcdb-909b-cea2bbe5ad69\":\"&nbsp;\"}";
_runApp.CreateInstance(string.Empty, (string)("5f0ca3df-390a-4bd7-aecb-5304bf2d191c"), str.ToObject<FlowInstance>(), frmData);
} }
} }