/// <summary>
        /// 保存通过日志
        /// </summary>
        /// <param name="currentStep"></param>
        /// <param name="RefID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="Content"></param>
        /// <param name="Conclusion"></param>
        /// <param name="RefIDType"></param>
        /// <returns></returns>
        private bool SaveApproveLog(ProcessStepEntityInfo currentStep, ProcessStepEntityInfo preStep, ProcessStepEntityInfo nextStep, long RefID, int userID, string userName, int nextUserID, string nextUserName, string Content = "", int RefIDType = 0)
        {
            //------流程流转日志---------
            if (preStep == null)//上一步骤为空 写本次日志
            {
                ProcessStepLogInfo logInfoCurrent = new ProcessStepLogInfo(currentStep, RefID, currentStep.Status, userID, userName, DateTime.Now, userID, userName, DateTime.Now, Content, 1, RefIDType);
                SaveLog(logInfoCurrent);//记录本次操作的日志,提交人、执行人都为当前用户
            }
            else //上一步骤非空   update本次日志
            {
                ProcessStepLogInfo logInfoCurrent = GetStepLogByRefID(currentStep.ProcessEntityID);
                logInfoCurrent.ExecutiveBy   = userName;
                logInfoCurrent.ExecutiveByID = userID;
                logInfoCurrent.ExecutiveTime = DateTime.Now;
                logInfoCurrent.Content       = Content;
                logInfoCurrent.Conclusion    = 1;
                logInfoCurrent.RefIDType     = RefIDType;
                logInfoCurrent.Status        = currentStep.Status;
                UpdateLog(logInfoCurrent);
            }

            if (nextStep != null)    //下一步骤非空, insert下一条日志的提交人
            {
                ProcessStepLogInfo logInfoNext = new ProcessStepLogInfo(nextStep, RefID, userID, userName, DateTime.Now);
                logInfoNext.ExecutiveByID = nextUserID;
                logInfoNext.ExecutiveBy   = nextUserName;
                SaveLog(logInfoNext);
            }

            return(true);
        }
        /// <summary>
        /// 作废业务单据时要终止流程,此时记日志,审批结果为“作废”
        /// </summary>
        /// <param name="currentStep"></param>
        /// <param name="RefID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="Content"></param>
        /// <param name="RefIDType"></param>
        /// <returns></returns>
        public bool SaveNullifyLog(ProcessStepEntityInfo currentStep, long RefID, int userID, string userName, string Content, int RefIDType = 0)
        {
            ProcessStepLogInfo logInfoCurrent = GetStepLogByRefID(currentStep.ProcessEntityID);

            logInfoCurrent.ExecutiveBy   = userName;
            logInfoCurrent.ExecutiveByID = userID;
            logInfoCurrent.ExecutiveTime = DateTime.Now;
            logInfoCurrent.Content       = Content;
            logInfoCurrent.Conclusion    = 2;
            logInfoCurrent.RefIDType     = RefIDType;
            logInfoCurrent.Status        = "已作废";
            UpdateLog(logInfoCurrent);

            return(true);
        }
 /// <summary>
 /// 获取流程实例当前步骤
 /// </summary>
 /// <param name="RefID">业务单据ID</param>
 /// <returns></returns>
 public ProcessStepEntityInfo GetCurrentStepByRefID(Int64 RefID, string RefType)
 {
     try
     {
         ProcessStepEntityInfo entity = SqlMapDAL.CreateNameQuery("GetCurrentStepByRefID").SetParameter("RefID", RefID).SetParameter("RefType", RefType).Entity <ProcessStepEntityInfo>();
         if (entity != null && entity.ProcessStepModelID != Guid.Empty)
         {
             entity.Relatives = GetRelatives(entity.ProcessStepModelID);
         }
         return(entity);
     }
     catch
     {
         return(null);
     }
 }
        /// <summary>
        /// 执行审核操作
        /// </summary>
        /// <param name="currentStep"></param>
        /// <param name="RefID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="Content"></param>
        /// <param name="Conclusion"></param>
        /// <param name="RefIDType"></param>
        /// <returns></returns>
        public bool SetApprove(ProcessStepEntityInfo currentStep, long RefID, int userID, string userName, int nextUserID, string nextUserName, string Content = "", int Conclusion = 0, int RefIDType = 0)
        {
            //上一步骤,下一步骤
            ProcessStepEntityInfo preStep  = GetPreviousStep(currentStep.ProcessEntityID, currentStep.StepNum);
            ProcessStepEntityInfo nextStep = GetNextStep(currentStep.ProcessEntityID, currentStep.StepNum);

            if (Conclusion == 1)
            {
                // 通过
                SetApproveStatusApprove(currentStep.ProcessEntityID, currentStep.Status, userID, userName, nextUserID, nextUserName);
                SaveApproveLog(currentStep, preStep, nextStep, RefID, userID, userName, nextUserID, nextUserName, Content, RefIDType);
            }
            else
            {
                // 打回
                SetApproveStatusFail(currentStep.ProcessEntityID, preStep.Status, userID, userName);
                SaveFailLog(currentStep, preStep, RefID, userID, userName, Content, RefIDType);
            }
            return(true);
        }
        /// <summary>
        /// 保存打回日志
        /// </summary>
        /// <param name="currentStep"></param>
        /// <param name="RefID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="Content"></param>
        /// <param name="Conclusion"></param>
        /// <param name="RefIDType"></param>
        /// <returns></returns>
        private bool SaveFailLog(ProcessStepEntityInfo currentStep, ProcessStepEntityInfo preStep, long RefID, int userID, string userName, string Content = "", int RefIDType = 0)
        {
            //------日志---------
            ProcessStepLogInfo logInfoCurrent = GetStepLogByRefID(currentStep.ProcessEntityID);//该表单待更新的日志

            logInfoCurrent.ExecutiveBy   = userName;
            logInfoCurrent.ExecutiveByID = userID;
            logInfoCurrent.ExecutiveTime = DateTime.Now;
            logInfoCurrent.Content       = Content;
            logInfoCurrent.Conclusion    = 0;
            logInfoCurrent.RefIDType     = RefIDType;
            logInfoCurrent.Status        = preStep.Status;
            UpdateLog(logInfoCurrent);
            if (preStep != null)    //上一步骤非空, insert 下一条日志的提交人
            {
                ProcessStepLogInfo logInfoNext = new ProcessStepLogInfo(preStep, RefID, userID, userName, DateTime.Now);
                SaveLog(logInfoNext);
            }

            return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// 审核(通过、打回都在此处理)
        /// </summary>
        /// <param name="RefID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="Content"></param>
        /// <param name="Conclusion"></param>
        /// <param name="RefIDType"></param>
        /// <returns></returns>
        public override bool Approve(long RefID, int Status, int userID, string userName, int nextUserID, string nextUserName, string Content = "", int Conclusion = 0, int RefIDType = 0)
        {
            ResourceRequestInfo resource = SqlMapDAL.CreateNameQuery("GetMyResourceInfo").SetParameter("RequestID", RefID).Entity <ResourceRequestInfo>();

            if (resource == null || resource.Status != Status)
            {
                return(false);
            }

            ProcessStepEntityInfo currentStep = base.GetCurrentStepByRefID(RefID, "资源申请业务流程");

            if (currentStep != null)
            {
                try
                {
                    int RequestUserType = GetRequestUserType(resource.RequestByID);////审核申请,当前用户不一定是申请人,要用任务的申请人

                    //上一步骤,下一步骤
                    ProcessStepEntityInfo prevStep = GetProcessStep(currentStep.ProcessEntityID, currentStep.StepNum - 1);
                    ProcessStepEntityInfo nextStep = GetProcessStep(currentStep.ProcessEntityID, currentStep.StepNum + 1);

                    int nextStatus = resource.Status + (Conclusion == 1 ? 1 : -1);
                    switch (RequestUserType)
                    {
                    case 1:
                        if (currentStep.StepNum == 1)
                        {
                            // 所内用户提交请求,自动进行1,2,3步骤
                            base.SetApprove(currentStep, RefID, userID, userName, 0, "", Content, Conclusion, RefIDType);
                            base.SetApprove(nextStep, RefID, userID, userName, 0, "", "所内用户申请,自动通过审批", Conclusion, RefIDType);
                            nextStep = GetProcessStep(currentStep.ProcessEntityID, currentStep.StepNum + 2);
                            base.SetApprove(nextStep, RefID, userID, userName, nextUserID, nextUserName, "所内用户申请,自动通过审批", Conclusion, RefIDType);
                            nextStatus = 3;
                        }
                        else if (currentStep.StepNum == 4 && Conclusion == 0)
                        {
                            // 所内用户请求中心主任分派步骤打回,直接打回至请求用户(即作废请求)
                            base.SetApprove(currentStep, RefID, userID, userName, 0, "", Content, Conclusion, RefIDType);
                            prevStep   = null;
                            nextStatus = 0;
                        }
                        else if (currentStep.StepNum == 6 && Conclusion == 1)
                        {
                            // 所内用户请求中心主任审核步骤通过,直接通过至请求人
                            base.SetApprove(currentStep, RefID, userID, userName, 0, "", Content, Conclusion, RefIDType);
                            base.SetApprove(nextStep, RefID, userID, userName, 0, "", "所内用户申请,自动通过审批", Conclusion, RefIDType);
                            nextStep = GetProcessStep(currentStep.ProcessEntityID, currentStep.StepNum + 2);
                            base.SetApprove(nextStep, RefID, userID, userName, nextUserID, nextUserName, "所内用户申请,自动通过审批", Conclusion, RefIDType);
                            nextStep   = null;
                            nextStatus = 8;
                        }
                        else
                        {
                            base.SetApprove(currentStep, RefID, userID, userName, nextUserID, nextUserName, Content, Conclusion, RefIDType);
                        }
                        break;

                    case 2:
                        if (currentStep.StepNum == 1)
                        {
                            // 科技厅系统内用户,自动进行1,2步骤
                            base.SetApprove(currentStep, RefID, userID, userName, 0, "", Content, Conclusion, RefIDType);
                            base.SetApprove(nextStep, RefID, userID, userName, nextUserID, nextUserName, "厅系统内部用户申请,自动通过审批", Conclusion, RefIDType);
                            nextStatus = 2;
                        }
                        else if (currentStep.StepNum == 3 && Conclusion == 0)
                        {
                            // 科技厅系统内用户请求所领导分发步骤打回,直接打回至请求用户
                            base.SetApprove(currentStep, RefID, userID, userName, 0, "", Content, Conclusion, RefIDType);
                            prevStep   = null;
                            nextStatus = 0;
                        }
                        else if (currentStep.StepNum == 7 && Conclusion == 1)
                        {
                            // 科技厅系统内用户请求所领导审核步骤通过,直接通过至请求人
                            base.SetApprove(currentStep, RefID, userID, userName, 0, "", Content, Conclusion, RefIDType);
                            base.SetApprove(prevStep, RefID, userID, userName, nextUserID, nextUserName, "厅系统内部用户申请,自动通过审批", Conclusion, RefIDType);
                            nextStep   = null;
                            nextStatus = 8;
                        }
                        else
                        {
                            base.SetApprove(currentStep, RefID, userID, userName, nextUserID, nextUserName, Content, Conclusion, RefIDType);
                        }
                        break;

                    case 3:
                        // 普通外部用户
                        base.SetApprove(currentStep, RefID, userID, userName, nextUserID, nextUserName, Content, Conclusion, RefIDType);
                        break;

                    default:
                        // 普通外部用户
                        base.SetApprove(currentStep, RefID, userID, userName, nextUserID, nextUserName, Content, Conclusion, RefIDType);
                        break;
                    }
                    // 更新单据状态
                    UpdateRequestStatus(RefID, nextStatus);

                    #region 发送通知
                    int    reciever;
                    string message;
                    if (Conclusion == 1)
                    {
                        if (nextStep != null)
                        {
                            // 通过,通知下一步执行人
                            reciever = nextUserID;
                            message  = "有新的资源请求【" + resource.Title + "】,请及时处理。";
                            MessageBLL.SendTask(userID, reciever.ToString(), message, "/RS/Resource/ResourceTaskList");
                        }
                        else
                        {
                            // 归档,通知资源申请人
                            reciever = resource.RequestByID;
                            message  = "您的资源请求【" + resource.Title + "】已完成,请下载查看。";
                            MessageBLL.SendMessage(userID, reciever.ToString(), message, "/RS/Resource/ResourceList");
                        }
                    }
                    else
                    {
                        if (prevStep != null)
                        {
                            // 打回,通知上一步执行人
                            reciever = prevStep.ExecutiveByID;
                            message  = "资源请求【" + resource.Title + "】被打回,请及时处理";
                            MessageBLL.SendTask(userID, reciever.ToString(), message, "/RS/Resource/ResourceTaskList");
                        }
                        else
                        {
                            // 打回,通知资源申请人
                            reciever = resource.RequestByID;
                            message  = "您的资源请求【" + resource.Title + "】被驳回,请知悉。";
                            MessageBLL.SendMessage(userID, reciever.ToString(), message, "/RS/Resource/ResourceTaskList");
                        }
                    }
                    #endregion

                    return(true);
                }
                catch (Exception e)
                {
                    LogUtility.WriteLog("审核操作失败:" + e.Message);
                    return(false);
                }
            }
            return(true);
        }