Exemple #1
0
        public bool IsNodeAllAgree(string InstanceID, string NodeID)
        {
            try
            {
                int ApprovalNum = CApprovalManager.GetLastApprovalNum(InstanceID, NodeID);
                if (ApprovalNum == 0)
                {
                    return(false);
                }

                string strUnCompleteNum = CDataHelper.GetData("select count(*) from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' and approval_num='" + ApprovalNum + "' and approval_status<>'" + EApprovalStatus.Complete.ToString() + "'");
                if (strUnCompleteNum != "0")
                {
                    return(false);
                }

                string strUnAgreeNum = CDataHelper.GetData("select count(*) from " + CTableName.FlowChartReceiver + " where instance_id='" + InstanceID + "' and node_id='" + NodeID + "' and approval_num='" + ApprovalNum + "' and approval_opinion<>'" + EApprovalStatus.Complete.ToString() + "' and approval_opinion<>NULL and approval_opinion<>''");
                if (strUnAgreeNum != "0")
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                CLog.PutDownErrInfo("判断节点审批人是否都同意操作异常。实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString());
                throw ex;
            }
        }
        /// <summary>
        /// 将工作流实例设置为错误状态
        /// </summary>
        /// <param name="InstanceID"></param>
        /// <param name="ErrorMessage">错误状态信息</param>
        public static string SetInstanceError(string InstanceID, string ErrorMessage)
        {
            try
            {
                //设置审批状态为无效
                string UpdateInstanceApprovalStatusResult = CApprovalManager.UpdateInstanceApprovalStatus(InstanceID, EApprovalStatus.Invalid);
                if (UpdateInstanceApprovalStatusResult != WFGlobal.success)
                {
                    return(UpdateInstanceApprovalStatusResult);
                }

                //设置实例状态为错误
                string UpdateInstanceStatusResult = UpdateInstanceStatus(InstanceID, EInstanceStatus.Error);
                if (UpdateInstanceStatusResult != WFGlobal.success)
                {
                    return(UpdateInstanceStatusResult);
                }

                //记录出错信息
                return(UpdateInstanceMessage(InstanceID, ErrorMessage));
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("设置工作流实例的错误状态操作异常,工作流实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
        /// <summary>
        /// 流程流转命令处理
        /// </summary>
        /// <param name="InstanceID">流程实例的ID</param>
        /// <param name="NodeID">节点ID</param>
        /// <param name="ApprovalOpinion">申批意见,同意,不同意,驳回上级,驳回至发起人</param>
        /// <param name="OpeManID">申批人ID</param>
        /// <param name="ApprovalReason">申批备注</param>
        private string WFTransmitDeal(string InstanceID, string NodeID, EApprovalOpinion ApprovalOpinion, string OpeManID, string ApprovalReason)
        {
            try
            {
                //获取并执行审批脚本
                string script = CNodeManager.GetApprovalScript(NodeID, ApprovalOpinion);
                if (script != null && script != "")
                {
                    CScriptOpe.ScriptExec(script, InstanceID);
                }

                //记录审批意见和状态
                string UpdateApprovalOpinionResult = CApprovalManager.UpdateApprovalOpinion(InstanceID, NodeID, ApprovalOpinion, OpeManID, ApprovalReason);
                if (UpdateApprovalOpinionResult != WFGlobal.success)
                {
                    return(UpdateApprovalOpinionResult);
                }

                //判断是否可以流转到下一级
                string NextNodeID = CNodeManager.GetNextNodeIDByCurrentNodeID(NodeID, ApprovalOpinion);
                if (CNodeManager.IsNodeThroughEnable(InstanceID, NextNodeID))
                {
                    //记录该节点所有审批人的审批状态
                    string UpdateNodeApprovalStatusResult = CApprovalManager.UpdateNodeApprovalStatus(InstanceID, NodeID, EApprovalStatus.Complete);
                    if (UpdateNodeApprovalStatusResult != WFGlobal.success)
                    {
                        return(UpdateNodeApprovalStatusResult);
                    }

                    if (ApprovalOpinion == EApprovalOpinion.驳回上级)
                    {
                        return(CReturnUP.ReturnUp(InstanceID, NodeID, NextNodeID));
                    }
                    else if (ApprovalOpinion == EApprovalOpinion.驳回至发起人)
                    {
                        return(CReturnToStart.ReturnToStart(InstanceID, NodeID, NextNodeID));
                    }
                    else if (ApprovalOpinion == EApprovalOpinion.意)
                    {
                        return(CGoEnd.GoEnd(InstanceID, NodeID, NextNodeID));
                    }
                    else
                    {
                        return(CNodeManager.GoNextNodesFromOtherNode(InstanceID, NodeID));
                    }
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("流程流转异常:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
 /// <summary>
 /// 将工作流实例的状态设置为Complete
 /// </summary>
 /// <param name="InstanceID"></param>
 public static string SetInstanceComplete(string InstanceID)
 {
     try
     {
         string UpdateInstanceApprovalStatusResult = CApprovalManager.UpdateInstanceApprovalStatus(InstanceID, EApprovalStatus.Complete);
         if (UpdateInstanceApprovalStatusResult != WFGlobal.success)
         {
             return(UpdateInstanceApprovalStatusResult);
         }
         return(UpdateInstanceStatus(InstanceID, EInstanceStatus.Complete));
     }
     catch (Exception ex)
     {
         WFGlobal.ErrInfo = CLog.PutDownErrInfo("设置实例为结束状态的操作异常,实例ID:" + InstanceID + ",异常信息:" + ex.Message.ToString());
         return(WFGlobal.ErrInfo);
     }
 }
        /// <summary>
        /// 发起流程命令处理
        /// </summary>
        /// <param name="WFName">流程名称</param>
        /// <param name="WFDataID">数据表相对应数据ID</param>
        /// <param name="OpeManID">发起人ID</param>
        private string WFStartDeal(string WFName, string WFDataID, string OpeManID)
        {
            try
            {
                string WFID = CWFManager.GetLastVersionWFID(WFName);

                if (WFID == null || WFID == "")
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流" + WFName + "不存在。");
                    return(WFGlobal.ErrInfo);
                }

                string StartNodeID = CNodeManager.GetStartNodeID(WFID);
                if (StartNodeID == null || StartNodeID == "")
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流" + WFID + "没有起始节点。");
                    return(WFGlobal.ErrInfo);
                }

                string NewInstanceID = Guid.NewGuid().ToString();

                //记录工作流实例
                string PutDownInstanceResult = CInstanceManager.PutDownNewInstance(WFName, WFDataID, OpeManID, WFID, NewInstanceID);
                if (PutDownInstanceResult != WFGlobal.success)
                {
                    return(PutDownInstanceResult);
                }

                //将工作流实例的审批人设定为发起人
                string PutDownApproverResult = CApprovalManager.PutDownApprover(NewInstanceID, StartNodeID, OpeManID, 1, "");
                if (PutDownApproverResult != WFGlobal.success)
                {
                    return(PutDownApproverResult);
                }

                //流程流转
                return(WFTransmitDeal(NewInstanceID, StartNodeID, EApprovalOpinion.意, OpeManID, ""));
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("发起工作流操作异常。工作流名称:" + WFName + ",发起人ID:" + OpeManID + ",数据ID" + WFDataID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
Exemple #6
0
        /// <summary>
        /// 将工作流流转到开始节点
        /// </summary>
        /// <param name="InstanceID"></param>
        /// <param name="CurrentNodeID">当前节点ID</param>
        public static string ReturnToStart(string InstanceID, string CurrentNodeID, string StartNodeID)
        {
            try
            {
                //将当前所有节点的审批状态设置为完成状态
                string UpdateInstanceApprovalStatusResult = CApprovalManager.UpdateInstanceApprovalStatus(InstanceID, EApprovalStatus.Complete);
                if (UpdateInstanceApprovalStatusResult != WFGlobal.success)
                {
                    return(UpdateInstanceApprovalStatusResult);
                }

                //流程流转到开始节点
                return(CNodeManager.NodeTransfer(InstanceID, CurrentNodeID, StartNodeID));
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("返回到开始节点操作异常。实例ID:" + InstanceID + ",当前节点ID:" + CurrentNodeID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
Exemple #7
0
        /// <summary>
        /// 记录节点的审批人
        /// </summary>
        /// <param name="InstanceID"></param>
        /// <param name="NodeID"></param>
        public static string PutDownNodeApprover(string InstanceID, string NodeID)
        {
            try
            {
                string nodetype = CNodeManager.GetNodeType(NodeID);
                if (nodetype == null)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取节点" + NodeID + "的节点类型失败,工作流实例ID:" + InstanceID);
                    CInstanceManager.SetInstanceError(InstanceID, WFGlobal.ErrInfo);
                    return(WFGlobal.ErrInfo);
                }

                int ApprovalNum = CApprovalManager.GetLastApprovalNum(InstanceID, NodeID);
                //判断是否开始流程
                if (nodetype == CNodeType.StartType)
                {
                    string StartManID = CInstanceManager.GetInstanceStartManID(InstanceID);
                    if (StartManID == null)
                    {
                        WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取流程实例的发起人失败,工作流实例ID:" + InstanceID);
                        CInstanceManager.SetInstanceError(InstanceID, WFGlobal.ErrInfo);
                        return(WFGlobal.ErrInfo);
                    }

                    string ApprovalNote = CApprovalManager.GetApprovalNote(InstanceID, NodeID);

                    string PutDownApproverResult = CApprovalManager.PutDownApprover(InstanceID, NodeID, StartManID, ApprovalNum + 1, ApprovalNote);
                    if (PutDownApproverResult != WFGlobal.success)
                    {
                        return(PutDownApproverResult);
                    }
                }
                //判断流程是否结束
                else if (nodetype != CNodeType.EndType)
                {
                    DataTable dtReceiver   = CApprovalManager.GetApprover(InstanceID, NodeID);
                    string    ApprovalNote = CApprovalManager.GetApprovalNote(InstanceID, NodeID);
                    if (dtReceiver != null)
                    {
                        if (dtReceiver.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtReceiver.Rows.Count; i++)
                            {
                                string ReceiverID            = dtReceiver.Rows[i][WFGlobal.UserID].ToString();
                                string PutDownApproverResult = CApprovalManager.PutDownApprover(InstanceID, NodeID, ReceiverID, ApprovalNum + 1, ApprovalNote);
                                if (PutDownApproverResult != WFGlobal.success)
                                {
                                    return(PutDownApproverResult);
                                }
                            }
                        }
                    }
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录节点审批人操作异常。工作流实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }