Esempio n. 1
0
        private List <WallEntry> buildEntryList(XmlDocument x)
        {
            XmlNodeList msgsNodes = x.SelectNodes("/response/post");

            if (msgsNodes != null)
            {
                List <WallEntry> msgList = new List <WallEntry>();
                foreach (XmlNode msgNode in msgsNodes)
                {
                    XmlUtils.UseNode(msgNode);
                    WallEntry wall = new WallEntry();
                    wall.Id           = XmlUtils.Int("id");
                    wall.Body         = XmlUtils.String("text");
                    wall.FromUser     = XmlUtils.Int("from_id");
                    wall.ToUser       = XmlUtils.Int("to_id");
                    wall.Date         = CommonUtils.FromUnixTime(XmlUtils.String("date"));
                    wall.Online       = ((XmlUtils.String("online")) == "1"? true: false);
                    wall.Attachment   = this.getAttachment(msgNode.SelectSingleNode("attachment"));
                    wall.CopyOwnerId  = XmlUtils.Int("copy_owner_id");
                    wall.CopyPostId   = XmlUtils.Int("copy_post_id");
                    wall.LikesInfo    = LikesFactory.GetLikesInfo(msgNode.SelectSingleNode("likes"));
                    wall.CommentsInfo = CommentsFactory.GetCommentsInfo(msgNode.SelectSingleNode("comments"));
                    if (XmlUtils.Int("reply_count") != -1)
                    {
                        wall.RepliesCount = XmlUtils.Int("reply_count");
                    }
                    msgList.Add(wall);
                }
                return(msgList);
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ownerId"></param>
        /// <param name="postId"></param>
        /// <param name="sortOrder"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <EntryComment> GetComments(int?ownerId, int postId, SortOrder sortOrder, int?offset, int?count)
        {
            this.Manager.Method("wall.getComments");
            if (ownerId != null)
            {
                this.Manager.Params("owner_id", ownerId);//((type == MessageType.Outgoing) ? "1" : "0"));;
            }
            this.Manager.Params("post_id", postId);
            if (sortOrder != null)
            {
                this.Manager.Params("sort", ((sortOrder == SortOrder.Asc)?"asc":"desc"));
            }
            if (offset != null)
            {
                this.Manager.Params("offset", offset);
            }
            if (count != null)
            {
                this.Manager.Params("count", count);
            }
            string resp = this.Manager.Execute().GetResponseString();

            if (this.Manager.MethodSuccessed)
            {
                XmlDocument x     = this.Manager.GetXmlDocument(resp);
                XmlNodeList nodes = x.SelectNodes("/response/comment");
                if (nodes.Count > 0)
                {
                    List <EntryComment> comments = new List <EntryComment>();
                    foreach (XmlNode node in nodes)
                    {
                        EntryComment c = CommentsFactory.GetEntryComment(node);
                        comments.Add(c);
                    }
                    return(comments);
                }
                return(null);
            }
            return(null);
        }