diff --git a/OpenAuth.App/Extention/WF_Runtime.cs b/OpenAuth.App/Extention/WF_Runtime.cs
index f0af7efa..395e1247 100644
--- a/OpenAuth.App/Extention/WF_Runtime.cs
+++ b/OpenAuth.App/Extention/WF_Runtime.cs
@@ -1,689 +1,689 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Infrastructure;
-
-namespace OpenAuth.App.Extention
-{
- public class WF_Runtime : IWF_Runtime
- {
- private WF_RuntimeModel _runtimeModel = null;
-
- private GetFrmData _getFrmData = null;
- ///
- /// 构造函数
- ///
- /// 流程模板
- /// 当前节点
- /// 表单数据
- 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 私有方法
- ///
- /// 获取工作流节点的字典列表:key节点id
- ///
- ///
- ///
- private Dictionary GetNodeDictionary(dynamic schemeContentJson)
- {
- Dictionary nodeDictionary = new Dictionary();
- 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;
- }
- ///
- /// 获取工作流线段的字典列表:key开始节点id,value线条实体列表
- ///
- ///
- ///
- private Dictionary> GetLineDictionary(dynamic schemeContentJson)
- {
- Dictionary> lineDictionary = new Dictionary>();
- foreach (var item in schemeContentJson.Flow.lines)
- {
- if (!lineDictionary.ContainsKey(item.from.Value))
- {
- List d = new List();
- d.Add(item);
- lineDictionary.Add(item.from.Value, d);
- }
- else
- {
- lineDictionary[item.from.Value].Add(item);
- }
- }
- return lineDictionary;
- }
- ///
- /// 获取工作流线段的字典列表:key开始节点id,value线条实体列表
- ///
- ///
- ///
- private Dictionary> GetToLineDictionary(dynamic schemeContentJson)
- {
- Dictionary> lineDictionary = new Dictionary>();
- foreach (var item in schemeContentJson.Flow.lines)
- {
- if (!lineDictionary.ContainsKey(item.to.Value))
- {
- List d = new List();
- d.Add(item);
- lineDictionary.Add(item.to.Value, d);
- }
- else
- {
- lineDictionary[item.to.Value].Add(item);
- }
- }
- return lineDictionary;
- }
- ///
- /// 工作流流转条件比较函数
- ///
- /// 表单数据
- ///
- ///
- ///
- 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;
- }
-
- ///
- /// 获取SQL语句
- ///
- ///
- ///
- ///
- private string SqlBuider(dynamic schemeContentJson, string frmData, string keyValue)
- {
- return "";
- 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;
- }
- }
- ///
- /// 系统表单获取表单数据
- ///
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 获取下一个节点
- ///
- /// 表单数据(用于判断流转条件)
- private string GetNextNode(string frmData,string nodeId = null)
- {
- try
- {
- List 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
- ///
- /// 工作流实例运行信息
- ///
- ///
- public WF_RuntimeModel runtimeModel
- {
- get { return _runtimeModel; }
- }
- ///
- /// 获取实例接下来运行的状态
- ///
- /// -1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
- 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;
- }
- }
- ///
- /// 获取节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 获取会签下面需要审核的ID列表
- ///
- ///
- ///
- public List GetCountersigningNodeIdList(string shuntnodeId)
- {
- try
- {
- List list = new List();
-
- List listline = _runtimeModel.lineDictionary[shuntnodeId];
-
- foreach (var item in listline)
- {
- list.Add(item.to.Value);
- }
-
- return list;
- }
- catch
- {
- throw;
- }
- }
- ///
- /// 通过节点Id获取下一个节点Id
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 节点会签审核
- ///
- ///
- ///
- /// -1不通过,1等待,其它通过
- 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> 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所有步骤通过 todo:先用空格
- {
- 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") //则时res是会签结束节点的ID
- {
- MakeTagNode(_nextNodeId, 1, userId);
- _runtimeModel.nextNodeId = res;
- _runtimeModel.nextNodeType = GetNodeStatus(res);
- }
- else
- {
- _runtimeModel.nextNodeId = _nextNodeId;
- _runtimeModel.nextNodeType = GetNodeStatus(_nextNodeId);
- }
- return res;
- }
- else
- {
- throw (new Exception("寻找不到会签下合流节点"));
- }
- }
- catch
- {
- throw;
- }
- }
- ///
- /// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
- ///
- ///
- public string RejectNode()
- {
- return RejectNode(_runtimeModel.currentNodeId);
- }
- ///
- /// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
- ///
- ///
- ///
- 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驳回
- ///
- ///
- ///
- ///
- ///
- 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
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Infrastructure;
+
+namespace OpenAuth.App.Extention
+{
+ public class WF_Runtime : IWF_Runtime
+ {
+ private WF_RuntimeModel _runtimeModel = null;
+
+ private GetFrmData _getFrmData = null;
+ ///
+ /// 构造函数
+ ///
+ /// 流程模板
+ /// 当前节点
+ /// 表单数据
+ 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 私有方法
+ ///
+ /// 获取工作流节点的字典列表:key节点id
+ ///
+ ///
+ ///
+ private Dictionary GetNodeDictionary(dynamic schemeContentJson)
+ {
+ Dictionary nodeDictionary = new Dictionary();
+ 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;
+ }
+ ///
+ /// 获取工作流线段的字典列表:key开始节点id,value线条实体列表
+ ///
+ ///
+ ///
+ private Dictionary> GetLineDictionary(dynamic schemeContentJson)
+ {
+ Dictionary> lineDictionary = new Dictionary>();
+ foreach (var item in schemeContentJson.Flow.lines)
+ {
+ if (!lineDictionary.ContainsKey(item.from.Value))
+ {
+ List d = new List();
+ d.Add(item);
+ lineDictionary.Add(item.from.Value, d);
+ }
+ else
+ {
+ lineDictionary[item.from.Value].Add(item);
+ }
+ }
+ return lineDictionary;
+ }
+ ///
+ /// 获取工作流线段的字典列表:key开始节点id,value线条实体列表
+ ///
+ ///
+ ///
+ private Dictionary> GetToLineDictionary(dynamic schemeContentJson)
+ {
+ Dictionary> lineDictionary = new Dictionary>();
+ foreach (var item in schemeContentJson.Flow.lines)
+ {
+ if (!lineDictionary.ContainsKey(item.to.Value))
+ {
+ List d = new List();
+ d.Add(item);
+ lineDictionary.Add(item.to.Value, d);
+ }
+ else
+ {
+ lineDictionary[item.to.Value].Add(item);
+ }
+ }
+ return lineDictionary;
+ }
+ ///
+ /// 工作流流转条件比较函数
+ ///
+ /// 表单数据
+ ///
+ ///
+ ///
+ 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;
+ }
+
+ ///
+ /// 获取SQL语句
+ ///
+ ///
+ ///
+ ///
+ private string SqlBuider(dynamic schemeContentJson, string frmData, string keyValue)
+ {
+ return "";
+ 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;
+ }
+ }
+ ///
+ /// 系统表单获取表单数据
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 获取下一个节点
+ ///
+ /// 表单数据(用于判断流转条件)
+ private string GetNextNode(string frmData,string nodeId = null)
+ {
+ try
+ {
+ List 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
+ ///
+ /// 工作流实例运行信息
+ ///
+ ///
+ public WF_RuntimeModel runtimeModel
+ {
+ get { return _runtimeModel; }
+ }
+ ///
+ /// 获取实例接下来运行的状态
+ ///
+ /// -1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
+ 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;
+ }
+ }
+ ///
+ /// 获取节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 获取会签下面需要审核的ID列表
+ ///
+ ///
+ ///
+ public List GetCountersigningNodeIdList(string shuntnodeId)
+ {
+ try
+ {
+ List list = new List();
+
+ List listline = _runtimeModel.lineDictionary[shuntnodeId];
+
+ foreach (var item in listline)
+ {
+ list.Add(item.to.Value);
+ }
+
+ return list;
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ ///
+ /// 通过节点Id获取下一个节点Id
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 节点会签审核
+ ///
+ ///
+ ///
+ /// -1不通过,1等待,其它通过
+ 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> 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所有步骤通过 todo:先用空格
+ {
+ 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") //则时res是会签结束节点的ID
+ {
+ MakeTagNode(_nextNodeId, 1, userId);
+ _runtimeModel.nextNodeId = res;
+ _runtimeModel.nextNodeType = GetNodeStatus(res);
+ }
+ else
+ {
+ _runtimeModel.nextNodeId = _nextNodeId;
+ _runtimeModel.nextNodeType = GetNodeStatus(_nextNodeId);
+ }
+ return res;
+ }
+ else
+ {
+ throw (new Exception("寻找不到会签下合流节点"));
+ }
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ ///
+ /// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
+ ///
+ ///
+ public string RejectNode()
+ {
+ return RejectNode(_runtimeModel.currentNodeId);
+ }
+ ///
+ /// 驳回节点0"前一步"1"第一步"2"某一步" 3"不处理"
+ ///
+ ///
+ ///
+ 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驳回
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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
+ }
+}
diff --git a/OpenAuth.App/SSO/PassportLoginRequest.cs b/OpenAuth.App/SSO/PassportLoginRequest.cs
index f2526f84..4f2e0e7c 100644
--- a/OpenAuth.App/SSO/PassportLoginRequest.cs
+++ b/OpenAuth.App/SSO/PassportLoginRequest.cs
@@ -1,30 +1,30 @@
-using System;
-
-namespace OpenAuth.App.SSO
-{
-
- public class PassportLoginRequest
- {
- public string UserName { get; set; }
-
- public string Password { get; set; }
-
- public string AppKey { get; set; }
-
- public void Trim()
- {
- if (string.IsNullOrEmpty(UserName))
- {
- throw new Exception("用户名不能为空");
- }
-
- if (string.IsNullOrEmpty(Password))
- {
- throw new Exception("密码不能为空");
- }
- UserName = UserName.Trim();
- Password = Password.Trim();
- if(!string.IsNullOrEmpty(AppKey)) AppKey = AppKey.Trim();
- }
- }
+using System;
+
+namespace OpenAuth.App.SSO
+{
+
+ public class PassportLoginRequest
+ {
+ public string UserName { get; set; }
+
+ public string Password { get; set; }
+
+ public string AppKey { get; set; }
+
+ public void Trim()
+ {
+ if (string.IsNullOrEmpty(UserName))
+ {
+ throw new Exception("用户名不能为空");
+ }
+
+ if (string.IsNullOrEmpty(Password))
+ {
+ throw new Exception("密码不能为空");
+ }
+ UserName = UserName.Trim();
+ Password = Password.Trim();
+ if(!string.IsNullOrEmpty(AppKey)) AppKey = AppKey.Trim();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenAuth.App/SSO/SSOAuthUtil.cs b/OpenAuth.App/SSO/SSOAuthUtil.cs
index 242a5edd..7b38abd0 100644
--- a/OpenAuth.App/SSO/SSOAuthUtil.cs
+++ b/OpenAuth.App/SSO/SSOAuthUtil.cs
@@ -1,78 +1,78 @@
-using System;
-using System.Web;
-using System.Web.Mvc;
-using Infrastructure;
-using Infrastructure.Cache;
-using OpenAuth.Domain;
-
-
-
-namespace OpenAuth.App.SSO
-{
- public class SSOAuthUtil
- {
- public static LoginResult Parse(PassportLoginRequest model)
- {
- var result = new LoginResult();
- try
- {
- model.Trim();
- //ȡӦϢ
- var appInfo = new AppInfoService().Get(model.AppKey);
- if (appInfo == null)
- {
- throw new Exception("Ӧò");
- }
- //ȡûϢ
- User userInfo = null;
- if (model.UserName == "System")
- {
- userInfo = new User
- {
- Id = Guid.Empty,
- Account = "System",
- Name ="Ա",
- Password = "123456"
- };
- }
- else
- {
- var usermanager = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
- userInfo = usermanager.Get(model.UserName);
- }
-
- if (userInfo == null)
- {
- throw new Exception("û");
- }
- if (userInfo.Password != model.Password)
- {
- throw new Exception("");
- }
-
- var currentSession = new UserAuthSession
- {
- UserName = model.UserName,
- Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"),
- AppKey = model.AppKey,
- CreateTime = DateTime.Now,
- IpAddress = HttpContext.Current.Request.UserHostAddress
- };
-
- //Session
- new ObjCacheProvider().Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10));
-
- result.Success = true;
- result.ReturnUrl = appInfo.ReturnUrl;
- result.Token = currentSession.Token;
- }
- catch (Exception ex)
- {
- result.Success = false;
- result.ErrorMsg = ex.Message;
- }
-
- return result;
- }
- }
+using System;
+using System.Web;
+using System.Web.Mvc;
+using Infrastructure;
+using Infrastructure.Cache;
+using OpenAuth.Domain;
+
+
+
+namespace OpenAuth.App.SSO
+{
+ public class SSOAuthUtil
+ {
+ public static LoginResult Parse(PassportLoginRequest model)
+ {
+ var result = new LoginResult();
+ try
+ {
+ model.Trim();
+ //ȡӦϢ
+ var appInfo = new AppInfoService().Get(model.AppKey);
+ if (appInfo == null)
+ {
+ throw new Exception("Ӧò");
+ }
+ //ȡûϢ
+ User userInfo = null;
+ if (model.UserName == "System")
+ {
+ userInfo = new User
+ {
+ Id = Guid.Empty,
+ Account = "System",
+ Name ="Ա",
+ Password = "123456"
+ };
+ }
+ else
+ {
+ var usermanager = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
+ userInfo = usermanager.Get(model.UserName);
+ }
+
+ if (userInfo == null)
+ {
+ throw new Exception("û");
+ }
+ if (userInfo.Password != model.Password)
+ {
+ throw new Exception("");
+ }
+
+ var currentSession = new UserAuthSession
+ {
+ UserName = model.UserName,
+ Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"),
+ AppKey = model.AppKey,
+ CreateTime = DateTime.Now,
+ IpAddress = HttpContext.Current.Request.UserHostAddress
+ };
+
+ //Session
+ new ObjCacheProvider().Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10));
+
+ result.Success = true;
+ result.ReturnUrl = appInfo.ReturnUrl;
+ result.Token = currentSession.Token;
+ }
+ catch (Exception ex)
+ {
+ result.Success = false;
+ result.ErrorMsg = ex.Message;
+ }
+
+ return result;
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenAuth.App/WFProcessInstanceService.cs b/OpenAuth.App/WFProcessInstanceService.cs
index 000246e8..3c9ff3cb 100644
--- a/OpenAuth.App/WFProcessInstanceService.cs
+++ b/OpenAuth.App/WFProcessInstanceService.cs
@@ -1,1066 +1,1066 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Infrastructure;
-using OpenAuth.App.Extention;
-using OpenAuth.App.SSO;
-using OpenAuth.App.ViewModel;
-using OpenAuth.Domain;
-using OpenAuth.Domain.Interface;
-
-namespace OpenAuth.App
-{
- ///
- /// 工作流实例表操作
- /// 李玉宝新增于2017-01-16 20:33:48
- ///
- public class WFProcessInstanceService
- {
- protected IUnitWork _unitWork;
-
- public WFProcessInstanceService(IUnitWork unitWork)
- {
- _unitWork = unitWork;
- }
-
- #region 获取数据
- ///
- /// 获取实例进程信息实体
- ///
- ///
- ///
- public WFProcessInstance GetEntity(Guid keyVlaue)
- {
- try
- {
- return _unitWork.FindSingle(u =>u.Id == keyVlaue);
- }
- catch
- {
- throw;
- }
- }
- #endregion
-
- #region 提交数据
- ///
- /// 存储工作流实例进程(编辑草稿用)
- ///
- ///
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 存储工作流实例进程(创建实例进程)
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 存储工作流实例进程(审核驳回重新提交)
- ///
- ///
- ///
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 更新流程实例 审核节点用
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- 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;
- }
- }
-
- ///
- /// 删除工作流实例进程(删除草稿使用)
- ///
- /// 主键
- ///
- public int DeleteProcess(Guid keyValue)
- {
- try
- {
- WFProcessInstance entity = _unitWork.FindSingle(u =>u.Id ==keyValue);
-
- _unitWork.Delete(u =>u.Id == keyValue);
- _unitWork.Delete(u =>u.Id == entity.ProcessSchemeId);
- _unitWork.Save();
- return 1;
- }
- catch {
- throw;
- }
- }
- ///
- /// 虚拟操作实例
- ///
- ///
- /// 0暂停,1启用,2取消(召回)
- ///
- public int OperateVirtualProcess(Guid keyValue,int state)
- {
- try
- {
- WFProcessInstance entity = _unitWork.FindSingle(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;
- }
- }
- ///
- /// 流程指派
- ///
- ///
- ///
- 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
- };
-
- var cnt = _unitWork.Find(u => u.CreateUserId == userid).Count();
- if (type == "inbox") //待办事项
- {
- result.total = cnt%pageSize == 0? cnt/pageSize : cnt/pageSize + 1;
- result.rows = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
-
- }
- else if (type == "outbox") //已办事项
- {
- result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
- result.rows = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
-
- }
- else //我的流程
- {
- result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
- result.rows = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
- }
-
- return result;
- }
-
- #region 流程处理API
- ///
- /// 创建一个实例
- ///
- /// 进程GUID
- /// 模板信息ID
- ///
- /// 进程编号
- /// 自定义名称
- /// 备注
- /// 表单数据信息
- ///
- public bool CreateInstance(Guid processId, Guid schemeInfoId, WFProcessInstance WFProcessInstance, string frmData = null)
- {
-
- try
- {
- WFSchemeInfo WFSchemeInfo = _unitWork.FindSingle(u => u.Id == schemeInfoId);
- WFSchemeContent WFSchemeContent = _unitWork.FindSingle(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);
- }
-
-
- var user = AuthUtil.GetCurrentUser();
- #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.CreateUserId = user.User.Id.ToString();
- WFProcessInstance.CreateUserName = user.User.Account;
- 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 = "【创建】" + user.User.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 delegateRecordEntitylist = GetDelegateRecordList(schemeInfoId, WFProcessInstance.Code, WFProcessInstance.CustomName, WFProcessInstance.MakerList);
- //WFProcessInstance.MakerList += delegateUserList;
- #endregion
-
- SaveProcess(wfruntime.runtimeModel, WFProcessInstance, WFProcessScheme, processOperationHistoryEntity, processTransitionHistoryEntity);
-
- return true;
- }
- catch
- {
- throw;
- }
-
- }
-
- ///
- /// 节点审核
- ///
- ///
- ///
- public bool NodeVerification(Guid processId, bool flag, string description = "")
- {
- bool _res = false;
- try
- {
- string _sqlstr = "", _dbbaseId = "";
- WFProcessInstance WFProcessInstance = GetEntity(processId);
- WFProcessScheme WFProcessScheme = _unitWork.FindSingle(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 _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")
- {
- var id = AuthUtil.GetCurrentUser().User.Id.ToString();
- foreach (string one in _makerList.Split(','))
- {
- if (id == one || id.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.GetCurrentUser().User.Id.ToString(), description);
- var _data = new
- {
- SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
- frmData = wfruntime.runtimeModel.frmData
- };
- 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.GetCurrentUser().User.Id.ToString(), 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
- {
- FromNodeId = wfruntime.runtimeModel.currentNodeId,
- FromNodeName = wfruntime.runtimeModel.currentNode.name.Value,
- FromNodeType = wfruntime.runtimeModel.currentNodeType,
- ToNodeId = wfruntime.runtimeModel.nextNodeId,
- ToNodeName = wfruntime.runtimeModel.nextNode.name.Value,
- ToNodeType = wfruntime.runtimeModel.nextNodeType,
- 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 = wfruntime.runtimeModel.frmData
- };
- WFProcessScheme.SchemeContent = data.ToJson();
- }
- #endregion
-
- _res = true;
- SaveProcess(_sqlstr, _dbbaseId, WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
- return _res;
- }
- catch
- {
- throw;
- }
- }
- ///
- /// 驳回
- ///
- ///
- ///
- ///
- ///
- public bool NodeReject(Guid processId, string nodeId, string description = "")
- {
- try
- {
- WFProcessInstance WFProcessInstance = GetEntity(processId);
- WFProcessScheme WFProcessScheme = _unitWork.FindSingle(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;
-
- SaveProcess(WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
- return true;
- }
- catch
- {
- throw;
- }
- }
- ///
- /// 召回流程进程
- ///
- ///
- public void CallingBackProcess(Guid processId)
- {
- try
- {
- OperateVirtualProcess(processId, 2);
- }
- catch
- {
- throw;
- }
- }
- ///
- /// 终止一个实例(彻底删除)
- ///
- ///
- ///
- public void KillProcess(Guid processId)
- {
- try
- {
- _unitWork.Delete(u => u.Id == processId);
- }
- catch
- {
- throw;
- }
- }
- ///
- /// 获取某个节点(审核人所能看到的提交表单的权限)
- ///
- ///
- ///
- public string GetProcessSchemeContentByNodeId(string data, string nodeId)
- {
- try
- {
- List list = new List();
- 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 && item.setInfo != null)
- {
- 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;
- }
- }
- ///
- /// 获取某个节点(审核人所能看到的提交表单的权限)
- ///
- ///
- ///
- ///
- public string GetProcessSchemeContentByUserId(string data, string userId)
- {
- try
- {
- List list = new List();
- 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
-
- ///
- /// 寻找该节点执行人
- ///
- ///
- ///
- private string GetMakerList(IWF_Runtime wfruntime)
- {
- try
- {
- string makerList = "";
- if (wfruntime.runtimeModel.nextNodeId == "-1")
- {
- throw (new Exception("无法寻找到下一个节点"));
- }
- if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
- {
- List _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;
- }
- }
- ///
- /// 寻找该节点执行人
- ///
- ///
- ///
- 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;
- }
- }
- ///
- /// 将数组转化成逗号相隔的字串
- ///
- ///
- ///
- ///
- 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(u => u.Id == keyValue);
- }
-
- ///
- /// 已办流程进度查看,根据当前访问人的权限查看表单内容
- /// 李玉宝于2017-01-20 15:35:13
- ///
- /// The key value.
- /// WFProcessScheme.
- public WFProcessScheme GetProcessSchemeByUserId(Guid keyValue)
- {
- var entity = GetProcessSchemeEntity(keyValue);
- entity.SchemeContent = GetProcessSchemeContentByUserId(entity.SchemeContent, AuthUtil.GetCurrentUser().User.Id.ToString());
- return entity;
- }
-
-
- ///
- /// 已办流程进度查看,根据当前节点的权限查看表单内容
- /// 李玉宝于2017-01-20 15:34:35
- ///
- /// The key value.
- /// The node identifier.
- /// WFProcessScheme.
- 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(u => u.Id == keyValue);
- }
-
- ///
- /// 审核流程
- /// 李玉宝于2017-01-20 15:44:45
- ///
- /// The process identifier.
- /// The verification data.
- 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;
- }
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Infrastructure;
+using OpenAuth.App.Extention;
+using OpenAuth.App.SSO;
+using OpenAuth.App.ViewModel;
+using OpenAuth.Domain;
+using OpenAuth.Domain.Interface;
+
+namespace OpenAuth.App
+{
+ ///
+ /// 工作流实例表操作
+ /// 李玉宝新增于2017-01-16 20:33:48
+ ///
+ public class WFProcessInstanceService
+ {
+ protected IUnitWork _unitWork;
+
+ public WFProcessInstanceService(IUnitWork unitWork)
+ {
+ _unitWork = unitWork;
+ }
+
+ #region 获取数据
+ ///
+ /// 获取实例进程信息实体
+ ///
+ ///
+ ///
+ public WFProcessInstance GetEntity(Guid keyVlaue)
+ {
+ try
+ {
+ return _unitWork.FindSingle(u =>u.Id == keyVlaue);
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ #endregion
+
+ #region 提交数据
+ ///
+ /// 存储工作流实例进程(编辑草稿用)
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 存储工作流实例进程(创建实例进程)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 存储工作流实例进程(审核驳回重新提交)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 更新流程实例 审核节点用
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+
+ ///
+ /// 删除工作流实例进程(删除草稿使用)
+ ///
+ /// 主键
+ ///
+ public int DeleteProcess(Guid keyValue)
+ {
+ try
+ {
+ WFProcessInstance entity = _unitWork.FindSingle(u =>u.Id ==keyValue);
+
+ _unitWork.Delete(u =>u.Id == keyValue);
+ _unitWork.Delete(u =>u.Id == entity.ProcessSchemeId);
+ _unitWork.Save();
+ return 1;
+ }
+ catch {
+ throw;
+ }
+ }
+ ///
+ /// 虚拟操作实例
+ ///
+ ///
+ /// 0暂停,1启用,2取消(召回)
+ ///
+ public int OperateVirtualProcess(Guid keyValue,int state)
+ {
+ try
+ {
+ WFProcessInstance entity = _unitWork.FindSingle(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;
+ }
+ }
+ ///
+ /// 流程指派
+ ///
+ ///
+ ///
+ 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
+ };
+
+ var cnt = _unitWork.Find(u => u.CreateUserId == userid).Count();
+ if (type == "inbox") //待办事项
+ {
+ result.total = cnt%pageSize == 0? cnt/pageSize : cnt/pageSize + 1;
+ result.rows = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
+
+ }
+ else if (type == "outbox") //已办事项
+ {
+ result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
+ result.rows = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
+
+ }
+ else //我的流程
+ {
+ result.total = cnt % pageSize == 0 ? cnt / pageSize : cnt / pageSize + 1;
+ result.rows = _unitWork.Find(pageCurrent, pageSize, "CreateDate descending", null).ToList();
+ }
+
+ return result;
+ }
+
+ #region 流程处理API
+ ///
+ /// 创建一个实例
+ ///
+ /// 进程GUID
+ /// 模板信息ID
+ ///
+ /// 进程编号
+ /// 自定义名称
+ /// 备注
+ /// 表单数据信息
+ ///
+ public bool CreateInstance(Guid processId, Guid schemeInfoId, WFProcessInstance WFProcessInstance, string frmData = null)
+ {
+
+ try
+ {
+ WFSchemeInfo WFSchemeInfo = _unitWork.FindSingle(u => u.Id == schemeInfoId);
+ WFSchemeContent WFSchemeContent = _unitWork.FindSingle(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);
+ }
+
+
+ var user = AuthUtil.GetCurrentUser();
+ #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.CreateUserId = user.User.Id.ToString();
+ WFProcessInstance.CreateUserName = user.User.Account;
+ 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 = "【创建】" + user.User.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 delegateRecordEntitylist = GetDelegateRecordList(schemeInfoId, WFProcessInstance.Code, WFProcessInstance.CustomName, WFProcessInstance.MakerList);
+ //WFProcessInstance.MakerList += delegateUserList;
+ #endregion
+
+ SaveProcess(wfruntime.runtimeModel, WFProcessInstance, WFProcessScheme, processOperationHistoryEntity, processTransitionHistoryEntity);
+
+ return true;
+ }
+ catch
+ {
+ throw;
+ }
+
+ }
+
+ ///
+ /// 节点审核
+ ///
+ ///
+ ///
+ public bool NodeVerification(Guid processId, bool flag, string description = "")
+ {
+ bool _res = false;
+ try
+ {
+ string _sqlstr = "", _dbbaseId = "";
+ WFProcessInstance WFProcessInstance = GetEntity(processId);
+ WFProcessScheme WFProcessScheme = _unitWork.FindSingle(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 _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")
+ {
+ var id = AuthUtil.GetCurrentUser().User.Id.ToString();
+ foreach (string one in _makerList.Split(','))
+ {
+ if (id == one || id.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.GetCurrentUser().User.Id.ToString(), description);
+ var _data = new
+ {
+ SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
+ frmData = wfruntime.runtimeModel.frmData
+ };
+ 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.GetCurrentUser().User.Id.ToString(), 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
+ {
+ FromNodeId = wfruntime.runtimeModel.currentNodeId,
+ FromNodeName = wfruntime.runtimeModel.currentNode.name.Value,
+ FromNodeType = wfruntime.runtimeModel.currentNodeType,
+ ToNodeId = wfruntime.runtimeModel.nextNodeId,
+ ToNodeName = wfruntime.runtimeModel.nextNode.name.Value,
+ ToNodeType = wfruntime.runtimeModel.nextNodeType,
+ 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 = wfruntime.runtimeModel.frmData
+ };
+ WFProcessScheme.SchemeContent = data.ToJson();
+ }
+ #endregion
+
+ _res = true;
+ SaveProcess(_sqlstr, _dbbaseId, WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
+ return _res;
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ ///
+ /// 驳回
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool NodeReject(Guid processId, string nodeId, string description = "")
+ {
+ try
+ {
+ WFProcessInstance WFProcessInstance = GetEntity(processId);
+ WFProcessScheme WFProcessScheme = _unitWork.FindSingle(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;
+
+ SaveProcess(WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
+ return true;
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ ///
+ /// 召回流程进程
+ ///
+ ///
+ public void CallingBackProcess(Guid processId)
+ {
+ try
+ {
+ OperateVirtualProcess(processId, 2);
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ ///
+ /// 终止一个实例(彻底删除)
+ ///
+ ///
+ ///
+ public void KillProcess(Guid processId)
+ {
+ try
+ {
+ _unitWork.Delete(u => u.Id == processId);
+ }
+ catch
+ {
+ throw;
+ }
+ }
+ ///
+ /// 获取某个节点(审核人所能看到的提交表单的权限)
+ ///
+ ///
+ ///
+ public string GetProcessSchemeContentByNodeId(string data, string nodeId)
+ {
+ try
+ {
+ List list = new List();
+ 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 && item.setInfo != null)
+ {
+ 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;
+ }
+ }
+ ///
+ /// 获取某个节点(审核人所能看到的提交表单的权限)
+ ///
+ ///
+ ///
+ ///
+ public string GetProcessSchemeContentByUserId(string data, string userId)
+ {
+ try
+ {
+ List list = new List();
+ 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
+
+ ///
+ /// 寻找该节点执行人
+ ///
+ ///
+ ///
+ private string GetMakerList(IWF_Runtime wfruntime)
+ {
+ try
+ {
+ string makerList = "";
+ if (wfruntime.runtimeModel.nextNodeId == "-1")
+ {
+ throw (new Exception("无法寻找到下一个节点"));
+ }
+ if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
+ {
+ List _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;
+ }
+ }
+ ///
+ /// 寻找该节点执行人
+ ///
+ ///
+ ///
+ 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;
+ }
+ }
+ ///
+ /// 将数组转化成逗号相隔的字串
+ ///
+ ///
+ ///
+ ///
+ 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(u => u.Id == keyValue);
+ }
+
+ ///
+ /// 已办流程进度查看,根据当前访问人的权限查看表单内容
+ /// 李玉宝于2017-01-20 15:35:13
+ ///
+ /// The key value.
+ /// WFProcessScheme.
+ public WFProcessScheme GetProcessSchemeByUserId(Guid keyValue)
+ {
+ var entity = GetProcessSchemeEntity(keyValue);
+ entity.SchemeContent = GetProcessSchemeContentByUserId(entity.SchemeContent, AuthUtil.GetCurrentUser().User.Id.ToString());
+ return entity;
+ }
+
+
+ ///
+ /// 已办流程进度查看,根据当前节点的权限查看表单内容
+ /// 李玉宝于2017-01-20 15:34:35
+ ///
+ /// The key value.
+ /// The node identifier.
+ /// WFProcessScheme.
+ 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(u => u.Id == keyValue);
+ }
+
+ ///
+ /// 审核流程
+ /// 李玉宝于2017-01-20 15:44:45
+ ///
+ /// The process identifier.
+ /// The verification data.
+ 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;
+ }
+ }
+ }
+}
diff --git a/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowDesignController.cs b/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowDesignController.cs
index d1038fb7..76df252a 100644
--- a/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowDesignController.cs
+++ b/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowDesignController.cs
@@ -21,14 +21,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
///
public class FlowDesignController :BaseController
{
- private WFSchemeService wfFlowInfoBLL;
- private UserManagerApp userBLL;
-
- public FlowDesignController()
- {
- wfFlowInfoBLL = AutofacExt.GetFromFac();
- userBLL = AutofacExt.GetFromFac();
- }
+ public WFSchemeService WfFlowInfoBll { get; set; }
#region 视图功能
///
@@ -100,8 +93,8 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetFormJson(Guid keyValue)
{
- var schemeinfo = wfFlowInfoBLL.GetEntity(keyValue);
- var schemecontent = wfFlowInfoBLL.GetSchemeEntity(schemeinfo.Id, schemeinfo.SchemeVersion);
+ var schemeinfo = WfFlowInfoBll.GetEntity(keyValue);
+ var schemecontent = WfFlowInfoBll.GetSchemeEntity(schemeinfo.Id, schemeinfo.SchemeVersion);
var JsonData = new
{
schemeinfo = schemeinfo,
@@ -118,7 +111,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetSchemeContentJson(Guid keyValue, string SchemeVersion)
{
- var schemecontent = wfFlowInfoBLL.GetSchemeEntity(keyValue, SchemeVersion);
+ var schemecontent = WfFlowInfoBll.GetSchemeEntity(keyValue, SchemeVersion);
return Content(schemecontent.ToJson());
}
#endregion
@@ -132,7 +125,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost]
public string RemoveForm(Guid[] ids)
{
- wfFlowInfoBLL.RemoveForm(ids);
+ WfFlowInfoBll.RemoveForm(ids);
return Result.ToJson();
}
///
@@ -146,7 +139,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
{
WFSchemeInfo entyity = InfoEntity.ToObject();
WFSchemeContent contententity = ContentEntity.ToObject();
- wfFlowInfoBLL.SaveForm(keyValue, entyity, contententity);
+ WfFlowInfoBll.SaveForm(keyValue, entyity, contententity);
return Result.ToJson();
}
///
@@ -159,13 +152,13 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
public ActionResult SubmitUpdateState(string keyValue, int State)
{
- wfFlowInfoBLL.UpdateState(keyValue, State);
+ WfFlowInfoBll.UpdateState(keyValue, State);
return Content("操作成功。");
}
public string Load(int pageCurrent = 1, int pageSize = 30)
{
- return JsonHelper.Instance.Serialize(wfFlowInfoBLL.Load(pageCurrent, pageSize));
+ return JsonHelper.Instance.Serialize(WfFlowInfoBll.Load(pageCurrent, pageSize));
}
#endregion
diff --git a/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowInstancesController.cs b/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowInstancesController.cs
index 52e43864..377b66e6 100644
--- a/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowInstancesController.cs
+++ b/OpenAuth.Mvc/Areas/FlowManage/Controllers/FlowInstancesController.cs
@@ -14,12 +14,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
///
public class FlowInstancesController : BaseController
{
- private WFProcessInstanceService _app;
-
- public FlowInstancesController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public WFProcessInstanceService App { get; set; }
#region 视图
@@ -115,7 +110,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
WFProcessInstance wfProcessInstanceEntity = wfProcessInstanceJson.ToObject();
wfProcessInstanceEntity.Id = Guid.Empty;
- _app.CreateInstance(Guid.NewGuid(), wfSchemeInfoId, wfProcessInstanceEntity, frmData);
+ App.CreateInstance(Guid.NewGuid(), wfSchemeInfoId, wfProcessInstanceEntity, frmData);
return Result.ToJson();
}
@@ -129,7 +124,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost]
public string VerificationProcess(Guid processId, string verificationData)
{
- _app.VerificationProcess(processId, verificationData);
+ App.VerificationProcess(processId, verificationData);
return Result.ToJson();
}
@@ -142,7 +137,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
{
foreach (var id in ids)
{
- _app.DeleteProcess(id);
+ App.DeleteProcess(id);
}
return Result.ToJson();
}
@@ -166,7 +161,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetProcessSchemeJson(Guid keyValue)
{
- var data = _app.GetProcessSchemeEntity(keyValue);
+ var data = App.GetProcessSchemeEntity(keyValue);
return Content(data.ToJson());
}
@@ -178,7 +173,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetProcessSchemeEntityByUserId(Guid keyValue)
{
- var data = _app.GetProcessSchemeByUserId(keyValue);
+ var data = App.GetProcessSchemeByUserId(keyValue);
return Content(data.ToJson());
}
@@ -191,7 +186,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetProcessSchemeEntityByNodeId(Guid keyValue, string nodeId)
{
- var data = _app.GetProcessSchemeEntityByNodeId(keyValue, nodeId);
+ var data = App.GetProcessSchemeEntityByNodeId(keyValue, nodeId);
return Content(data.ToJson());
}
@@ -203,8 +198,8 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetProcessInfoJson(Guid keyValue)
{
- var processInstance = _app.GetProcessInstanceEntity(keyValue);
- var processScheme = _app.GetProcessSchemeEntity(processInstance.ProcessSchemeId);
+ var processInstance = App.GetProcessInstanceEntity(keyValue);
+ var processScheme = App.GetProcessSchemeEntity(processInstance.ProcessSchemeId);
var JsonData = new
{
processInstance = processInstance,
@@ -221,13 +216,13 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetProcessInstanceJson(Guid keyValue)
{
- var processInstance = _app.GetProcessInstanceEntity(keyValue);
+ var processInstance = App.GetProcessInstanceEntity(keyValue);
return Content(processInstance.ToJson());
}
public string Load(string type, int pageCurrent = 1, int pageSize = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetCurrentUser().User.Id.ToString(), type, pageCurrent, pageSize));
+ return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetCurrentUser().User.Id.ToString(), type, pageCurrent, pageSize));
}
#endregion 获取数据(公用)
diff --git a/OpenAuth.Mvc/Areas/FlowManage/Controllers/FormDesignController.cs b/OpenAuth.Mvc/Areas/FlowManage/Controllers/FormDesignController.cs
index e03b3eff..6a587d68 100644
--- a/OpenAuth.Mvc/Areas/FlowManage/Controllers/FormDesignController.cs
+++ b/OpenAuth.Mvc/Areas/FlowManage/Controllers/FormDesignController.cs
@@ -13,12 +13,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
public class FormDesignController : BaseController
{
- private readonly WFFormService _wfFrmMainBll;
-
- public FormDesignController()
- {
- _wfFrmMainBll = AutofacExt.GetFromFac();
- }
+ public WFFormService WfFrmMainBll { get; set; }
#region 视图功能
///
@@ -55,7 +50,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
public string Load(int pageCurrent = 1, int pageSize = 30)
{
- return JsonHelper.Instance.Serialize(_wfFrmMainBll.Load(pageCurrent, pageSize));
+ return JsonHelper.Instance.Serialize(WfFrmMainBll.Load(pageCurrent, pageSize));
}
///
@@ -66,7 +61,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetTreeJson()
{
- var data = _wfFrmMainBll.GetAllList();
+ var data = WfFrmMainBll.GetAllList();
var treeList = new List();
foreach (var item in data)
{
@@ -95,7 +90,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetFormJson(Guid keyValue)
{
- var data = _wfFrmMainBll.GetForm(keyValue);
+ var data = WfFrmMainBll.GetForm(keyValue);
return Content(data.ToJson());
}
@@ -106,7 +101,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpGet]
public ActionResult GetAllListJson()
{
- var data = _wfFrmMainBll.GetAllList();
+ var data = WfFrmMainBll.GetAllList();
return Content(data.ToJson());
}
#endregion
@@ -120,7 +115,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
[HttpPost]
public string RemoveForm(Guid[] ids)
{
- _wfFrmMainBll.RemoveForm(ids);
+ WfFrmMainBll.RemoveForm(ids);
return Result.ToJson();
}
/////
@@ -137,7 +132,7 @@ namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
var user = AuthUtil.GetCurrentUser();
userEntity.ModifyUserId = user.User.Account;
userEntity.ModifyUserName = user.User.Name;
- _wfFrmMainBll.SaveForm(keyValue, userEntity);
+ WfFrmMainBll.SaveForm(keyValue, userEntity);
}
catch (Exception e)
{
diff --git a/OpenAuth.Mvc/Areas/FlowManage/Views/FlowDesign/FlowLineForm.cshtml b/OpenAuth.Mvc/Areas/FlowManage/Views/FlowDesign/FlowLineForm.cshtml
index 0a555e03..165fa2c1 100644
--- a/OpenAuth.Mvc/Areas/FlowManage/Views/FlowDesign/FlowLineForm.cshtml
+++ b/OpenAuth.Mvc/Areas/FlowManage/Views/FlowDesign/FlowLineForm.cshtml
@@ -15,12 +15,12 @@
InitControl();
});
function initLoadPageData() {
- var _FlowDesignObject = top.FlowSchemeBuider.FlowDesignObject;
- lineobject = _FlowDesignObject.$lineData[top.FlowSchemeBuider.LineId];
- lineobject.id = top.FlowSchemeBuider.LineId;
+ var _FlowDesignObject = parent.FlowDesignObject;
+ lineobject = _FlowDesignObject.$lineData[parent.LineId];
+ lineobject.id = parent.LineId;
fromnode = _FlowDesignObject.$nodeData[lineobject.from];
- frmtype = top.FlowSchemeBuider.postData["FrmType"];
+ frmtype = parent.postData["FrmType"];
if (frmtype == 0) {
frmCotent = JSON.parse(top.FlowSchemeBuider.frmData["FrmContent"]);
}
diff --git a/OpenAuth.Mvc/AutofacExt.cs b/OpenAuth.Mvc/AutofacExt.cs
index 5818281b..9ca8f6fc 100644
--- a/OpenAuth.Mvc/AutofacExt.cs
+++ b/OpenAuth.Mvc/AutofacExt.cs
@@ -36,30 +36,31 @@ namespace OpenAuth.Mvc
builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>));
builder.RegisterType(typeof (UnitWork)).As(typeof (IUnitWork));
- //注册WebConfig中的配置
- builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
-
//注册app层
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof (UserManagerApp)));
//注册领域服务
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(AuthoriseService)))
- .Where(u =>u.Namespace== "OpenAuth.Domain.Service");
+ .Where(u =>u.Namespace== "OpenAuth.Domain.Service"
+ || u.Namespace == "OpenAuth.Domain.Interface");
- // Register your MVC controllers.
- builder.RegisterControllers(typeof(MvcApplication).Assembly);
+ //注册Repository
+ builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserRepository)))
+ .AsImplementedInterfaces();
- // OPTIONAL: Register model binders that require DI.
+ // 注册controller,使用属性注入
+ builder.RegisterControllers(Assembly.GetExecutingAssembly()).PropertiesAutowired();
+
builder.RegisterModelBinders(Assembly.GetExecutingAssembly());
builder.RegisterModelBinderProvider();
// OPTIONAL: Register web abstractions like HttpContextBase.
- builder.RegisterModule();
+ //builder.RegisterModule();
// OPTIONAL: Enable property injection in view pages.
builder.RegisterSource(new ViewRegistrationSource());
- // OPTIONAL: Enable property injection into action filters.
+ // 注册所有的Attribute
builder.RegisterFilterProvider();
// Set the dependency resolver to be Autofac.
diff --git a/OpenAuth.Mvc/Controllers/CategoryManagerController.cs b/OpenAuth.Mvc/Controllers/CategoryManagerController.cs
index 2889298c..e97c110c 100644
--- a/OpenAuth.Mvc/Controllers/CategoryManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/CategoryManagerController.cs
@@ -10,12 +10,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class CategoryManagerController : BaseController
{
- private CategoryManagerApp _app;
-
- public CategoryManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public CategoryManagerApp App { get; set; }
//
// GET: /UserManager/
@@ -30,12 +25,12 @@ namespace OpenAuth.Mvc.Controllers
///
public string Load(Guid parentId, int page = 1, int rows = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(parentId, page, rows));
+ return JsonHelper.Instance.Serialize(App.Load(parentId, page, rows));
}
public string LoadForTree()
{
- return JsonHelper.Instance.Serialize(_app.LoadAll());
+ return JsonHelper.Instance.Serialize(App.LoadAll());
}
//添加或修改Category
@@ -44,7 +39,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.AddOrUpdate(model);
+ App.AddOrUpdate(model);
}
catch (Exception ex)
@@ -59,7 +54,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.Delete(ids);
+ App.Delete(ids);
}
catch (Exception e)
{
diff --git a/OpenAuth.Mvc/Controllers/HomeController.cs b/OpenAuth.Mvc/Controllers/HomeController.cs
index 85601df2..1a7ae9a5 100644
--- a/OpenAuth.Mvc/Controllers/HomeController.cs
+++ b/OpenAuth.Mvc/Controllers/HomeController.cs
@@ -12,13 +12,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class HomeController : BaseController
{
- private ModuleManagerApp _app;
- public HomeController()
- {
- _app = AutofacExt.GetFromFac();
- }
-
public ActionResult Index()
{
ViewBag.NavBar = GetNavBar();
diff --git a/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs b/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
index 521534bf..fffa6bc2 100644
--- a/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
@@ -24,12 +24,8 @@ namespace OpenAuth.Mvc.Controllers
{
public class ModuleElementManagerController : BaseController
{
- private ModuleElementManagerApp _app;
+ public ModuleElementManagerApp App { get; set; }
- public ModuleElementManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
public ActionResult Index(Guid id)
{
ViewBag.ModuleId = id;
@@ -37,14 +33,14 @@ namespace OpenAuth.Mvc.Controllers
}
public ActionResult Get(Guid moduleId)
{
- return Json(_app.LoadByModuleId(moduleId), JsonRequestBehavior.AllowGet);
+ return Json(App.LoadByModuleId(moduleId), JsonRequestBehavior.AllowGet);
}
[HttpPost]
public string AddOrEditButton(ModuleElement button)
{
try
{
- _app.AddOrUpdate(button);
+ App.AddOrUpdate(button);
}
catch (DbEntityValidationException e)
{
@@ -58,7 +54,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.Delete(ids);
+ App.Delete(ids);
}
catch (Exception e)
{
@@ -83,7 +79,7 @@ namespace OpenAuth.Mvc.Controllers
}
public string LoadWithAccess(Guid tId, Guid firstId, string key)
{
- return JsonHelper.Instance.Serialize(_app.LoadWithAccess(key, firstId, tId));
+ return JsonHelper.Instance.Serialize(App.LoadWithAccess(key, firstId, tId));
}
}
}
\ No newline at end of file
diff --git a/OpenAuth.Mvc/Controllers/ModuleManagerController.cs b/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
index 5cd3aaa6..72da3c8e 100644
--- a/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
@@ -14,12 +14,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class ModuleManagerController : BaseController
{
- private ModuleManagerApp _app;
-
- public ModuleManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public ModuleManagerApp App { get; set; }
// GET: /ModuleManager/
[Authenticate]
@@ -34,7 +29,7 @@ namespace OpenAuth.Mvc.Controllers
ViewBag.ModuleType = key;
var moduleWithChildren = AuthUtil.GetCurrentUser().ModuleWithChildren;
- var modules = key == "UserModule" ? _app.LoadForUser(firstId) : _app.LoadForRole(firstId);
+ var modules = key == "UserModule" ? App.LoadForUser(firstId) : App.LoadForRole(firstId);
CheckModule(moduleWithChildren, modules);
@@ -106,7 +101,7 @@ namespace OpenAuth.Mvc.Controllers
///
public string Load(Guid orgId, int page = 1, int rows = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(orgId, page, rows));
+ return JsonHelper.Instance.Serialize(App.Load(orgId, page, rows));
}
///
@@ -116,7 +111,7 @@ namespace OpenAuth.Mvc.Controllers
/// System.String.
public string LoadForUser(Guid firstId)
{
- var orgs = _app.LoadForUser(firstId);
+ var orgs = App.LoadForUser(firstId);
return JsonHelper.Instance.Serialize(orgs);
}
@@ -127,7 +122,7 @@ namespace OpenAuth.Mvc.Controllers
/// System.String.
public string LoadForRole(Guid firstId)
{
- var orgs = _app.LoadForRole(firstId);
+ var orgs = App.LoadForRole(firstId);
return JsonHelper.Instance.Serialize(orgs);
}
@@ -145,7 +140,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.AddOrUpdate(model);
+ App.AddOrUpdate(model);
}
catch (Exception ex)
{
@@ -162,7 +157,7 @@ namespace OpenAuth.Mvc.Controllers
{
foreach (var obj in ids)
{
- _app.Delete(obj);
+ App.Delete(obj);
}
}
catch (Exception e)
diff --git a/OpenAuth.Mvc/Controllers/OrgManagerController.cs b/OpenAuth.Mvc/Controllers/OrgManagerController.cs
index 9a0feed8..72b3f528 100644
--- a/OpenAuth.Mvc/Controllers/OrgManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/OrgManagerController.cs
@@ -10,12 +10,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class OrgManagerController : BaseController
{
- private OrgManagerApp _orgApp;
-
- public OrgManagerController()
- {
- _orgApp = AutofacExt.GetFromFac();
- }
+ public OrgManagerApp OrgApp { get; set; }
//
// GET: /OrgManager/
@@ -38,13 +33,13 @@ namespace OpenAuth.Mvc.Controllers
public string LoadForUser(Guid firstId)
{
- var orgs = _orgApp.LoadForUser(firstId);
+ var orgs = OrgApp.LoadForUser(firstId);
return JsonHelper.Instance.Serialize(orgs);
}
public string LoadForRole(Guid firstId)
{
- var orgs = _orgApp.LoadForRole(firstId);
+ var orgs = OrgApp.LoadForRole(firstId);
return JsonHelper.Instance.Serialize(orgs);
}
@@ -55,7 +50,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _orgApp.AddOrUpdate(org);
+ OrgApp.AddOrUpdate(org);
}
catch (Exception ex)
{
@@ -67,7 +62,7 @@ namespace OpenAuth.Mvc.Controllers
public string LoadChildren(Guid id)
{
- return JsonHelper.Instance.Serialize(_orgApp.LoadAllChildren(id));
+ return JsonHelper.Instance.Serialize(OrgApp.LoadAllChildren(id));
}
///
@@ -80,7 +75,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _orgApp.DelOrg(ids);
+ OrgApp.DelOrg(ids);
}
catch (Exception e)
{
diff --git a/OpenAuth.Mvc/Controllers/RelevanceManagerController.cs b/OpenAuth.Mvc/Controllers/RelevanceManagerController.cs
index 235f6c83..7298c86d 100644
--- a/OpenAuth.Mvc/Controllers/RelevanceManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/RelevanceManagerController.cs
@@ -12,19 +12,14 @@ namespace OpenAuth.Mvc.Controllers
{
public class RelevanceManagerController : BaseController
{
- private RevelanceManagerApp _app;
-
- public RelevanceManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public RevelanceManagerApp App { get; set; }
[HttpPost]
public string Assign(string type, Guid firstId, Guid[] secIds)
{
try
{
- _app.Assign(type, firstId, secIds);
+ App.Assign(type, firstId, secIds);
}
catch (Exception ex)
{
@@ -38,7 +33,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.UnAssign(type, firstId, secIds);
+ App.UnAssign(type, firstId, secIds);
}
catch (Exception ex)
{
diff --git a/OpenAuth.Mvc/Controllers/ResourceManagerController.cs b/OpenAuth.Mvc/Controllers/ResourceManagerController.cs
index aea55e74..9e30e7fe 100644
--- a/OpenAuth.Mvc/Controllers/ResourceManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/ResourceManagerController.cs
@@ -11,12 +11,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class ResourceManagerController : BaseController
{
- private ResourceManagerApp _app;
-
- public ResourceManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public ResourceManagerApp App { get; set; }
//
// GET: /UserManager/
@@ -32,7 +27,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.AddOrUpdate(model);
+ App.AddOrUpdate(model);
}
catch (Exception ex)
{
@@ -47,12 +42,12 @@ namespace OpenAuth.Mvc.Controllers
///
public string Load(Guid categoryId, int page = 1, int rows = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetUserName(), categoryId, page, rows));
+ return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetUserName(), categoryId, page, rows));
}
public string LoadForTree()
{
- var models = _app.LoadAll();
+ var models = App.LoadAll();
return JsonHelper.Instance.Serialize(models);
}
@@ -61,7 +56,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.Delete(ids);
+ App.Delete(ids);
}
catch (Exception e)
{
@@ -96,7 +91,7 @@ namespace OpenAuth.Mvc.Controllers
/// System.String.
public string LoadWithAccess(Guid cId, Guid firstId, string key)
{
- return JsonHelper.Instance.Serialize(_app.LoadWithAccess(AuthUtil.GetUserName(),key,firstId, cId));
+ return JsonHelper.Instance.Serialize(App.LoadWithAccess(AuthUtil.GetUserName(),key,firstId, cId));
}
}
}
\ No newline at end of file
diff --git a/OpenAuth.Mvc/Controllers/RoleManagerController.cs b/OpenAuth.Mvc/Controllers/RoleManagerController.cs
index 4fe569ac..a50f1cb1 100644
--- a/OpenAuth.Mvc/Controllers/RoleManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/RoleManagerController.cs
@@ -10,12 +10,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class RoleManagerController : BaseController
{
- private RoleManagerApp _app;
-
- public RoleManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public RoleManagerApp App { get; set; }
//
// GET: /RoleManager/
@@ -31,7 +26,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.AddOrUpdate(obj);
+ App.AddOrUpdate(obj);
}
catch (Exception ex)
{
@@ -46,7 +41,7 @@ namespace OpenAuth.Mvc.Controllers
///
public string Load(Guid orgId, int pageCurrent = 1, int pageSize = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
+ return JsonHelper.Instance.Serialize(App.Load(orgId, pageCurrent, pageSize));
}
[System.Web.Mvc.HttpPost]
@@ -56,7 +51,7 @@ namespace OpenAuth.Mvc.Controllers
{
foreach (var obj in ids)
{
- _app.Delete(obj);
+ App.Delete(obj);
}
}
catch (Exception e)
@@ -78,7 +73,7 @@ namespace OpenAuth.Mvc.Controllers
public string LoadForOrgAndUser(Guid orgId, Guid userId)
{
- return JsonHelper.Instance.Serialize(_app.LoadForOrgAndUser(orgId, userId));
+ return JsonHelper.Instance.Serialize(App.LoadForOrgAndUser(orgId, userId));
}
#endregion 为用户设置角色界面
diff --git a/OpenAuth.Mvc/Controllers/StockManagerController.cs b/OpenAuth.Mvc/Controllers/StockManagerController.cs
index cb3e4f5b..e1f30a2b 100644
--- a/OpenAuth.Mvc/Controllers/StockManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/StockManagerController.cs
@@ -14,12 +14,7 @@ namespace OpenAuth.Mvc.Controllers
///
public class StockManagerController : BaseController
{
- private StockManagerApp _app;
-
- public StockManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public StockManagerApp App { get; set; }
//
// GET: /UserManager/
@@ -37,7 +32,7 @@ namespace OpenAuth.Mvc.Controllers
{
var newmodel = new Stock();
model.CopyTo(newmodel);
- _app.AddOrUpdate(newmodel);
+ App.AddOrUpdate(newmodel);
}
catch (Exception ex)
{
@@ -52,14 +47,14 @@ namespace OpenAuth.Mvc.Controllers
///
public string Load(Guid parentId, int page = 1, int rows = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetUserName(), parentId, page, rows));
+ return JsonHelper.Instance.Serialize(App.Load(AuthUtil.GetUserName(), parentId, page, rows));
}
public string Delete(Guid[] ids)
{
try
{
- _app.Delete(ids);
+ App.Delete(ids);
}
catch (Exception e)
{
diff --git a/OpenAuth.Mvc/Controllers/UserManagerController.cs b/OpenAuth.Mvc/Controllers/UserManagerController.cs
index 967d682c..75a17f18 100644
--- a/OpenAuth.Mvc/Controllers/UserManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/UserManagerController.cs
@@ -13,12 +13,7 @@ namespace OpenAuth.Mvc.Controllers
{
public class UserManagerController : BaseController
{
- private UserManagerApp _app;
-
- public UserManagerController()
- {
- _app = AutofacExt.GetFromFac();
- }
+ public UserManagerApp App { get; set; }
//
// GET: /UserManager/
@@ -34,7 +29,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.AddOrUpdate(view);
+ App.AddOrUpdate(view);
}
catch (Exception ex)
@@ -50,7 +45,7 @@ namespace OpenAuth.Mvc.Controllers
///
public string Load(Guid orgId, int page = 1, int rows = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(orgId, page, rows));
+ return JsonHelper.Instance.Serialize(App.Load(orgId, page, rows));
}
[HttpPost]
@@ -58,7 +53,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
- _app.Delete(ids);
+ App.Delete(ids);
}
catch (Exception e)
{
@@ -81,7 +76,7 @@ namespace OpenAuth.Mvc.Controllers
var treeList = new List();
string companyid = "";
string departmentid = "";
- foreach (UserView item in _app.Load(Guid.Empty, 1, 10).rows)
+ foreach (UserView item in App.Load(Guid.Empty, 1, 10).rows)
{
TreeEntity tree = new TreeEntity();
@@ -107,7 +102,7 @@ namespace OpenAuth.Mvc.Controllers
///
public string GetAccessedUsers()
{
- IEnumerable users = _app.Load(Guid.Empty, 1, 10).rows;
+ IEnumerable users = App.Load(Guid.Empty, 1, 10).rows;
var result = new Dictionary();
foreach (var user in users)
{
diff --git a/OpenAuth.Mvc/Web.config b/OpenAuth.Mvc/Web.config
index 88e14ede..ec593cb9 100644
--- a/OpenAuth.Mvc/Web.config
+++ b/OpenAuth.Mvc/Web.config
@@ -9,8 +9,6 @@
-
-
@@ -42,19 +40,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-