Esempio n. 1
0
    public XmlDocument GetApprovalInfoByFormID(int FormID)
    {
        MasterData myDS = new MasterData();
        MasterData.ApprovalInfoDataTable tbApprovalInfo = myDS.ApprovalInfo;
        AuthorizationDS.PositionDataTable tbPosition = null;
        int index = 1;

        AuthorizationBLL authBLL = new AuthorizationBLL();
        OUTreeBLL ouBLL = new OUTreeBLL();

        MasterData.ApprovalInfoRow rowApprovalInfo = tbApprovalInfo.NewApprovalInfoRow();

        FormDS.FormRow rowForm = new FormSaleBLL().GetFormByID(FormID)[0];
        rowApprovalInfo.ApprovalInfoID = index++;
        rowApprovalInfo.StuffName = authBLL.GetStuffUserById(rowForm.UserID).StuffName;
        rowApprovalInfo.ApprovalDate = rowForm.SubmitDate.ToString("yyyy-MM-dd HH:mm");
        rowApprovalInfo.Position = ouBLL.GetPositionById(rowForm.PositionID).PositionName;
        rowApprovalInfo.Comment = "";
        rowApprovalInfo.Status = "Submit";
        tbApprovalInfo.AddApprovalInfoRow(rowApprovalInfo);

        if (!rowForm.IsProcIDNull()) {
            APWorkFlow.NodeStatusDataTable nodeTable = new APHelper().getApprovalStatus(rowForm.ProcID);
            foreach (APWorkFlow.NodeStatusRow item in nodeTable) {
                if ((!item.IsSTATUSNull()) && item.STATUS != "ASSIGNED") {
                    rowApprovalInfo = tbApprovalInfo.NewApprovalInfoRow();
                    item.PARTICIPANT = item.PARTICIPANT.Replace("PP", "P");
                    rowApprovalInfo.ApprovalInfoID = index++;
                    int i = 0;
                    foreach (var userid in item.PARTICIPANT.Split('$')[0].Split('P')) {

                        if ((!string.IsNullOrEmpty(userid)) && authBLL.GetStuffUserById(int.Parse(userid)).StuffName.Trim().Equals(item.APPROVED_BY)) {
                            tbPosition = ouBLL.GetPositionsByID(int.Parse(item.PARTICIPANT.Split('$')[1].Split('P')[i]));
                            rowApprovalInfo.Position = tbPosition.Count > 0 ? tbPosition[0].PositionName : "";
                            break;
                        }
                        i++;
                    }
                    rowApprovalInfo.StuffName = item.APPROVED_BY;
                    rowApprovalInfo.ApprovalDate = item.IsCOMPLETED_DATENull() ? "" : item.COMPLETED_DATE;

                    rowApprovalInfo.Comment = item.IsCOMMENTSNull() ? "" : item.COMMENTS;
                    rowApprovalInfo.Status = item.IsSTATUSNull() ? "" : item.STATUS;
                    tbApprovalInfo.AddApprovalInfoRow(rowApprovalInfo);
                }
            }
        }

        return new XmlDataDocument(myDS);
    }
Esempio n. 2
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;
        }