示例#1
0
        public string GetStartProcessXML(string requestor, string operate, string processName, string groupName, string keyXml, string data, string infoSource)
        {
            try
            {
                DataSet dsr, osr;
                if (requestor.ToLower() == operate.ToLower())
                {
                    dsr = K2DBHelper.GetEmployeeInfoByUserAd(requestor);
                    osr = dsr;
                }
                else
                {
                    dsr = K2DBHelper.GetEmployeeInfoByUserAd(requestor);
                    osr = K2DBHelper.GetEmployeeInfoByUserAd(operate);
                }

                if (dsr.Tables.Count == 0 || osr.Tables.Count == 0)
                {
                    throw new Exception("未取得申请人或操作人信息!");
                    //return string.Empty;
                }

                if (dsr.Tables[0].Rows.Count == 0 || osr.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("未取得申请人或操作人信息!");
                    //return string.Empty;
                }

                RequestDefinition.Request request = new RequestDefinition.Request();
                request.RequestorAD    = requestor;
                request.OperatorAD     = operate;
                request.Department     = dsr.Tables[0].Rows[0]["DepartCode"].ToString();
                request.DepartmentName = dsr.Tables[0].Rows[0]["DepartName"].ToString();
                request.RequestorEmail = dsr.Tables[0].Rows[0]["Email"].ToString();
                request.RequestorTel   = dsr.Tables[0].Rows[0]["OfficePhone"].ToString();
                request.WorkSpace      = "ALL"; //由于PWorld没有Based地点概念,故此处写为ALL
                request.Operator       = osr.Tables[0].Rows[0]["EmployeeName"].ToString();
                request.Requestor      = dsr.Tables[0].Rows[0]["EmployeeName"].ToString();
                request.OperatorEmail  = osr.Tables[0].Rows[0]["Email"].ToString();
                request.OperatorTel    = osr.Tables[0].Rows[0]["OfficePhone"].ToString();

                string xml = SerializationHelper.Serialize(request);
                xml = xml.Insert(xml.IndexOf("</Request>"), keyXml + data);
                string approveNodeXml = WS.K2.K2Rule.GetApproveNodeXML(processName, groupName, xml);
                string retXml         = WS.K2.K2Rule.GetApproveXML(requestor, approveNodeXml, xml, infoSource); //取得最终的xml

                //记录日志
                K2DBHelper.RecordGetApproveXML(requestor, operate, processName, groupName, keyXml, data, retXml);

                return(retXml);
            }
            catch (Exception ex)
            {
                K2DBHelper.RecoreErrorProfile(ex, "K2HelperWS.GetStartProcessXML", requestor);
                return(ex.Message);
            }
        }