mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-04-08 01:51:28 +08:00
完成流程实例列表/详情、流程模版添加
This commit is contained in:
@@ -1,106 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class CommonApplyApp
|
||||
{
|
||||
private IRepository<CommonApply> _repository;
|
||||
private IUnitWork _unitWork;
|
||||
|
||||
public CommonApplyApp(IRepository<CommonApply> repository, IUnitWork unitWork)
|
||||
{
|
||||
_repository = repository;
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
public void AddOrUpdate(CommonApply model)
|
||||
{
|
||||
if (model.Id == Guid.Empty)
|
||||
{
|
||||
model.ApplyTime = DateTime.Now;
|
||||
_repository.Add(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.Update(u => u.Id == model.Id, u => new CommonApply
|
||||
{
|
||||
UserId = model.UserId,
|
||||
Name = model.Name,
|
||||
Comment = model.Comment,
|
||||
WorkflowName = model.WorkflowName
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改流程状态
|
||||
/// </summary>
|
||||
public void ChangeState(Guid id,string state, string statename)
|
||||
{
|
||||
_repository.Update(u =>u.Id == id, u =>new CommonApply
|
||||
{
|
||||
State = state,
|
||||
StateName = statename
|
||||
});
|
||||
}
|
||||
|
||||
public CommonApply Get(Guid value)
|
||||
{
|
||||
return _repository.FindSingle(u =>u.Id == value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载流程处理
|
||||
/// </summary>
|
||||
/// <param name="userid">用户ID</param>
|
||||
/// <param name="type">inbox:待办事项/outbox:已办事项</param>
|
||||
public GridData Load(Guid userid, string type, int pageCurrent, int pageSize)
|
||||
{
|
||||
var result = new GridData
|
||||
{
|
||||
page = pageCurrent
|
||||
};
|
||||
|
||||
if (type == "inbox") //待办事项
|
||||
{
|
||||
var inboxes = GetInboxProcessIds(userid);
|
||||
result.total = _unitWork.Find<CommonApply>(u => inboxes.Contains(u.Id)).Count();
|
||||
result.rows = _unitWork.Find<CommonApply>(pageCurrent, pageSize, "Sort descending",u => inboxes.Contains(u.Id)).ToList();
|
||||
}
|
||||
else if (type == "outbox") //已办事项
|
||||
{
|
||||
IQueryable<Guid> outboxes = GetOutboxProcessIds(userid);
|
||||
result.total = _unitWork.Find<CommonApply>(u => outboxes.Contains(u.Id)).Count();
|
||||
result.rows = _unitWork.Find<CommonApply>(pageCurrent, pageSize, "Sort descending", u => outboxes.Contains(u.Id)).ToList();
|
||||
}
|
||||
else //我的流程
|
||||
{
|
||||
result.total = _unitWork.Find<CommonApply>(u => u.UserId == userid).Count();
|
||||
result.rows = _unitWork.Find<CommonApply>(pageCurrent, pageSize, "Sort descending", u => u.UserId == userid).ToList();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private IQueryable<Guid> GetOutboxProcessIds(Guid userid)
|
||||
{
|
||||
return _unitWork.Find<ApplyTransitionHistory>(u => u.UserId == userid).Select(u => u.ApplyId);
|
||||
}
|
||||
|
||||
private IQueryable<Guid> GetInboxProcessIds(Guid userid)
|
||||
{
|
||||
return _unitWork.Find<Relevance>(u =>u.Key =="ProcessUser" &&(userid == Guid.Empty || u.SecondId == userid)).Select(u =>u.FirstId);
|
||||
}
|
||||
|
||||
public void Del(Guid[] ids)
|
||||
{
|
||||
_repository.Delete(u =>ids.Contains(u.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
64
OpenAuth.App/Extention/IWF_Runtime.cs
Normal file
64
OpenAuth.App/Extention/IWF_Runtime.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenAuth.App.Extention
|
||||
{
|
||||
public interface IWF_Runtime
|
||||
{
|
||||
#region 工作流实例流转API
|
||||
/// <summary>
|
||||
/// 工作流实例运行信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
WF_RuntimeModel runtimeModel{get;}
|
||||
/// <summary>
|
||||
/// 获取实例接下来运行的状态
|
||||
/// </summary>
|
||||
/// <returns>-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束</returns>
|
||||
int GetStatus();
|
||||
/// <summary>
|
||||
/// 获取节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
int GetNodeStatus(string nodeId);
|
||||
/// <summary>
|
||||
/// 获取会签下面需要审核的ID列表
|
||||
/// </summary>
|
||||
/// <param name="shuntnodeId"></param>
|
||||
/// <returns></returns>
|
||||
List<string> GetCountersigningNodeIdList(string shuntnodeId);
|
||||
/// <summary>
|
||||
/// 通过节点Id获取下一个节点Id
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
string GetNextNodeByNodeId(string nodeId);
|
||||
/// <summary>
|
||||
/// 节点会签审核
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <param name="flag"></param>
|
||||
/// <returns>-1不通过,1等待,其它通过</returns>
|
||||
string NodeConfluence(string nodeId, bool flag,string userId, string description = "");
|
||||
/// <summary>
|
||||
/// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string RejectNode();
|
||||
/// <summary>
|
||||
/// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
string RejectNode(string nodeId);
|
||||
/// <summary>
|
||||
/// 标记节点1通过,-1不通过,0驳回
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <param name="flag"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="description"></param>
|
||||
void MakeTagNode(string nodeId, int flag,string userId, string description = "");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
693
OpenAuth.App/Extention/WF_Runtime.cs
Normal file
693
OpenAuth.App/Extention/WF_Runtime.cs
Normal file
@@ -0,0 +1,693 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Infrastructure;
|
||||
|
||||
namespace OpenAuth.App.Extention
|
||||
{
|
||||
/// <summary>
|
||||
/// 版 本 6.1
|
||||
/// Copyright (c) 2013-2016 上海力软信息技术有限公司
|
||||
/// 创建人:陈彬彬
|
||||
/// 日 期:2016.03.04 16:58
|
||||
/// 描 述:工作流流程流转操作类
|
||||
/// </summary>
|
||||
public class WF_Runtime : IWF_Runtime
|
||||
{
|
||||
private WF_RuntimeModel _runtimeModel = null;
|
||||
|
||||
private GetFrmData _getFrmData = null;
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="schemeContent">流程模板</param>
|
||||
/// <param name="currentNodeId">当前节点</param>
|
||||
/// <param name="frmData">表单数据</param>
|
||||
public WF_Runtime(WF_RuntimeInitModel wfRuntimeInitModel,GetFrmData getFrmData = null)
|
||||
{
|
||||
_runtimeModel = new WF_RuntimeModel();
|
||||
_getFrmData = getFrmData;
|
||||
dynamic schemeContentJson = wfRuntimeInitModel.schemeContent.ToJson();//获取工作流模板内容的json对象;
|
||||
_runtimeModel.schemeContentJson = schemeContentJson;//模板流程json对象
|
||||
_runtimeModel.nodeDictionary = GetNodeDictionary(schemeContentJson);//节点集合
|
||||
_runtimeModel.lineDictionary = GetLineDictionary(schemeContentJson);//线条集合
|
||||
_runtimeModel.currentNodeId = (wfRuntimeInitModel.currentNodeId == "" ? _runtimeModel.startNodeId : wfRuntimeInitModel.currentNodeId);
|
||||
_runtimeModel.currentNodeType = GetNodeStatus(_runtimeModel.currentNodeId);
|
||||
_runtimeModel.frmData = wfRuntimeInitModel.frmData;
|
||||
if (getFrmData != null)
|
||||
{
|
||||
_runtimeModel.frmType = 1;
|
||||
wfRuntimeInitModel.frmData = GetNodeFrmData(getFrmData);
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.frmType = 0;
|
||||
}
|
||||
|
||||
if (_runtimeModel.currentNodeType == 0 || _runtimeModel.currentNodeType == 4)
|
||||
{
|
||||
_runtimeModel.nextNodeId = "-1";//下一个节点
|
||||
_runtimeModel.nextNodeType = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.nextNodeId = GetNextNode(wfRuntimeInitModel.frmData);//下一个节点
|
||||
_runtimeModel.nextNodeType = GetNodeStatus(_runtimeModel.nextNodeId);
|
||||
}
|
||||
|
||||
_runtimeModel.previousId = wfRuntimeInitModel.previousId;
|
||||
|
||||
_runtimeModel.processId = wfRuntimeInitModel.processId.ToString();
|
||||
_runtimeModel.sqlFrm = SqlBuider(schemeContentJson, wfRuntimeInitModel.frmData, wfRuntimeInitModel.processId.ToString());
|
||||
|
||||
}
|
||||
|
||||
#region 私有方法
|
||||
/// <summary>
|
||||
/// 获取工作流节点的字典列表:key节点id
|
||||
/// </summary>
|
||||
/// <param name="schemeContentJson"></param>
|
||||
/// <returns></returns>
|
||||
private Dictionary<string, dynamic> GetNodeDictionary(dynamic schemeContentJson)
|
||||
{
|
||||
Dictionary<string, dynamic> nodeDictionary = new Dictionary<string, dynamic>();
|
||||
foreach (var item in schemeContentJson.Flow.nodes)
|
||||
{
|
||||
if (!nodeDictionary.ContainsKey(item.id.Value))
|
||||
{
|
||||
nodeDictionary.Add(item.id.Value, item);
|
||||
}
|
||||
if (item.type == "startround")
|
||||
{
|
||||
this._runtimeModel.startNodeId = item.id.Value;
|
||||
}
|
||||
}
|
||||
return nodeDictionary;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工作流线段的字典列表:key开始节点id,value线条实体列表
|
||||
/// </summary>
|
||||
/// <param name="schemeContentJson"></param>
|
||||
/// <returns></returns>
|
||||
private Dictionary<string, List<dynamic>> GetLineDictionary(dynamic schemeContentJson)
|
||||
{
|
||||
Dictionary<string, List<dynamic>> lineDictionary = new Dictionary<string, List<dynamic>>();
|
||||
foreach (var item in schemeContentJson.Flow.lines)
|
||||
{
|
||||
if (!lineDictionary.ContainsKey(item.from.Value))
|
||||
{
|
||||
List<dynamic> d = new List<dynamic>();
|
||||
d.Add(item);
|
||||
lineDictionary.Add(item.from.Value, d);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineDictionary[item.from.Value].Add(item);
|
||||
}
|
||||
}
|
||||
return lineDictionary;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工作流线段的字典列表:key开始节点id,value线条实体列表
|
||||
/// </summary>
|
||||
/// <param name="schemeContentJson"></param>
|
||||
/// <returns></returns>
|
||||
private Dictionary<string, List<dynamic>> GetToLineDictionary(dynamic schemeContentJson)
|
||||
{
|
||||
Dictionary<string, List<dynamic>> lineDictionary = new Dictionary<string, List<dynamic>>();
|
||||
foreach (var item in schemeContentJson.Flow.lines)
|
||||
{
|
||||
if (!lineDictionary.ContainsKey(item.to.Value))
|
||||
{
|
||||
List<dynamic> d = new List<dynamic>();
|
||||
d.Add(item);
|
||||
lineDictionary.Add(item.to.Value, d);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineDictionary[item.to.Value].Add(item);
|
||||
}
|
||||
}
|
||||
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>
|
||||
/// 获取SQL语句
|
||||
/// </summary>
|
||||
/// <param name="tablename"></param>
|
||||
/// <param name="frmData"></param>
|
||||
/// <returns></returns>
|
||||
private string SqlBuider(dynamic schemeContentJson, string frmData, string keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (schemeContentJson.Frm.isSystemTable.Value == 1)
|
||||
{
|
||||
var strSql = new StringBuilder();
|
||||
var frmDataParam = frmData.ToJObject();
|
||||
string sqlname = schemeContentJson.Frm.FrmTableId.Value, sqlvalues = "'" + keyValue + "'";
|
||||
foreach (var item in frmDataParam)
|
||||
{
|
||||
if (item.Key != "__RequestVerificationToken")
|
||||
{
|
||||
sqlname += "," + item.Key;
|
||||
if (item.Value.Type.ToString() == "String")
|
||||
{
|
||||
sqlvalues += ",'" + item.Value + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlvalues += "," + item.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
strSql.Append(string.Format("insert into " + schemeContentJson.Frm.FrmTable.Value + " ({0})values({1})", sqlname, sqlvalues));
|
||||
return strSql.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 系统表单获取表单数据
|
||||
/// </summary>
|
||||
/// <param name="getFrmData"></param>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
private string GetNodeFrmData(GetFrmData getFrmData,string nodeId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string _nodeId = (nodeId == null ? _runtimeModel.currentNodeId : nodeId);
|
||||
dynamic _node = _runtimeModel.nodeDictionary[_nodeId];
|
||||
if (_node.setInfo != null)
|
||||
{
|
||||
return getFrmData(_node.setInfo.NodeDataBase.Value, _node.setInfo.NodeTable.Value, _node.setInfo.NodePram.Value, _runtimeModel.processId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取下一个节点
|
||||
/// </summary>
|
||||
/// <param name="frmData">表单数据(用于判断流转条件)</param>
|
||||
private string GetNextNode(string frmData,string nodeId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<dynamic> LineList = null;
|
||||
if (nodeId == null)
|
||||
{
|
||||
LineList = runtimeModel.lineDictionary[runtimeModel.currentNodeId];
|
||||
}
|
||||
else
|
||||
{
|
||||
LineList = runtimeModel.lineDictionary[nodeId];
|
||||
}
|
||||
if (LineList.Count == 1)
|
||||
{
|
||||
return LineList[0].to.Value;
|
||||
}
|
||||
else if (frmData != "")
|
||||
{
|
||||
frmData = frmData.ToLower();//统一转小写
|
||||
var frmDataJson = frmData.ToJObject();//获取数据内容
|
||||
bool flag = false;
|
||||
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")
|
||||
{
|
||||
flag = compareValue;
|
||||
if (!compareValue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (compareValue)
|
||||
{
|
||||
flag = compareValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)//如果满足条件,
|
||||
{
|
||||
return item.to.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "-1";//表示寻找不到节点
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 工作流实例流转API
|
||||
/// <summary>
|
||||
/// 工作流实例运行信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public WF_RuntimeModel runtimeModel
|
||||
{
|
||||
get { return _runtimeModel; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取实例接下来运行的状态
|
||||
/// </summary>
|
||||
/// <returns>-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束</returns>
|
||||
public int GetStatus()
|
||||
{
|
||||
if (_runtimeModel.nextNodeId != "-1")
|
||||
{
|
||||
if (_runtimeModel.nextNode.type == "shuntnode")//会签开始节点
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (_runtimeModel.nextNode.type == "confluencenode")//会签结束节点
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (_runtimeModel.nextNode.type == "endround")//结束节点
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
public int GetNodeStatus(string nodeId)
|
||||
{
|
||||
if (_runtimeModel.nodeDictionary[nodeId].type == "shuntnode")//会签开始节点
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (_runtimeModel.nodeDictionary[nodeId].type == "confluencenode")//会签结束节点
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (_runtimeModel.nodeDictionary[nodeId].type == "endround")//结束节点
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
else if (_runtimeModel.nodeDictionary[nodeId].type == "startround")//开始节点
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取会签下面需要审核的ID列表
|
||||
/// </summary>
|
||||
/// <param name="shuntnodeId"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetCountersigningNodeIdList(string shuntnodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
|
||||
List<dynamic> listline = _runtimeModel.lineDictionary[shuntnodeId];
|
||||
|
||||
foreach (var item in listline)
|
||||
{
|
||||
list.Add(item.to.Value);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过节点Id获取下一个节点Id
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetNextNodeByNodeId(string nodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
string frmData = "";
|
||||
if (_runtimeModel.frmType == 0)
|
||||
{
|
||||
frmData = _runtimeModel.frmData;
|
||||
}
|
||||
else
|
||||
{
|
||||
frmData = GetNodeFrmData(_getFrmData, nodeId);
|
||||
}
|
||||
return GetNextNode(frmData, nodeId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 节点会签审核
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <param name="flag"></param>
|
||||
/// <returns>-1不通过,1等待,其它通过</returns>
|
||||
public string NodeConfluence(string nodeId, bool flag,string userId, string description = "")
|
||||
{
|
||||
string res = "-1";
|
||||
try
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
MakeTagNode(nodeId, 1, userId, description);
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeTagNode(nodeId, -1, userId, description);
|
||||
}
|
||||
|
||||
string _nextNodeId = GetNextNodeByNodeId(nodeId);//获取下一个节点
|
||||
if (_nextNodeId != "-1")
|
||||
{
|
||||
Dictionary<string, List<dynamic>> toLines = GetToLineDictionary(_runtimeModel.schemeContentJson);
|
||||
int allnum = toLines[_nextNodeId].Count;
|
||||
int i = 0;
|
||||
foreach (var item in _runtimeModel.schemeContentJson.Flow.nodes)
|
||||
{
|
||||
if (item.id.Value == _nextNodeId)
|
||||
{
|
||||
if(item.setInfo.NodeConfluenceType.Value == "0")//0所有步骤通过
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
if (item.setInfo.ConfluenceOk == null)
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk = 1;
|
||||
res = "1";
|
||||
}
|
||||
else if (item.setInfo.ConfluenceOk.Value == (allnum - 1))
|
||||
{
|
||||
res = GetNextNodeByNodeId(_nextNodeId);
|
||||
if (res == "-1")
|
||||
{
|
||||
throw (new Exception("会签成功寻找不到下一个节点"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk++;
|
||||
res = "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(item.setInfo.NodeConfluenceType.Value == "1")//1一个步骤通过即可
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
res = GetNextNodeByNodeId(_nextNodeId);
|
||||
if (res == "-1")
|
||||
{
|
||||
throw (new Exception("会签成功寻找不到下一个节点"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.setInfo.ConfluenceNo == null)
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo = 1;
|
||||
res = "1";
|
||||
}
|
||||
else if (item.setInfo.ConfluenceNo.Value == (allnum - 1))
|
||||
{
|
||||
res = "-1";
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo++;
|
||||
res = "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
else//2按百分比计算
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
if (item.setInfo.ConfluenceOk == null)
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.setInfo.ConfluenceNo == null)
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo++;
|
||||
}
|
||||
}
|
||||
if ((item.setInfo.ConfluenceNo.Value + item.setInfo.ConfluenceOk.Value) / allnum * 100 > int.Parse(item.setInfo.NodeConfluenceRate.Value))
|
||||
{
|
||||
res = GetNextNodeByNodeId(_nextNodeId);
|
||||
if (res == "-1")
|
||||
{
|
||||
throw (new Exception("会签成功寻找不到下一个节点"));
|
||||
}
|
||||
}
|
||||
else if ((item.setInfo.ConfluenceNo.Value + item.setInfo.ConfluenceOk.Value) == allnum)
|
||||
{
|
||||
res = "-1";
|
||||
}
|
||||
else
|
||||
{
|
||||
res = "1";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (res == "-1")
|
||||
{
|
||||
MakeTagNode(_nextNodeId, -1, userId);
|
||||
}
|
||||
else if (res != "1")
|
||||
{
|
||||
MakeTagNode(_nextNodeId, 1, userId);
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeModel.nextNodeId = res;
|
||||
_runtimeModel.nextNodeType = GetNodeStatus(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw (new Exception("寻找不到会签下合流节点"));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string RejectNode()
|
||||
{
|
||||
return RejectNode(_runtimeModel.currentNodeId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
public string RejectNode(string nodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
dynamic _node = _runtimeModel.nodeDictionary[nodeId];
|
||||
if (_node.setInfo != null)
|
||||
{
|
||||
if (_node.setInfo.NodeRejectType.Value == "0")
|
||||
{
|
||||
return _runtimeModel.previousId;
|
||||
}
|
||||
else if (_node.setInfo.NodeRejectType.Value == "1")
|
||||
{
|
||||
return GetNextNodeByNodeId(_runtimeModel.startNodeId);
|
||||
}
|
||||
else if (_node.setInfo.NodeRejectType.Value == "2")
|
||||
{
|
||||
return _node.setInfo.NodeRejectStep.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
else//前一步
|
||||
{
|
||||
return _runtimeModel.previousId;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// 标记节点1通过,-1不通过,0驳回
|
||||
/// </summary>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <param name="flag"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="description"></param>
|
||||
public void MakeTagNode(string nodeId, int flag, string userId, string description = "")
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in _runtimeModel.schemeContentJson.Flow.nodes)
|
||||
{
|
||||
if (item.id.Value == nodeId)
|
||||
{
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.Taged = flag;
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.UserId = userId;
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.description = description;
|
||||
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.TagedTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
35
OpenAuth.App/Extention/WF_RuntimeInitModel.cs
Normal file
35
OpenAuth.App/Extention/WF_RuntimeInitModel.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
|
||||
namespace OpenAuth.App.Extention
|
||||
{
|
||||
/// <summary>
|
||||
/// 版 本 6.1
|
||||
/// Copyright (c) 2013-2016 上海力软信息技术有限公司
|
||||
/// 创建人:陈彬彬
|
||||
/// 日 期:2016.03.04 16:58
|
||||
/// 描 述:工作流流程流转初始化模型类
|
||||
/// </summary>
|
||||
public class WF_RuntimeInitModel
|
||||
{
|
||||
/// <summary>
|
||||
/// GUID
|
||||
/// </summary>
|
||||
public Guid 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; }
|
||||
}
|
||||
}
|
||||
86
OpenAuth.App/Extention/WF_RuntimeModel.cs
Normal file
86
OpenAuth.App/Extention/WF_RuntimeModel.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenAuth.App.Extention
|
||||
{
|
||||
/// <summary>
|
||||
/// 版 本 6.1
|
||||
/// Copyright (c) 2013-2016 上海力软信息技术有限公司
|
||||
/// 创建人:陈彬彬
|
||||
/// 日 期:2016.03.04 16:58
|
||||
/// 描 述:工作流流程流转模型类
|
||||
/// </summary>
|
||||
public class WF_RuntimeModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行实例的Id
|
||||
/// </summary>
|
||||
public string processId { get; set; }
|
||||
/// <summary>
|
||||
/// 开始节点的ID
|
||||
/// </summary>
|
||||
public string startNodeId { get; set; }
|
||||
/// <summary>
|
||||
/// 开始节点的对象
|
||||
/// </summary>
|
||||
public dynamic startNode { get { return this.nodeDictionary[this.startNodeId]; } }
|
||||
/// <summary>
|
||||
/// 当前节点的ID
|
||||
/// </summary>
|
||||
public string currentNodeId { get; set; }
|
||||
/// <summary>
|
||||
/// 当前节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
|
||||
/// </summary>
|
||||
public int currentNodeType { get; set; }
|
||||
/// <summary>
|
||||
/// 当前节点的对象
|
||||
/// </summary>
|
||||
public dynamic currentNode { get { return this.nodeDictionary[this.currentNodeId]; } }
|
||||
/// <summary>
|
||||
/// 下一个节点
|
||||
/// </summary>
|
||||
public string nextNodeId { get; set; }
|
||||
/// <summary>
|
||||
/// 下一个节点类型
|
||||
/// </summary>
|
||||
public int nextNodeType { get; set; }
|
||||
/// <summary>
|
||||
/// 下一个节点对象
|
||||
/// </summary>
|
||||
public dynamic nextNode { get { return this.nodeDictionary[this.nextNodeId]; } }
|
||||
|
||||
/// <summary>
|
||||
/// 上一个节点
|
||||
/// </summary>
|
||||
public string previousId { get; set; }
|
||||
/// <summary>
|
||||
/// 上一个节点
|
||||
/// </summary>
|
||||
public dynamic previousNode { get { return this.nodeDictionary[this.previousId]; } }
|
||||
/// <summary>
|
||||
/// 实例节点集合
|
||||
/// </summary>
|
||||
public Dictionary<string, dynamic> nodeDictionary { get; set; }
|
||||
/// <summary>
|
||||
/// 流转的线段集合
|
||||
/// </summary>
|
||||
public Dictionary<string, List<dynamic>> lineDictionary { get; set; }
|
||||
/// <summary>
|
||||
/// (建表的表单需要插入的数据表的语句)
|
||||
/// </summary>
|
||||
public string sqlFrm { get; set; }
|
||||
/// <summary>
|
||||
/// 模板json数据
|
||||
/// </summary>
|
||||
public dynamic schemeContentJson { get; set; }
|
||||
/// <summary>
|
||||
/// 表单数据
|
||||
/// </summary>
|
||||
public string frmData { get; set; }
|
||||
/// <summary>
|
||||
/// 表单类型(0自定义表单,1系统表单)
|
||||
/// </summary>
|
||||
public int frmType { get; set; }
|
||||
}
|
||||
|
||||
public delegate string GetFrmData(string DataBaseId, string tableName, string tableFiled, string processId);
|
||||
}
|
||||
@@ -83,6 +83,12 @@
|
||||
<Compile Include="ApplyTransitionHistoryApp.cs" />
|
||||
<Compile Include="CategoryManagerApp.cs" />
|
||||
<Compile Include="AuthorizeApp.cs" />
|
||||
<Compile Include="Extention\IWF_Runtime.cs" />
|
||||
<Compile Include="Extention\WF_Runtime.cs" />
|
||||
<Compile Include="Extention\WF_RuntimeInitModel.cs" />
|
||||
<Compile Include="Extention\WF_RuntimeModel.cs" />
|
||||
<Compile Include="WFProcessInstanceService.cs" />
|
||||
<Compile Include="WFRuntimeService.cs" />
|
||||
<Compile Include="WorkflowInboxApp.cs" />
|
||||
<Compile Include="ModuleElementManagerApp.cs" />
|
||||
<Compile Include="ModuleManagerApp.cs" />
|
||||
@@ -98,7 +104,6 @@
|
||||
<Compile Include="SSO\LoginResult.cs" />
|
||||
<Compile Include="SSO\SSOAuthAttribute.cs" />
|
||||
<Compile Include="SSO\UserAuthSession.cs" />
|
||||
<Compile Include="CommonApplyApp.cs" />
|
||||
<Compile Include="StockManagerApp.cs" />
|
||||
<Compile Include="UserManagerApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a CodeSmith Template.
|
||||
//
|
||||
// DO NOT MODIFY contents of this file. Changes to this
|
||||
// file will be lost if the code is regenerated.
|
||||
// Author:Yubao Li
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Infrastructure;
|
||||
using OpenAuth.Domain;
|
||||
|
||||
namespace OpenAuth.App.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CommonApplyVM :Entity
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Number { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Comment { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string State { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string StateName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.Guid UserId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.Guid? ControllerUserId { get; set; }
|
||||
|
||||
public string WorkflowName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用命令
|
||||
/// </summary>
|
||||
public CommandModel[] Commands { get; set; }
|
||||
|
||||
public Dictionary<string, string> AvailiableStates { get; set; }
|
||||
|
||||
public static implicit operator CommonApplyVM(CommonApply obj)
|
||||
{
|
||||
return obj.MapTo<CommonApplyVM>();
|
||||
}
|
||||
|
||||
public static implicit operator CommonApply(CommonApplyVM obj)
|
||||
{
|
||||
return obj.MapTo<CommonApply>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
358
OpenAuth.App/WFProcessInstanceService.cs
Normal file
358
OpenAuth.App/WFProcessInstanceService.cs
Normal file
@@ -0,0 +1,358 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenAuth.App.Extention;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作流实例表操作
|
||||
/// <para>李玉宝新增于2017-01-16 20:33:48</para>
|
||||
/// </summary>
|
||||
public class WFProcessInstanceService
|
||||
{
|
||||
protected IUnitWork _unitWork;
|
||||
|
||||
public WFProcessInstanceService(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
#region 获取数据
|
||||
/// <summary>
|
||||
/// 获取实例进程信息实体
|
||||
/// </summary>
|
||||
/// <param name="keyVlaue"></param>
|
||||
/// <returns></returns>
|
||||
public WFProcessInstance GetEntity(Guid keyVlaue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _unitWork.FindSingle<WFProcessInstance>(u =>u.Id == keyVlaue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 提交数据
|
||||
/// <summary>
|
||||
/// 存储工作流实例进程(编辑草稿用)
|
||||
/// </summary>
|
||||
/// <param name="processInstanceEntity"></param>
|
||||
/// <param name="processSchemeEntity"></param>
|
||||
/// <param name="wfOperationHistoryEntity"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveProcess(Guid processId, WFProcessInstance processInstanceEntity, WFProcessScheme processSchemeEntity, WFProcessOperationHistory wfOperationHistoryEntity = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Guid.Empty ==(processInstanceEntity.Id))
|
||||
{
|
||||
_unitWork.Add(processSchemeEntity);
|
||||
|
||||
processInstanceEntity.Create();
|
||||
processInstanceEntity.Id = processId;
|
||||
processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
|
||||
_unitWork.Add(processInstanceEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
processInstanceEntity.Modify(processId);
|
||||
_unitWork.Update(processInstanceEntity);
|
||||
|
||||
processSchemeEntity.Modify(processInstanceEntity.ProcessSchemeId);
|
||||
_unitWork.Update(processSchemeEntity);
|
||||
}
|
||||
if (wfOperationHistoryEntity != null)
|
||||
{
|
||||
wfOperationHistoryEntity.ProcessId = processId;
|
||||
_unitWork.Add(wfOperationHistoryEntity);
|
||||
}
|
||||
_unitWork.Save();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 存储工作流实例进程(创建实例进程)
|
||||
/// </summary>
|
||||
/// <param name="wfRuntimeModel"></param>
|
||||
/// <param name="processInstanceEntity"></param>
|
||||
/// <param name="processSchemeEntity"></param>
|
||||
/// <param name="processOperationHistoryEntity"></param>
|
||||
/// <param name="delegateRecordEntity"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveProcess(WF_RuntimeModel wfRuntimeModel, WFProcessInstance processInstanceEntity, WFProcessScheme processSchemeEntity, WFProcessOperationHistory processOperationHistoryEntity, WFProcessTransitionHistory processTransitionHistoryEntity)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Guid.Empty == (processInstanceEntity.Id))
|
||||
{
|
||||
processSchemeEntity.Create();
|
||||
_unitWork.Add(processSchemeEntity);
|
||||
|
||||
processInstanceEntity.Create();
|
||||
processInstanceEntity.Id = Guid.Parse(wfRuntimeModel.processId);
|
||||
processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
|
||||
_unitWork.Add(processInstanceEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
processInstanceEntity.Modify(processInstanceEntity.Id);
|
||||
_unitWork.Update(processSchemeEntity);
|
||||
_unitWork.Update(processInstanceEntity);
|
||||
}
|
||||
processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
|
||||
_unitWork.Add(processOperationHistoryEntity);
|
||||
|
||||
if (processTransitionHistoryEntity != null)
|
||||
{
|
||||
processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
|
||||
_unitWork.Add(processTransitionHistoryEntity);
|
||||
}
|
||||
|
||||
_unitWork.Save();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 存储工作流实例进程(审核驳回重新提交)
|
||||
/// </summary>
|
||||
/// <param name="processInstanceEntity"></param>
|
||||
/// <param name="processSchemeEntity"></param>
|
||||
/// <param name="processOperationHistoryEntity"></param>
|
||||
/// <param name="processTransitionHistoryEntity"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveProcess(WFProcessInstance processInstanceEntity, WFProcessScheme processSchemeEntity,
|
||||
WFProcessOperationHistory processOperationHistoryEntity, WFProcessTransitionHistory processTransitionHistoryEntity = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
processInstanceEntity.Modify(processInstanceEntity.Id);
|
||||
_unitWork.Update(processSchemeEntity);
|
||||
_unitWork.Update(processInstanceEntity);
|
||||
|
||||
processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
|
||||
_unitWork.Add(processOperationHistoryEntity);
|
||||
|
||||
if (processTransitionHistoryEntity != null)
|
||||
{
|
||||
processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
|
||||
_unitWork.Add(processTransitionHistoryEntity);
|
||||
}
|
||||
|
||||
_unitWork.Save();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新流程实例 审核节点用
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="dbbaseId"></param>
|
||||
/// <param name="processInstanceEntity"></param>
|
||||
/// <param name="processSchemeEntity"></param>
|
||||
/// <param name="processOperationHistoryEntity"></param>
|
||||
/// <param name="delegateRecordEntityList"></param>
|
||||
/// <param name="processTransitionHistoryEntity"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveProcess(string sql,string dbbaseId, WFProcessInstance processInstanceEntity, WFProcessScheme processSchemeEntity, WFProcessOperationHistory processOperationHistoryEntity, WFProcessTransitionHistory processTransitionHistoryEntity = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
processInstanceEntity.Modify(processInstanceEntity.Id);
|
||||
_unitWork.Update(processSchemeEntity);
|
||||
_unitWork.Update(processInstanceEntity);
|
||||
|
||||
processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
|
||||
_unitWork.Add(processOperationHistoryEntity);
|
||||
|
||||
if (processTransitionHistoryEntity != null)
|
||||
{
|
||||
processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
|
||||
_unitWork.Add(processTransitionHistoryEntity);
|
||||
}
|
||||
|
||||
//if (!string.IsNullOrEmpty(dbbaseId) && !string.IsNullOrEmpty(sql))//测试环境不允许执行sql语句
|
||||
//{
|
||||
// DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(dbbaseId);//获取
|
||||
// this.BaseRepository(dataBaseLinkEntity.DbConnection).ExecuteBySql(sql.Replace("{0}", processInstanceEntity.Id));
|
||||
//}
|
||||
_unitWork.Save();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存工作流进程实例
|
||||
/// </summary>
|
||||
/// <param name="processInstanceEntity"></param>
|
||||
/// <returns></returns>
|
||||
public int SaveProcess(WFProcessInstance processInstanceEntity)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance isExistEntity = _unitWork.FindSingle<WFProcessInstance>(u =>u.Id ==processInstanceEntity.Id);
|
||||
if (isExistEntity == null)
|
||||
{
|
||||
processInstanceEntity.Create();
|
||||
_unitWork.Add(processInstanceEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
processInstanceEntity.Modify(processInstanceEntity.Id);
|
||||
_unitWork.Update(processInstanceEntity);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除工作流实例进程(删除草稿使用)
|
||||
/// </summary>
|
||||
/// <param name="keyValue">主键</param>
|
||||
/// <returns></returns>
|
||||
public int DeleteProcess(Guid keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance entity = _unitWork.FindSingle<WFProcessInstance>(u =>u.Id ==keyValue);
|
||||
|
||||
_unitWork.Delete<WFProcessInstance>(u =>u.Id == keyValue);
|
||||
_unitWork.Delete<WFProcessScheme>(u =>u.Id == entity.ProcessSchemeId);
|
||||
_unitWork.Save();
|
||||
return 1;
|
||||
}
|
||||
catch {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 虚拟操作实例
|
||||
/// </summary>
|
||||
/// <param name="keyValue"></param>
|
||||
/// <param name="state">0暂停,1启用,2取消(召回)</param>
|
||||
/// <returns></returns>
|
||||
public int OperateVirtualProcess(Guid keyValue,int state)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance entity = _unitWork.FindSingle<WFProcessInstance>(u =>u.Id ==keyValue);
|
||||
if (entity.IsFinish == 1)
|
||||
{
|
||||
throw new Exception("实例已经审核完成,操作失败");
|
||||
}
|
||||
else if (entity.IsFinish == 2)
|
||||
{
|
||||
throw new Exception("实例已经取消,操作失败");
|
||||
}
|
||||
/// 流程是否完成(0运行中,1运行结束,2被召回,3不同意,4表示被驳回)
|
||||
string content = "";
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
if (entity.EnabledMark == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
entity.EnabledMark = 0;
|
||||
content = "【暂停】暂停了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
|
||||
break;
|
||||
case 1:
|
||||
if (entity.EnabledMark == 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
entity.EnabledMark = 1;
|
||||
content = "【启用】启用了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
|
||||
break;
|
||||
case 2:
|
||||
entity.IsFinish = 2;
|
||||
content = "【召回】召回了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
|
||||
break;
|
||||
}
|
||||
_unitWork.Update(entity);
|
||||
WFProcessOperationHistory processOperationHistoryEntity = new WFProcessOperationHistory();
|
||||
processOperationHistoryEntity.ProcessId = entity.Id;
|
||||
processOperationHistoryEntity.Content = content;
|
||||
_unitWork.Add(processOperationHistoryEntity);
|
||||
_unitWork.Save();
|
||||
return 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 流程指派
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <param name="makeLists"></param>
|
||||
public void DesignateProcess(Guid processId, string makeLists)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance entity = new WFProcessInstance();
|
||||
entity.Id = processId;
|
||||
entity.MakerList = makeLists;
|
||||
_unitWork.Update(entity);
|
||||
}
|
||||
catch {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public GridData Load(string userid, string type, int pageCurrent, int pageSize)
|
||||
{
|
||||
var result = new GridData
|
||||
{
|
||||
page = pageCurrent
|
||||
};
|
||||
|
||||
if (type == "inbox") //待办事项
|
||||
{
|
||||
result.total = _unitWork.Find<WFProcessInstance>(u => u.CreateUserId == userid).Count();
|
||||
result.rows = _unitWork.Find<WFProcessInstance>(pageCurrent, pageSize, "CreateDate descending", null).ToList();
|
||||
|
||||
}
|
||||
else if (type == "outbox") //已办事项
|
||||
{
|
||||
result.total = _unitWork.Find<WFProcessInstance>(u => u.CreateUserId == userid).Count();
|
||||
result.rows = _unitWork.Find<WFProcessInstance>(pageCurrent, pageSize, "CreateDate descending", null).ToList();
|
||||
|
||||
}
|
||||
else //我的流程
|
||||
{
|
||||
result.total = _unitWork.Find<WFProcessInstance>(u => u.CreateUserId == userid).Count();
|
||||
result.rows = _unitWork.Find<WFProcessInstance>(pageCurrent, pageSize, "CreateDate descending", null).ToList();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
966
OpenAuth.App/WFRuntimeService.cs
Normal file
966
OpenAuth.App/WFRuntimeService.cs
Normal file
@@ -0,0 +1,966 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Extention;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 流程运行
|
||||
/// <para>李玉宝新增于2017-01-17 9:02:02</para>
|
||||
/// </summary>
|
||||
public class WFRuntimeService
|
||||
{
|
||||
private IUnitWork _unitWork;
|
||||
private WFProcessInstanceService wfProcessInstanceService;
|
||||
|
||||
public WFRuntimeService(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
private string delegateUserList = "";
|
||||
|
||||
#region 流程处理API
|
||||
/// <summary>
|
||||
/// 创建一个实例
|
||||
/// </summary>
|
||||
/// <param name="processId">进程GUID</param>
|
||||
/// <param name="schemeInfoId">模板信息ID</param>
|
||||
/// <param name="wfLevel"></param>
|
||||
/// <param name="code">进程编号</param>
|
||||
/// <param name="customName">自定义名称</param>
|
||||
/// <param name="description">备注</param>
|
||||
/// <param name="frmData">表单数据信息</param>
|
||||
/// <returns></returns>
|
||||
public bool CreateInstance(Guid processId, Guid schemeInfoId, WFProcessInstance WFProcessInstance, string frmData = null)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
WFSchemeInfo WFSchemeInfo = _unitWork.FindSingle<WFSchemeInfo>(u =>u.Id == schemeInfoId);
|
||||
WFSchemeContent WFSchemeContent = _unitWork.FindSingle<WFSchemeContent>(u =>
|
||||
u.SchemeInfoId==schemeInfoId && u.SchemeVersion ==WFSchemeInfo.SchemeVersion);
|
||||
|
||||
WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
|
||||
{
|
||||
schemeContent = WFSchemeContent.SchemeContent,
|
||||
currentNodeId = "",
|
||||
frmData = frmData,
|
||||
processId = processId
|
||||
};
|
||||
IWF_Runtime wfruntime = null;
|
||||
|
||||
if(frmData == null)
|
||||
{
|
||||
throw new Exception("自定义表单需要提交表单数据");
|
||||
}
|
||||
else
|
||||
{
|
||||
wfruntime = new WF_Runtime(wfRuntimeInitModel);
|
||||
}
|
||||
|
||||
|
||||
#region 实例信息
|
||||
WFProcessInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
|
||||
WFProcessInstance.ActivityType = wfruntime.GetStatus();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
|
||||
WFProcessInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
|
||||
WFProcessInstance.PreviousId = wfruntime.runtimeModel.currentNodeId;
|
||||
WFProcessInstance.SchemeType = WFSchemeInfo.SchemeType;
|
||||
WFProcessInstance.FrmType = WFSchemeInfo.FrmType;
|
||||
WFProcessInstance.EnabledMark = 1;//正式运行
|
||||
WFProcessInstance.MakerList =(wfruntime.GetStatus() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
|
||||
WFProcessInstance.IsFinish = (wfruntime.GetStatus() == 4 ? 1 : 0);
|
||||
#endregion
|
||||
|
||||
#region 实例模板
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = WFSchemeContent.SchemeContent,
|
||||
frmData = frmData
|
||||
};
|
||||
WFProcessScheme WFProcessScheme = new WFProcessScheme {
|
||||
SchemeInfoId = schemeInfoId,
|
||||
SchemeVersion = WFSchemeInfo.SchemeVersion,
|
||||
ProcessType = 1,//1正式,0草稿
|
||||
SchemeContent = data.ToJson().ToString()
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region 流程操作记录
|
||||
WFProcessOperationHistory processOperationHistoryEntity = new WFProcessOperationHistory();
|
||||
processOperationHistoryEntity.Content = "【创建】" + "todo"+ "创建了一个流程进程【" + WFProcessInstance.Code + "/" + WFProcessInstance.CustomName + "】";
|
||||
#endregion
|
||||
|
||||
#region 流转记录
|
||||
WFProcessTransitionHistory processTransitionHistoryEntity = new WFProcessTransitionHistory();
|
||||
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId;
|
||||
processTransitionHistoryEntity.FromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
|
||||
processTransitionHistoryEntity.FromNodeType = wfruntime.runtimeModel.currentNodeType;
|
||||
processTransitionHistoryEntity.ToNodeId = wfruntime.runtimeModel.nextNodeId;
|
||||
processTransitionHistoryEntity.ToNodeName = wfruntime.runtimeModel.nextNode.name.Value;
|
||||
processTransitionHistoryEntity.ToNodeType = wfruntime.runtimeModel.nextNodeType;
|
||||
processTransitionHistoryEntity.TransitionSate =0;
|
||||
processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
|
||||
#endregion
|
||||
|
||||
#region 委托记录
|
||||
//List<WFDelegateRecord> delegateRecordEntitylist = GetDelegateRecordList(schemeInfoId, WFProcessInstance.Code, WFProcessInstance.CustomName, WFProcessInstance.MakerList);
|
||||
//WFProcessInstance.MakerList += delegateUserList;
|
||||
#endregion
|
||||
|
||||
wfProcessInstanceService.SaveProcess(wfruntime.runtimeModel, WFProcessInstance, WFProcessScheme, processOperationHistoryEntity, processTransitionHistoryEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建一个实例(草稿创建)
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="customName"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="frmData"></param>
|
||||
/// <returns></returns>
|
||||
public bool CreateInstance(WFProcessInstance WFProcessInstance, string frmData = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance _WFProcessInstance = wfProcessInstanceService.GetEntity(WFProcessInstance.Id);
|
||||
WFProcessScheme WFProcessScheme = _unitWork.FindSingle<WFProcessScheme>(u =>u.Id ==WFProcessInstance.ProcessSchemeId);
|
||||
dynamic schemeContentJson = WFProcessScheme.SchemeContent.ToJson();//获取工作流模板内容的json对象;
|
||||
WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
|
||||
{
|
||||
schemeContent = schemeContentJson.SchemeContent.Value,
|
||||
currentNodeId = "",
|
||||
frmData = frmData,
|
||||
processId = WFProcessScheme.Id
|
||||
};
|
||||
IWF_Runtime wfruntime = null;
|
||||
|
||||
if (frmData == null)
|
||||
{
|
||||
throw new Exception("自定义表单需要提交表单数据");
|
||||
}
|
||||
else
|
||||
{
|
||||
wfruntime = new WF_Runtime(wfRuntimeInitModel);
|
||||
}
|
||||
|
||||
|
||||
#region 实例信息
|
||||
WFProcessInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
|
||||
WFProcessInstance.ActivityType = wfruntime.GetStatus();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
|
||||
WFProcessInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
|
||||
WFProcessInstance.PreviousId = wfruntime.runtimeModel.currentNodeId;
|
||||
WFProcessInstance.EnabledMark = 1;//正式运行
|
||||
WFProcessInstance.MakerList = (wfruntime.GetStatus() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
|
||||
WFProcessInstance.IsFinish = (wfruntime.GetStatus() == 4 ? 1 : 0);
|
||||
#endregion
|
||||
|
||||
#region 实例模板
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = schemeContentJson.SchemeContent.Value,
|
||||
frmData = frmData
|
||||
};
|
||||
WFProcessScheme.ProcessType = 1;//1正式,0草稿
|
||||
WFProcessScheme.SchemeContent = data.ToJson().ToString();
|
||||
#endregion
|
||||
|
||||
#region 流程操作记录
|
||||
WFProcessOperationHistory processOperationHistoryEntity = new WFProcessOperationHistory();
|
||||
processOperationHistoryEntity.Content = "【创建】" + "todo name" + "创建了一个流程进程【" + WFProcessInstance.Code + "/" + WFProcessInstance.CustomName + "】";
|
||||
#endregion
|
||||
|
||||
#region 流转记录
|
||||
WFProcessTransitionHistory processTransitionHistoryEntity = new WFProcessTransitionHistory();
|
||||
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId;
|
||||
processTransitionHistoryEntity.FromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
|
||||
processTransitionHistoryEntity.FromNodeType = wfruntime.runtimeModel.currentNodeType;
|
||||
processTransitionHistoryEntity.ToNodeId = wfruntime.runtimeModel.nextNodeId;
|
||||
processTransitionHistoryEntity.ToNodeName = wfruntime.runtimeModel.nextNode.name.Value;
|
||||
processTransitionHistoryEntity.ToNodeType = wfruntime.runtimeModel.nextNodeType;
|
||||
processTransitionHistoryEntity.TransitionSate = 0;
|
||||
processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
|
||||
#endregion
|
||||
|
||||
#region 委托记录
|
||||
//List<WFDelegateRecord> delegateRecordEntitylist = GetDelegateRecordList(WFProcessScheme.SchemeInfoId, WFProcessInstance.Code, WFProcessInstance.CustomName, WFProcessInstance.MakerList);
|
||||
//WFProcessInstance.MakerList += delegateUserList;
|
||||
#endregion
|
||||
|
||||
wfProcessInstanceService.SaveProcess(wfruntime.runtimeModel, WFProcessInstance, WFProcessScheme, processOperationHistoryEntity, processTransitionHistoryEntity);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 编辑表单再次提交(驳回后处理)
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="frmData"></param>
|
||||
/// <returns></returns>
|
||||
public bool EditionInstance(Guid processId, string description, string frmData = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance WFProcessInstance = wfProcessInstanceService.GetEntity(processId);
|
||||
WFProcessScheme WFProcessScheme = _unitWork.FindSingle< WFProcessScheme>(u =>u.Id ==WFProcessInstance.ProcessSchemeId);
|
||||
dynamic schemeContentJson = WFProcessScheme.SchemeContent.ToJson();//获取工作流模板内容的json对象;
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = schemeContentJson.SchemeContent.Value,
|
||||
frmData = frmData
|
||||
};
|
||||
WFProcessScheme.SchemeContent = data.ToJson().ToString();
|
||||
|
||||
WFProcessInstance.IsFinish = 0;
|
||||
if (string.IsNullOrEmpty(description))
|
||||
{
|
||||
WFProcessInstance.Description = description;
|
||||
}
|
||||
WFProcessInstance.CreateDate = DateTime.Now;
|
||||
|
||||
#region 流程操作记录
|
||||
WFProcessOperationHistory processOperationHistoryEntity = new WFProcessOperationHistory();
|
||||
processOperationHistoryEntity.Content = "【创建】" + "todo name" + "创建了一个流程进程【" + WFProcessInstance.Code + "/" + WFProcessInstance.CustomName + "】";
|
||||
#endregion
|
||||
|
||||
#region 委托记录
|
||||
//List<WFDelegateRecord> delegateRecordEntitylist = GetDelegateRecordList(WFProcessScheme.SchemeInfoId, WFProcessInstance.Code, WFProcessInstance.CustomName, WFProcessInstance.MakerList);
|
||||
//WFProcessInstance.MakerList += delegateUserList;
|
||||
#endregion
|
||||
|
||||
wfProcessInstanceService.SaveProcess(WFProcessInstance, WFProcessScheme, processOperationHistoryEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建一个草稿
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <param name="schemeInfoId"></param>
|
||||
/// <param name="wfLevel"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="customName"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="frmData"></param>
|
||||
/// <returns></returns>
|
||||
public bool CreateRoughdraft(Guid processId, Guid schemeInfoId, WFProcessInstance WFProcessInstance, string frmData = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFSchemeInfo WFSchemeInfo = _unitWork.FindSingle<WFSchemeInfo>(u =>u.Id ==schemeInfoId);
|
||||
WFSchemeContent WFSchemeContent = _unitWork.FindSingle<WFSchemeContent>(u =>u.SchemeInfoId ==schemeInfoId
|
||||
&& u.SchemeVersion ==WFSchemeInfo.SchemeVersion);
|
||||
|
||||
WFProcessInstance.ActivityId = "";
|
||||
WFProcessInstance.ActivityName = "";
|
||||
WFProcessInstance.ActivityType = 0;//开始节点
|
||||
WFProcessInstance.IsFinish = 0;
|
||||
WFProcessInstance.SchemeType = WFSchemeInfo.SchemeType;
|
||||
WFProcessInstance.EnabledMark = 3;//草稿
|
||||
WFProcessInstance.CreateDate = DateTime.Now;
|
||||
WFProcessInstance.FrmType = WFSchemeInfo.FrmType;
|
||||
|
||||
WFProcessScheme WFProcessScheme = new WFProcessScheme();
|
||||
WFProcessScheme.SchemeInfoId = schemeInfoId;
|
||||
WFProcessScheme.SchemeVersion = WFSchemeInfo.SchemeVersion;
|
||||
WFProcessScheme.ProcessType = WFProcessInstance.EnabledMark;
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = WFSchemeContent.SchemeContent,
|
||||
frmData = frmData
|
||||
};
|
||||
WFProcessScheme.SchemeContent = data.ToJson();
|
||||
|
||||
wfProcessInstanceService.SaveProcess(processId,WFProcessInstance, WFProcessScheme);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建一个草稿
|
||||
/// </summary>
|
||||
/// <param name="WFProcessInstance"></param>
|
||||
/// <param name="frmData"></param>
|
||||
/// <returns></returns>
|
||||
public bool EditionRoughdraft(WFProcessInstance WFProcessInstance, string frmData = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessScheme WFProcessScheme = _unitWork.FindSingle<WFProcessScheme>(u =>u.Id ==WFProcessInstance.ProcessSchemeId);
|
||||
dynamic schemeContentJson = WFProcessScheme.SchemeContent.ToJson();//获取工作流模板内容的json对象;
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = schemeContentJson.SchemeContent.Value,
|
||||
frmData = frmData
|
||||
};
|
||||
WFProcessScheme.SchemeContent = data.ToJson().ToString();
|
||||
WFProcessInstance.IsFinish = 0;
|
||||
WFProcessInstance.CreateDate = DateTime.Now;
|
||||
wfProcessInstanceService.SaveProcess(WFProcessInstance.Id,WFProcessInstance, WFProcessScheme);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 节点审核
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <returns></returns>
|
||||
public bool NodeVerification(Guid processId, bool flag, string description = "")
|
||||
{
|
||||
bool _res = false;
|
||||
try
|
||||
{
|
||||
string _sqlstr="", _dbbaseId="";
|
||||
WFProcessInstance WFProcessInstance = wfProcessInstanceService.GetEntity(processId);
|
||||
WFProcessScheme WFProcessScheme = _unitWork.FindSingle<WFProcessScheme>(u =>u.Id ==WFProcessInstance.ProcessSchemeId);
|
||||
WFProcessOperationHistory WFProcessOperationHistory = new WFProcessOperationHistory();//操作记录
|
||||
WFProcessTransitionHistory processTransitionHistoryEntity = null;//流转记录
|
||||
|
||||
dynamic schemeContentJson = WFProcessScheme.SchemeContent.ToJson();//获取工作流模板内容的json对象;
|
||||
WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
|
||||
{
|
||||
schemeContent = schemeContentJson.SchemeContent.Value,
|
||||
currentNodeId = WFProcessInstance.ActivityId,
|
||||
frmData = schemeContentJson.frmData.Value,
|
||||
previousId = WFProcessInstance.PreviousId,
|
||||
processId = processId
|
||||
};
|
||||
IWF_Runtime wfruntime = new WF_Runtime(wfRuntimeInitModel);
|
||||
|
||||
|
||||
#region 会签
|
||||
if (WFProcessInstance.ActivityType == 0)//会签
|
||||
{
|
||||
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1,"");//标记当前节点通过
|
||||
///寻找需要审核的节点Id
|
||||
string _VerificationNodeId = "";
|
||||
List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
|
||||
string _makerList = "";
|
||||
foreach (string item in _nodelist)
|
||||
{
|
||||
_makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.processId);
|
||||
if (_makerList != "-1")
|
||||
{
|
||||
foreach (string one in _makerList.Split(','))
|
||||
{
|
||||
if (AuthUtil.GetUserName() == one || AuthUtil.GetUserName().IndexOf(one) != -1)
|
||||
{
|
||||
_VerificationNodeId = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_VerificationNodeId != "")
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
WFProcessOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodeDictionary[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
|
||||
}
|
||||
else
|
||||
{
|
||||
WFProcessOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodeDictionary[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
|
||||
}
|
||||
|
||||
string _Confluenceres = wfruntime.NodeConfluence(_VerificationNodeId, flag, AuthUtil.GetUserName(), description);
|
||||
var _data = new {
|
||||
SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
|
||||
frmData = (WFProcessInstance.FrmType == 0?wfruntime.runtimeModel.frmData:null)
|
||||
};
|
||||
WFProcessScheme.SchemeContent = _data.ToJson().ToString();
|
||||
switch (_Confluenceres)
|
||||
{
|
||||
case "-1"://不通过
|
||||
WFProcessInstance.IsFinish = 3;
|
||||
break;
|
||||
case "1"://等待
|
||||
break;
|
||||
default://通过
|
||||
WFProcessInstance.PreviousId = WFProcessInstance.ActivityId;
|
||||
WFProcessInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
|
||||
WFProcessInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
|
||||
WFProcessInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
|
||||
WFProcessInstance.IsFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
|
||||
WFProcessInstance.MakerList = (wfruntime.runtimeModel.nextNodeType == 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
|
||||
|
||||
#region 流转记录
|
||||
processTransitionHistoryEntity = new WFProcessTransitionHistory();
|
||||
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId;
|
||||
processTransitionHistoryEntity.FromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
|
||||
processTransitionHistoryEntity.FromNodeType = wfruntime.runtimeModel.currentNodeType;
|
||||
processTransitionHistoryEntity.ToNodeId = wfruntime.runtimeModel.nextNodeId;
|
||||
processTransitionHistoryEntity.ToNodeName = wfruntime.runtimeModel.nextNode.name.Value;
|
||||
processTransitionHistoryEntity.ToNodeType = wfruntime.runtimeModel.nextNodeType;
|
||||
processTransitionHistoryEntity.TransitionSate = 0;
|
||||
processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
if (wfruntime.runtimeModel.currentNode.setInfo != null && wfruntime.runtimeModel.currentNode.setInfo.NodeSQL != null)
|
||||
{
|
||||
_sqlstr = wfruntime.runtimeModel.currentNode.setInfo.NodeSQL.Value;
|
||||
_dbbaseId = wfruntime.runtimeModel.currentNode.setInfo.NodeDataBaseToSQL.Value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw(new Exception("审核异常,找不到审核节点"));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 一般审核
|
||||
else//一般审核
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1, AuthUtil.GetUserName(), description);
|
||||
WFProcessInstance.PreviousId = WFProcessInstance.ActivityId;
|
||||
WFProcessInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
|
||||
WFProcessInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
|
||||
WFProcessInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
|
||||
WFProcessInstance.MakerList = (wfruntime.runtimeModel.nextNodeType == 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
|
||||
WFProcessInstance.IsFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
|
||||
#region 流转记录
|
||||
processTransitionHistoryEntity = new WFProcessTransitionHistory();
|
||||
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId;
|
||||
processTransitionHistoryEntity.FromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
|
||||
processTransitionHistoryEntity.FromNodeType = wfruntime.runtimeModel.currentNodeType;
|
||||
processTransitionHistoryEntity.ToNodeId = wfruntime.runtimeModel.nextNodeId;
|
||||
processTransitionHistoryEntity.ToNodeName = wfruntime.runtimeModel.nextNode.name.Value;
|
||||
processTransitionHistoryEntity.ToNodeType = wfruntime.runtimeModel.nextNodeType;
|
||||
processTransitionHistoryEntity.TransitionSate = 0;
|
||||
processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
if (wfruntime.runtimeModel.currentNode.setInfo != null && wfruntime.runtimeModel.currentNode.setInfo.NodeSQL != null)
|
||||
{
|
||||
_sqlstr = wfruntime.runtimeModel.currentNode.setInfo.NodeSQL.Value;
|
||||
_dbbaseId = wfruntime.runtimeModel.currentNode.setInfo.NodeDataBaseToSQL.Value;
|
||||
}
|
||||
|
||||
WFProcessOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
|
||||
}
|
||||
else
|
||||
{
|
||||
WFProcessInstance.IsFinish = 3; //表示该节点不同意
|
||||
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, -1, AuthUtil.GetUserName(), description);
|
||||
|
||||
WFProcessOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
|
||||
}
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
|
||||
frmData = (WFProcessInstance.FrmType == 0 ? wfruntime.runtimeModel.frmData : null)
|
||||
};
|
||||
WFProcessScheme.SchemeContent = data.ToJson().ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
_res = true;
|
||||
wfProcessInstanceService.SaveProcess(_sqlstr, _dbbaseId,WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
|
||||
return _res;
|
||||
}
|
||||
catch {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 驳回
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <returns></returns>
|
||||
public bool NodeReject(Guid processId,string nodeId, string description = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
WFProcessInstance WFProcessInstance = wfProcessInstanceService.GetEntity(processId);
|
||||
WFProcessScheme WFProcessScheme = _unitWork.FindSingle<WFProcessScheme>(u =>u.Id ==WFProcessInstance.ProcessSchemeId);
|
||||
WFProcessOperationHistory WFProcessOperationHistory = new WFProcessOperationHistory();
|
||||
WFProcessTransitionHistory processTransitionHistoryEntity = null;
|
||||
dynamic schemeContentJson = WFProcessScheme.SchemeContent.ToJson();//获取工作流模板内容的json对象;
|
||||
WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
|
||||
{
|
||||
schemeContent = schemeContentJson.SchemeContent.Value,
|
||||
currentNodeId = WFProcessInstance.ActivityId,
|
||||
frmData = schemeContentJson.frmData.Value,
|
||||
previousId = WFProcessInstance.PreviousId,
|
||||
processId = processId
|
||||
};
|
||||
IWF_Runtime wfruntime = new WF_Runtime(wfRuntimeInitModel);
|
||||
|
||||
|
||||
string resnode = "";
|
||||
if (nodeId == "")
|
||||
{
|
||||
resnode = wfruntime.RejectNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
resnode = nodeId;
|
||||
}
|
||||
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 0, AuthUtil.GetUserName(), description);
|
||||
WFProcessInstance.IsFinish = 4;//4表示驳回(需要申请者重新提交表单)
|
||||
if (resnode != "")
|
||||
{
|
||||
WFProcessInstance.PreviousId = WFProcessInstance.ActivityId;
|
||||
WFProcessInstance.ActivityId = resnode;
|
||||
WFProcessInstance.ActivityType = wfruntime.GetNodeStatus(resnode);//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
|
||||
WFProcessInstance.ActivityName = wfruntime.runtimeModel.nodeDictionary[resnode].name;
|
||||
WFProcessInstance.MakerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[resnode], WFProcessInstance.PreviousId);//当前节点可执行的人信息
|
||||
#region 流转记录
|
||||
processTransitionHistoryEntity = new WFProcessTransitionHistory();
|
||||
processTransitionHistoryEntity.FromNodeId = wfruntime.runtimeModel.currentNodeId;
|
||||
processTransitionHistoryEntity.FromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
|
||||
processTransitionHistoryEntity.FromNodeType = wfruntime.runtimeModel.currentNodeType;
|
||||
processTransitionHistoryEntity.ToNodeId = wfruntime.runtimeModel.nextNodeId;
|
||||
processTransitionHistoryEntity.ToNodeName = wfruntime.runtimeModel.nextNode.name.Value;
|
||||
processTransitionHistoryEntity.ToNodeType = wfruntime.runtimeModel.nextNodeType;
|
||||
processTransitionHistoryEntity.TransitionSate = 1;//
|
||||
processTransitionHistoryEntity.IsFinish = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
|
||||
#endregion
|
||||
}
|
||||
var data = new
|
||||
{
|
||||
SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
|
||||
frmData = (WFProcessInstance.FrmType == 0 ? wfruntime.runtimeModel.frmData : null)
|
||||
};
|
||||
WFProcessScheme.SchemeContent = data.ToJson().ToString();
|
||||
WFProcessOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + description;
|
||||
|
||||
wfProcessInstanceService.SaveProcess(WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 召回流程进程
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
public void CallingBackProcess(Guid processId)
|
||||
{
|
||||
try
|
||||
{
|
||||
wfProcessInstanceService.OperateVirtualProcess(processId,2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 终止一个实例(彻底删除)
|
||||
/// </summary>
|
||||
/// <param name="processId"></param>
|
||||
/// <returns></returns>
|
||||
public void KillProcess(Guid processId)
|
||||
{
|
||||
try
|
||||
{
|
||||
_unitWork.Delete<WFProcessInstance>(u =>u.Id == processId);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取某个节点(审核人所能看到的提交表单的权限)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public string GetProcessSchemeContentByNodeId(string data, string nodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<dynamic> list = new List<dynamic>();
|
||||
dynamic schemeContentJson = data.ToJson();//获取工作流模板内容的json对象;
|
||||
string schemeContent1 = schemeContentJson.SchemeContent.Value;
|
||||
dynamic schemeContentJson1 = schemeContent1.ToJson();
|
||||
string FrmContent = schemeContentJson1.Frm.FrmContent.Value;
|
||||
dynamic FrmContentJson = FrmContent.ToJson();
|
||||
|
||||
foreach (var item in schemeContentJson1.Flow.nodes)
|
||||
{
|
||||
if (item.id.Value == nodeId)
|
||||
{
|
||||
foreach (var item1 in item.setInfo.frmPermissionInfo)
|
||||
{
|
||||
foreach (var item2 in FrmContentJson)
|
||||
{
|
||||
if (item2.control_field.Value == item1.fieldid.Value)
|
||||
{
|
||||
if (item1.look.Value == true)
|
||||
{
|
||||
if (item1.down != null)
|
||||
{
|
||||
item2.down = item1.down.Value;
|
||||
}
|
||||
list.Add(item2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
schemeContentJson1.Frm.FrmContent = list.ToJson().ToString();
|
||||
schemeContentJson.SchemeContent = schemeContentJson1.ToString();
|
||||
return schemeContentJson.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取某个节点(审核人所能看到的提交表单的权限)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetProcessSchemeContentByUserId(string data, string userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<dynamic> list = new List<dynamic>();
|
||||
dynamic schemeContentJson = data.ToJson();//获取工作流模板内容的json对象;
|
||||
string schemeContent1 = schemeContentJson.SchemeContent.Value;
|
||||
dynamic schemeContentJson1 = schemeContent1.ToJson();
|
||||
string FrmContent = schemeContentJson1.Frm.FrmContent.Value;
|
||||
dynamic FrmContentJson = FrmContent.ToJson();
|
||||
|
||||
foreach (var item in schemeContentJson1.Flow.nodes)
|
||||
{
|
||||
if (item.setInfo != null && item.setInfo.UserId != null && item.setInfo.UserId.Value == userId)
|
||||
{
|
||||
foreach (var item1 in item.setInfo.frmPermissionInfo)
|
||||
{
|
||||
foreach (var item2 in FrmContentJson)
|
||||
{
|
||||
if (item2.control_field.Value == item1.fieldid.Value)
|
||||
{
|
||||
if (item1.look.Value == true)
|
||||
{
|
||||
if (item1.down != null)
|
||||
{
|
||||
item2.down = item1.down.Value;
|
||||
}
|
||||
list.Add(item2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
schemeContentJson1.Frm.FrmContent = list.ToJson().ToString();
|
||||
schemeContentJson.SchemeContent = schemeContentJson1.ToString();
|
||||
return schemeContentJson.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 寻找该节点执行人
|
||||
/// </summary>
|
||||
/// <param name="wfruntime"></param>
|
||||
/// <returns></returns>
|
||||
private string GetMakerList(IWF_Runtime wfruntime)
|
||||
{
|
||||
try
|
||||
{
|
||||
string makerList = "";
|
||||
if (wfruntime.runtimeModel.nextNodeId == "-1")
|
||||
{
|
||||
throw (new Exception("无法寻找到下一个节点"));
|
||||
}
|
||||
if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
|
||||
{
|
||||
List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.nextNodeId);
|
||||
string _makerList = "";
|
||||
foreach (string item in _nodelist)
|
||||
{
|
||||
_makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.processId);
|
||||
if (_makerList == "-1")
|
||||
{
|
||||
throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!"));
|
||||
}
|
||||
else if (_makerList == "1")
|
||||
{
|
||||
throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (makerList != "")
|
||||
{
|
||||
makerList += ",";
|
||||
}
|
||||
makerList += _makerList;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
makerList = GetMakerList(wfruntime.runtimeModel.nextNode, wfruntime.runtimeModel.processId);
|
||||
if (makerList == "-1")
|
||||
{
|
||||
throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
|
||||
}
|
||||
}
|
||||
|
||||
return makerList;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 寻找该节点执行人
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
private string GetMakerList(dynamic node, string processId)
|
||||
{
|
||||
try
|
||||
{
|
||||
string makerlsit = "";
|
||||
|
||||
if (node.setInfo == null)
|
||||
{
|
||||
makerlsit = "-1";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (node.setInfo.NodeDesignate.Value == "NodeDesignateType1")//所有成员
|
||||
{
|
||||
makerlsit = "1";
|
||||
}
|
||||
else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType2")//指定成员
|
||||
{
|
||||
makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.role, makerlsit);
|
||||
makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.post, makerlsit);
|
||||
makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.usergroup, makerlsit);
|
||||
makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.user, makerlsit);
|
||||
|
||||
if (makerlsit == "")
|
||||
{
|
||||
makerlsit = "-1";
|
||||
}
|
||||
}
|
||||
//else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType3")//发起者领导
|
||||
//{
|
||||
// UserEntity userEntity = userService.GetEntity(OperatorProvider.Provider.Current().UserId);
|
||||
// if (string.IsNullOrEmpty(userEntity.ManagerId))
|
||||
// {
|
||||
// makerlsit = "-1";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// makerlsit = userEntity.ManagerId;
|
||||
// }
|
||||
//}
|
||||
//else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType4")//前一步骤领导
|
||||
//{
|
||||
// WFProcessTransitionHistory transitionHistoryEntity = wfProcessTransitionHistoryService.GetEntity(processId, node.id.Value);
|
||||
// UserEntity userEntity = userService.GetEntity(transitionHistoryEntity.CreateUserId);
|
||||
// if (string.IsNullOrEmpty(userEntity.ManagerId))
|
||||
// {
|
||||
// makerlsit = "-1";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// makerlsit = userEntity.ManagerId;
|
||||
// }
|
||||
//}
|
||||
//else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType5")//发起者部门领导
|
||||
//{
|
||||
// UserEntity userEntity = userService.GetEntity(OperatorProvider.Provider.Current().UserId);
|
||||
// DepartmentEntity departmentEntity = departmentService.GetEntity(userEntity.DepartmentId);
|
||||
|
||||
// if (string.IsNullOrEmpty(departmentEntity.ManagerId))
|
||||
// {
|
||||
// makerlsit = "-1";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// makerlsit = departmentEntity.ManagerId;
|
||||
// }
|
||||
//}
|
||||
//else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType6")//发起者公司领导
|
||||
//{
|
||||
// UserEntity userEntity = userService.GetEntity(OperatorProvider.Provider.Current().UserId);
|
||||
// OrganizeEntity organizeEntity = organizeService.GetEntity(userEntity.OrganizeId);
|
||||
|
||||
// if (string.IsNullOrEmpty(organizeEntity.ManagerId))
|
||||
// {
|
||||
// makerlsit = "-1";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// makerlsit = organizeEntity.ManagerId;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
return makerlsit;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 将数组转化成逗号相隔的字串
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="Str"></param>
|
||||
/// <returns></returns>
|
||||
private string ArrwyToString(dynamic data, string Str)
|
||||
{
|
||||
string resStr = Str;
|
||||
foreach (var item in data)
|
||||
{
|
||||
if (resStr != "")
|
||||
{
|
||||
resStr += ",";
|
||||
}
|
||||
resStr += item.Value;
|
||||
}
|
||||
return resStr;
|
||||
}
|
||||
|
||||
public WFProcessScheme GetProcessSchemeEntity(Guid keyValue)
|
||||
{
|
||||
return _unitWork.FindSingle<WFProcessScheme>(u => u.Id == keyValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 已办流程进度查看,根据当前访问人的权限查看表单内容
|
||||
/// <para>李玉宝于2017-01-20 15:35:13</para>
|
||||
/// </summary>
|
||||
/// <param name="keyValue">The key value.</param>
|
||||
/// <returns>WFProcessScheme.</returns>
|
||||
public WFProcessScheme GetProcessSchemeByUserId(Guid keyValue)
|
||||
{
|
||||
var entity = GetProcessSchemeEntity(keyValue);
|
||||
entity.SchemeContent = GetProcessSchemeContentByUserId(entity.SchemeContent, AuthUtil.GetCurrentUser().User.Id.ToString());
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 已办流程进度查看,根据当前节点的权限查看表单内容
|
||||
/// <para>李玉宝于2017-01-20 15:34:35</para>
|
||||
/// </summary>
|
||||
/// <param name="keyValue">The key value.</param>
|
||||
/// <param name="nodeId">The node identifier.</param>
|
||||
/// <returns>WFProcessScheme.</returns>
|
||||
public WFProcessScheme GetProcessSchemeEntityByNodeId(Guid keyValue, string nodeId)
|
||||
{
|
||||
var entity = GetProcessSchemeEntity(keyValue);
|
||||
entity.SchemeContent = GetProcessSchemeContentByNodeId(entity.SchemeContent, nodeId);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public WFProcessInstance GetProcessInstanceEntity(Guid keyValue)
|
||||
{
|
||||
return _unitWork.FindSingle<WFProcessInstance>(u => u.Id == keyValue);
|
||||
}
|
||||
|
||||
public void DeleteProcess(Guid keyValue)
|
||||
{
|
||||
var entity = _unitWork.FindSingle<WFProcessInstance>(u => u.Id == keyValue);
|
||||
_unitWork.Delete<WFProcessScheme>(u =>u.Id == entity.ProcessSchemeId);
|
||||
_unitWork.Delete<WFProcessInstance>(u =>u.Id == keyValue);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 审核流程
|
||||
/// <para>李玉宝于2017-01-20 15:44:45</para>
|
||||
/// </summary>
|
||||
/// <param name="processId">The process identifier.</param>
|
||||
/// <param name="verificationData">The verification data.</param>
|
||||
public void VerificationProcess(Guid processId, string verificationData)
|
||||
{
|
||||
try
|
||||
{
|
||||
dynamic verificationDataJson = verificationData.ToJson();
|
||||
|
||||
//驳回
|
||||
if (verificationDataJson.VerificationFinally.Value == "3")
|
||||
{
|
||||
string _nodeId = "";
|
||||
if (verificationDataJson.NodeRejectStep != null)
|
||||
{
|
||||
_nodeId = verificationDataJson.NodeRejectStep.Value;
|
||||
}
|
||||
NodeReject(processId, _nodeId, verificationDataJson.VerificationOpinion.Value);
|
||||
}
|
||||
else if (verificationDataJson.VerificationFinally.Value == "2")//表示不同意
|
||||
{
|
||||
NodeVerification(processId, false, verificationDataJson.VerificationOpinion.Value);
|
||||
}
|
||||
else if (verificationDataJson.VerificationFinally.Value == "1")//表示同意
|
||||
{
|
||||
NodeVerification(processId, true, verificationDataJson.VerificationOpinion.Value);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user