示例#1
0
        //审批
        public void Approve(WorkFlowExecutionContext ec)
        {
            string phid = ec.BillInfo.PK1;

            IUserFacade facade = new SpringObject().GetObject <IUserFacade>("DMC3.Rights.Facade.User");

            List <UserApproveRightsModel> userApproveRights = new List <UserApproveRightsModel>();

            string    billno      = dac.GetHrRightApplyBillNo(phid);
            DataTable applicantDt = dac.GetApplicantDt(billno);

            for (int i = 0; i < applicantDt.Rows.Count; i++)
            {
                UserApproveRightsModel model = new UserApproveRightsModel();
                model.LoginOrgs    = new List <long>();
                model.InfoOrgs     = new List <long>();
                model.UserOrgRoles = new List <UserApproveRightsModel.UserOrgRole>();
                model.HrId         = long.Parse(applicantDt.Rows[i]["hrid"].ToString());
                model.UserId       = long.Parse(applicantDt.Rows[i]["userid"].ToString());
                model.DeptId       = long.Parse(dac.GetApplicantDeptId(model.HrId));
                DataTable OrgDt = GetOrgInfo(model.UserId.ToString(), billno);
                for (int j = 0; j < OrgDt.Rows.Count; j++)
                {
                    if ((bool)OrgDt.Rows[j]["select"] == true)
                    {
                        long orgid = long.Parse(OrgDt.Rows[j]["orgid"].ToString());
                        if (OrgDt.Rows[j]["applicantorg"].ToString() == "登录组织/信息组织")
                        {
                            model.LoginOrgs.Add(orgid);
                            model.InfoOrgs.Add(orgid);
                        }
                        else if (OrgDt.Rows[j]["applicantorg"].ToString() == "信息组织")
                        {
                            model.InfoOrgs.Add(orgid);
                        }
                    }
                }

                DataTable roleDt = dac.GetRoleDtByBillNoNUserId(billno, model.UserId.ToString());
                for (int k = 0; k < roleDt.Rows.Count; k++)
                {
                    UserApproveRightsModel.UserOrgRole userOrgRole = new UserApproveRightsModel.UserOrgRole();
                    userOrgRole.OrgId  = long.Parse(roleDt.Rows[k]["orgid"].ToString());
                    userOrgRole.RoleId = long.Parse(roleDt.Rows[k]["roleid"].ToString());
                    model.UserOrgRoles.Add(userOrgRole);
                }

                userApproveRights.Add(model);
            }

            facade.SaveUserApproveRights(userApproveRights);

            dac.UpdateWorkFlowCheckPsnDate(ec.BillInfo.PK1);
        }