예제 #1
0
        public override bool Equals(object obj)
        {
            MobileTerm term = obj as MobileTerm;

            if (term != null)
            {
                return(this.RoomId == term.RoomId);
            }
            else
            {
                return(base.Equals(obj));
            }
        }
        public bool TryGetMobileTermList(Model.HandlerSession session, DateTime from, DateTime to, out List<Model.MobileTerm> mobileTermList)
        {
            mobileTermList = new List<MobileTerm>();
            try
            {
                session.AddMessageId();
                string xmlData = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><mobileTermList><messageId>{0}</messageId><token>{1}</token><startTime>{2}</startTime><endTime>{3}</endTime></mobileTermList>",
                                                session.MessageId,
                                                session.Token,
                                                from.ToString("yyyy-MM-dd HH:mm:ss"),
                                                to.ToString("yyyy-MM-dd HH:mm:ss"));
                //logger.Debug(string.Format("TryGetMobileTermList, xmldata: {0}", xmlData));
                var response = this._client.DoHttpWebRequest(session.BaseUrl + "mobileTermList", xmlData);
                ////logger.Debug(string.Format("TryGetMobileTermList response, xmldata: {0}", response.OuterXml));
                XmlNode root = response.SelectSingleNode("mobileTermList");
                string status = root.SelectSingleNode("result").InnerText;

                if (status == "200")
                {
                    foreach (var item in root.SelectNodes("roomInfo"))
                    {
                        var node = item as XmlNode;
                        var term = new MobileTerm();
                        term.RoomId = node.SelectSingleNode("roomId").InnerText;
                        term.RoomName = node.SelectSingleNode("roomName").InnerText;

                        mobileTermList.Add(term);
                    }

                    return true;
                }
                else
                {
                    //logger.Error(string.Format("TryGetMobileTermList failed, status: {0}, error:{1}", status, response.InnerXml));
                    this.ReLogin(session, root.SelectSingleNode("result"));
                    return false;
                }
            }
            catch (Exception ex)
            {
                //logger.Error("TryGetMobileTermList failed, error:" + ex.Message + "\n" + ex.StackTrace);
                this.Login(ref session);

            }

            return false;
        }