コード例 #1
0
        /// <summary>
        /// 驳回
        /// </summary>
        /// <param name="processId"></param>
        /// <param name="nodeId"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public bool NodeReject(Guid processId, string nodeId, string description = "")
        {
            try
            {
                WFProcessInstance          WFProcessInstance              = GetEntity(processId);
                WFProcessScheme            WFProcessScheme                = _unitWork.FindSingle <WFProcessScheme>(u => u.Id == WFProcessInstance.ProcessSchemeId);
                WFProcessOperationHistory  WFProcessOperationHistory      = new WFProcessOperationHistory();
                WFProcessTransitionHistory processTransitionHistoryEntity = null;
                dynamic             schemeContentJson  = WFProcessScheme.SchemeContent.ToJson();//获取工作流模板内容的json对象;
                WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
                {
                    schemeContent = schemeContentJson.SchemeContent.Value,
                    currentNodeId = WFProcessInstance.ActivityId,
                    frmData       = schemeContentJson.frmData.Value,
                    previousId    = WFProcessInstance.PreviousId,
                    processId     = processId
                };
                IWF_Runtime wfruntime = new WF_Runtime(wfRuntimeInitModel);


                string resnode = "";
                if (nodeId == "")
                {
                    resnode = wfruntime.RejectNode();
                }
                else
                {
                    resnode = nodeId;
                }
                wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 0, AuthUtil.GetUserName(), description);
                WFProcessInstance.IsFinish = 4;//4表示驳回(需要申请者重新提交表单)
                if (resnode != "")
                {
                    WFProcessInstance.PreviousId   = WFProcessInstance.ActivityId;
                    WFProcessInstance.ActivityId   = resnode;
                    WFProcessInstance.ActivityType = wfruntime.GetNodeStatus(resnode);                                                           //-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
                    WFProcessInstance.ActivityName = wfruntime.runtimeModel.nodeDictionary[resnode].name;
                    WFProcessInstance.MakerList    = GetMakerList(wfruntime.runtimeModel.nodeDictionary[resnode], WFProcessInstance.PreviousId); //当前节点可执行的人信息
                    #region 流转记录
                    processTransitionHistoryEntity                = new WFProcessTransitionHistory();
                    processTransitionHistoryEntity.FromNodeId     = wfruntime.runtimeModel.currentNodeId;
                    processTransitionHistoryEntity.FromNodeName   = wfruntime.runtimeModel.currentNode.name.Value;
                    processTransitionHistoryEntity.FromNodeType   = wfruntime.runtimeModel.currentNodeType;
                    processTransitionHistoryEntity.ToNodeId       = wfruntime.runtimeModel.nextNodeId;
                    processTransitionHistoryEntity.ToNodeName     = wfruntime.runtimeModel.nextNode.name.Value;
                    processTransitionHistoryEntity.ToNodeType     = wfruntime.runtimeModel.nextNodeType;
                    processTransitionHistoryEntity.TransitionSate = 1;//
                    processTransitionHistoryEntity.IsFinish       = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
                    #endregion
                }
                var data = new
                {
                    SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
                    frmData       = (WFProcessInstance.FrmType == 0 ? wfruntime.runtimeModel.frmData : null)
                };
                WFProcessScheme.SchemeContent     = data.ToJson().ToString();
                WFProcessOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + description;

                SaveProcess(WFProcessInstance, WFProcessScheme, WFProcessOperationHistory, processTransitionHistoryEntity);
                return(true);
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// 节点审核
        /// </summary>
        /// <param name="processId"></param>
        /// <returns></returns>
        public bool NodeVerification(Guid processId, bool flag, string description = "")
        {
            bool _res = false;

            try
            {
                string                     _sqlstr = "", _dbbaseId = "";
                WFProcessInstance          WFProcessInstance              = GetEntity(processId);
                WFProcessScheme            WFProcessScheme                = _unitWork.FindSingle <WFProcessScheme>(u => u.Id == WFProcessInstance.ProcessSchemeId);
                WFProcessOperationHistory  WFProcessOperationHistory      = new WFProcessOperationHistory(); //操作记录
                WFProcessTransitionHistory processTransitionHistoryEntity = null;                            //流转记录

                dynamic             schemeContentJson  = WFProcessScheme.SchemeContent.ToJson();             //获取工作流模板内容的json对象;
                WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
                {
                    schemeContent = schemeContentJson.SchemeContent.Value,
                    currentNodeId = WFProcessInstance.ActivityId,
                    frmData       = schemeContentJson.frmData.Value,
                    previousId    = WFProcessInstance.PreviousId,
                    processId     = processId
                };
                IWF_Runtime wfruntime = new WF_Runtime(wfRuntimeInitModel);


                #region 会签
                if (WFProcessInstance.ActivityType == 0)                                //会签
                {
                    wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1, ""); //标记当前节点通过
                    ///寻找需要审核的节点Id
                    string        _VerificationNodeId = "";
                    List <string> _nodelist           = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
                    string        _makerList          = "";
                    foreach (string item in _nodelist)
                    {
                        _makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.processId);
                        if (_makerList != "-1")
                        {
                            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;
            }
        }