public static UserLogonReq ParseToEntity(System.Xml.Linq.XElement requestElement)
        {
            UserLogonReq req = new UserLogonReq();

            IEnumerable<XElement> elements = requestElement.Descendants("parameter");

            /*
             <req>
  <head>
<msgType>UserLogon</msgType>
<msgPlace>100</msgPlace>
  </head>
  <body>
<parameter>
      <name>loginName</name>
      <value>13500000000</value>
</parameter>
<parameter>
      <name>userType</name>
      <value>1</value>
</parameter>
  </body>
</req>
             */

            foreach (XElement e in elements)
            {
                try
                {
                    string name = e.Element("name").Value;
                    string value = e.Element("value").Value;
                    MapToEntity(req, name, value);
                }
                catch
                {
                    continue;
                }
            }

            return req;

            //XmlSerializer ser = new XmlSerializer(typeof(UserLogonReq));
            //StringReader reader = new StringReader(requestElement.ToString());
            //object obj = ser.Deserialize(reader);
            //if (obj != null && obj is UserLogonReq)
            //    return obj as UserLogonReq;

            //return null;
        }
        public UserLogonResp DoWithUserLogon(UserLogonReq request)
        {
            using (AspirecnUserCenterEntities context = new AspirecnUserCenterEntities())
            {
                var users = from one in context.t_user_info
                            where one.LoginName == request.loginName
                            && one.Password == request.password
                            select one;

                if (users != null && users.Count() > 0)
                {
                    var user = users.First();
                    if (user != null)
                    {
                        return this.ParseToUserLogonResp(user);
                    }
                }
            }

            return new UserLogonResp() { hRet = -1 };

               // return null;
        }
        private static void MapToEntity(UserLogonReq req, string name, string value)
        {
            if (name.Equals("loginName", StringComparison.InvariantCultureIgnoreCase))
            {
                req.loginName = value;
            }

            if (name.Equals("userType", StringComparison.InvariantCultureIgnoreCase))
            {
                req.userType = value;
            }
            
            if (name.Equals("password", StringComparison.InvariantCultureIgnoreCase))
            {
                req.password = value;
            }

            if (name.Equals("deviceId", StringComparison.InvariantCultureIgnoreCase))
            {
                req.deviceId = value;
            }

            if (name.Equals("channelId", StringComparison.InvariantCultureIgnoreCase))
            {
                req.channelId = value;
            }

        }
        public UserLogonResp RequestLogon(UserLogonReq request)
        {
            UserLogonResp response = new UserLogonResp()
            {
                hRet = 0,
                user_info = new user_info_schema()
                {
                    userId = request.loginName,
                    loginName = request.loginName
                }
            };

            return response;
        }