Пример #1
0
        //启动流程
        public APResult CreateProcess(APParameter app)
        {
            APResult result = new APResult();
            string email = string.Empty;
            string l_strtitle = "";
            StuffUserBLL stuffuserbll = new StuffUserBLL();
            StringBuilder l_strbody = new StringBuilder();
            OUTreeBLL outreebll = new OUTreeBLL();
            string Deptment = outreebll.GetFlowParameter(app.OrganizationUnitID);
            Dictionary<string, object> Dictionary = app.Dic;
            Dictionary["Department"] = Deptment;
            AuthorizationDS.PositionRow position = outreebll.GetPositionById(app.PositionID);
            if (position.IsFlowLevelNull()) {
                Dictionary["FlowLevel"] = "";
            } else {
                Dictionary["FlowLevel"] = position.FlowLevel;
            }
            string ProcID = AP.createProcess(app.FormNo + ":" + DateTime.Now.ToString(), new AuthorizationBLL().GetFlowTemplateNameByFormTypeAndUserID(app.FormTypeID, app.UserID), Dictionary);
            result.ProcID = ProcID;

            string[] InTurn = AP.startProcess(ProcID, app.OrganizationUnitID, ref email).Split('&');//不同流程角色下的人员和职位
            string ids = "";
            string pids = "";
            for (int a = 0; a < InTurn.Length; a++) {
                ids += InTurn[a].Split('$')[0].ToString();///人员
                pids += InTurn[a].Split('$')[1].ToString();//职位
            }
            result.ApprovedDate = DateTime.Now;
            result.InTurnUserIds = ids;//下一步的人员
            result.InTurnPositionIds = pids;//下一步的人员职位
            result.StatusID = (int)SystemEnums.FormStatus.Awaiting;
            //自动审批下一个节点是自己的
            if (!(ids.IndexOf("27") >= 0)) {
                if (ids.IndexOf(app.UserID.ToString()) > 0) {
                    APResult approveresult = ApproveForm(app, app.FormID, app.UserID, stuffuserbll.GetStuffUserById(app.UserID)[0].StuffName, true, "", "", ProcID);
                    result.InTurnUserIds = approveresult.InTurnUserIds;
                    result.InTurnPositionIds = approveresult.InTurnPositionIds;
                }
            }

            try {
                if (!string.IsNullOrEmpty(email)) {
                    //QueryDS.FormViewRow l_drformView = new FormQueryBLL().GetFormViewByID(app.FormID);
                    l_strtitle = "有一份单据编号为:" + app.FormNo + ",等待您的审批!";
                    l_strbody.Append("您好,<br>");
                    l_strbody.Append("&nbsp;&nbsp;您有一份" + new StuffUserBLL().GetStuffUserById(app.UserID)[0].StuffName + "提交的单据,编号为:" + app.FormNo + ",等待您的审批!");

                    l_strbody.Append("<br>此邮件请勿回复!");
                    mailBody = string.Format(mailBody, l_strbody.ToString());
                    sendMail(email, "", l_strtitle, mailBody);
                    //AP.sendMail(emailTo, "", l_strtitle, mailBody);
                }
            } catch {
            }
            return result;
        }
Пример #2
0
        public APResult ApproveForm(APParameter app, int formID, int stuffUserId, string stuffName, bool pass, string comment, string ProxyStuffName, string proctID)
        {
            APResult result = new APResult();
            string email = string.Empty;
            try {
                string l_strtitle = "";
                StringBuilder l_strbody = new StringBuilder();
                FormTableAdapter TAMainForm = new FormTableAdapter();
                //FormDS.FormRow formRow = TAMainForm.GetDataByID(formID)[0];

                string returnValue = AP.approve(pass, comment, stuffUserId.ToString(), stuffName, proctID, ProxyStuffName, app.OrganizationUnitID, ref email,false);
                // UtilityBLL ubll = new UtilityBLL();
                string[] approveinfo = AP.GetProcessApproveUser(proctID);
                if (returnValue != null) {
                    string[] InTurn = returnValue.Split('&');//不同流程角色下的人员和职位
                    string ids = "";
                    string pids = "";
                    for (int a = 0; a < InTurn.Length; a++) {
                        ids += InTurn[a].Split('$')[0].ToString();///人员
                        pids += InTurn[a].Split('$')[1].ToString();//职位
                    }
                    result.InTurnUserIds = ids;//下一步的人员
                    result.InTurnPositionIds = pids;//下一步的人员职位
                }
                #region 发送邮件
                try {
                    QueryDS.FormViewRow l_drformView = new FormQueryBLL().GetFormViewByID(formID);
                    if (pass) {
                        if (!string.IsNullOrEmpty(returnValue)) {
                            l_strtitle = "有一份" + l_drformView.FormTypeName + "单据,编号为:" + l_drformView.FormNo + ",等待您的审批!";
                            l_strbody.Append("您好,<br>");
                            l_strbody.Append("&nbsp;&nbsp;有一份" + l_drformView.StuffName + "提交的" + l_drformView.FormTypeName + "单据,编号:" + l_drformView.FormNo + ",等待您的审批!");
                            l_strbody.Append("<br>此邮件请勿回复!");
                            mailBody = string.Format(mailBody, l_strbody.ToString());
                            sendMail(email, "", l_strtitle, mailBody);
                            //AP.sendMail(emailTo, "", l_strtitle, mailBody);
                        } else {
                            l_strtitle = "您的" + l_drformView.FormTypeName + "单据,编号为:" + l_drformView.FormNo + ",已审批完成!";
                            l_strbody.Append("您好,<br>");
                            l_strbody.Append("&nbsp;&nbsp;您于" + l_drformView.SubmitDate.ToString("yyyy-MM-dd") + "提交的" + l_drformView.FormTypeName + "单据,编号:" + l_drformView.FormNo + ",已经审批通过!");
                            l_strbody.Append("<br>此邮件请勿回复!");
                            mailBody = string.Format(mailBody, l_strbody.ToString());
                            sendMail(AuthorizationBLL.GetStuffUserById(app.UserID).EMail, "", l_strtitle, mailBody);
                            //AP.sendMail(emailTo, "", l_strtitle, mailBody);
                        }
                    } else {
                        l_strtitle = "您的" + l_drformView.FormTypeName + "单据,编号为:" + l_drformView.FormNo + ",被驳回!";
                        l_strbody.Append("您好,<br>");
                        l_strbody.Append("&nbsp;&nbsp;您于" + l_drformView.SubmitDate.ToString("yyyy-MM-dd") + "提交的" + l_drformView.FormTypeName + "单据,编号:" + l_drformView.FormNo + ",被" + stuffName + "驳回!");
                        l_strbody.Append("<br>此邮件请勿回复!");
                        mailBody = string.Format(mailBody, l_strbody.ToString());
                        sendMail(AuthorizationBLL.GetStuffUserById(app.UserID).EMail, "", l_strtitle, mailBody);
                        //AP.sendMail(emailTo, "", l_strtitle, mailBody);
                    }
                } catch {

                }
                #endregion

                return result;
            } catch (Exception ex) {
                throw ex;
            }
        }