Esempio n. 1
0
        /// <summary>
        /// 根据帐号获取员工信息
        /// </summary>
        /// <param name="loginAccount"></param>
        /// <returns></returns>
        public string GetEmployeeInfo(string loginAccount)
        {
            StringBuilder StrReturn = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.OmitXmlDeclaration = true;
            try
            {
                using (XmlWriter writer = XmlWriter.Create(StrReturn, settings))
                {
                    using (CommDal<T_HR_EMPLOYEE> cdl = new CommDal<T_HR_EMPLOYEE>())
                    {
                        var ents = from ent in cdl.GetObjects<T_HR_EMPLOYEE>()
                                   where ent.EMPLOYEEENAME == loginAccount
                                   select ent;
                        if (ents.Count() > 0)
                        {
                            EmployeeModel employee = new EmployeeModel();

                            if (ents.FirstOrDefault() != null)
                            {
                                T_HR_EMPLOYEE UserInfo = ents.FirstOrDefault();
                                employee = GetSingelEmployee(UserInfo.EMPLOYEEID);
                                if (employee != null)
                                {

                                    writer.WriteStartElement("BizRegReq");
                                    writer.WriteStartElement("Employee");
                                    writer.WriteAttributeString("EmployeeId", employee.EmployeeId);
                                    writer.WriteAttributeString("EmployeeName", employee.EmployeeName);
                                    writer.WriteAttributeString("LoginAccount", employee.LoginAccount);
                                    writer.WriteAttributeString("Sex", employee.Sex);
                                    //writer.WriteAttributeString("Age", "");
                                    writer.WriteAttributeString("PostName", employee.PostName);
                                    writer.WriteAttributeString("Email", employee.Email);
                                    writer.WriteAttributeString("Address", employee.Address);
                                    writer.WriteAttributeString("AddCode", "");//没有默认为空
                                    writer.WriteAttributeString("Mobile", employee.Mobile);
                                    writer.WriteAttributeString("Tel", employee.Tel);
                                    writer.WriteAttributeString("Nation", "");
                                    writer.WriteAttributeString("Province", "");
                                    writer.WriteAttributeString("City", "");
                                    writer.WriteAttributeString("PostID", employee.PostID);
                                    writer.WriteAttributeString("Remark", employee.Remark);
                                    writer.WriteAttributeString("CompanyName", employee.CompanyName);
                                    writer.WriteEndElement();//完成Employee节点
                                    writer.WriteEndElement();//完成BizRegReq节点

                                }
                                else
                                {
                                    ErrorMessage(writer, "没有获取到该员工信息");
                                }
                            }
                            else
                            {
                                ErrorMessage(writer, "没有获取到该员工信息");
                            }
                        }
                        else
                        {
                            ErrorMessage(writer, "没有获取到该员工信息");

                        }
                        writer.Flush();
                    }
                }


            }
            catch (Exception ex)
            {
                using (XmlWriter catchError = XmlWriter.Create(StrReturn, settings))
                {
                    ErrorMessage(catchError, "服务器错误");
                    Tracer.Debug("即时通讯-GetEmployeeInfo:" + ex.ToString() + System.DateTime.Now);
                    catchError.Flush();
                }
            }
            return StrReturn.ToString().Replace("\r", "").Replace("\n", "");
        }
Esempio n. 2
0
        /// <summary>
        /// 根据帐号获取员工信息
        /// </summary>
        /// <param name="loginAccount"></param>
        /// <returns></returns>
        public string GetEmployeeInfo(string loginAccount)
        {
            StringBuilder     StrReturn = new StringBuilder();
            XmlWriterSettings settings  = new XmlWriterSettings();

            settings.Indent             = true;
            settings.OmitXmlDeclaration = true;
            try
            {
                using (XmlWriter writer = XmlWriter.Create(StrReturn, settings))
                {
                    using (CommDal <T_HR_EMPLOYEE> cdl = new CommDal <T_HR_EMPLOYEE>())
                    {
                        var ents = from ent in cdl.GetObjects <T_HR_EMPLOYEE>()
                                   where ent.EMPLOYEEENAME == loginAccount
                                   select ent;
                        if (ents.Count() > 0)
                        {
                            EmployeeModel employee = new EmployeeModel();

                            if (ents.FirstOrDefault() != null)
                            {
                                T_HR_EMPLOYEE UserInfo = ents.FirstOrDefault();
                                employee = GetSingelEmployee(UserInfo.EMPLOYEEID);
                                if (employee != null)
                                {
                                    writer.WriteStartElement("BizRegReq");
                                    writer.WriteStartElement("Employee");
                                    writer.WriteAttributeString("EmployeeId", employee.EmployeeId);
                                    writer.WriteAttributeString("EmployeeName", employee.EmployeeName);
                                    writer.WriteAttributeString("LoginAccount", employee.LoginAccount);
                                    writer.WriteAttributeString("Sex", employee.Sex);
                                    //writer.WriteAttributeString("Age", "");
                                    writer.WriteAttributeString("PostName", employee.PostName);
                                    writer.WriteAttributeString("Email", employee.Email);
                                    writer.WriteAttributeString("Address", employee.Address);
                                    writer.WriteAttributeString("AddCode", "");//没有默认为空
                                    writer.WriteAttributeString("Mobile", employee.Mobile);
                                    writer.WriteAttributeString("Tel", employee.Tel);
                                    writer.WriteAttributeString("Nation", "");
                                    writer.WriteAttributeString("Province", "");
                                    writer.WriteAttributeString("City", "");
                                    writer.WriteAttributeString("PostID", employee.PostID);
                                    writer.WriteAttributeString("Remark", employee.Remark);
                                    writer.WriteAttributeString("CompanyName", employee.CompanyName);
                                    writer.WriteEndElement(); //完成Employee节点
                                    writer.WriteEndElement(); //完成BizRegReq节点
                                }
                                else
                                {
                                    ErrorMessage(writer, "没有获取到该员工信息");
                                }
                            }
                            else
                            {
                                ErrorMessage(writer, "没有获取到该员工信息");
                            }
                        }
                        else
                        {
                            ErrorMessage(writer, "没有获取到该员工信息");
                        }
                        writer.Flush();
                    }
                }
            }
            catch (Exception ex)
            {
                using (XmlWriter catchError = XmlWriter.Create(StrReturn, settings))
                {
                    ErrorMessage(catchError, "服务器错误");
                    Tracer.Debug("即时通讯-GetEmployeeInfo:" + ex.ToString() + System.DateTime.Now);
                    catchError.Flush();
                }
            }
            return(StrReturn.ToString().Replace("\r", "").Replace("\n", ""));
        }