Ejemplo n.º 1
0
 private commentdetail getdetail(int commentid)
 {
     try
     {
         commentdetail detail  = new commentdetail();
         comment       comment = result.commentContentArr[commentid];
         detail.cid       = comment.cid;;
         detail.content   = comment.content;
         detail.userName  = comment.userName;
         detail.userID    = comment.userID;
         detail.postDate  = comment.postDate;
         detail.userImg   = comment.userImg;
         detail.userClass = comment.userClass;
         detail.quoteId   = comment.quoteId;
         detail.count     = comment.count;
         detail.ups       = comment.ups;
         detail.downs     = comment.downs;
         if (comment.quoteId != 0)
         {
             comment pcomment = result.commentContentArr[comment.quoteId];
             detail.pcid      = pcomment.cid;
             detail.pcontent  = pcomment.content;
             detail.puserName = pcomment.userName;
             detail.puserID   = pcomment.userID;
             detail.ppostDate = pcomment.postDate;
             detail.pquoteId  = pcomment.quoteId;
             detail.pcount    = pcomment.count;
         }
         return(detail);
     }
     catch { return(null); }
 }
        private async Task getList()
        {
            islistbusy          = true;
            indicator.IsVisible = true;
            try
            {
                using (Stream stream = await new HttpHelp().Get(string.Format(StaticData.mention, page)))
                {
                    StreamReader sr  = new StreamReader(stream);
                    JObject      obj = JObject.Parse(sr.ReadToEnd());

                    if (!(bool)obj["success"])
                    {
                        if ((string)obj["message"] != null)
                        {
                            MessageBox.Show((string)obj["message"]);
                        }
                        indicator.IsVisible = false;
                        return;
                    }

                    int totalPage = (int)obj["totalPage"];
                    if (page < totalPage)
                    {
                        page++;
                    }
                    else
                    {
                        page = 0;
                    }

                    List <int>    commentList = new List <int>();
                    List <ACItem> contentList = new List <ACItem>();
                    foreach (var commentid in (obj["commentList"] as JArray))
                    {
                        commentList.Add((int)commentid);
                    }
                    foreach (var content in (obj["contentList"] as JArray))
                    {
                        contentList.Add(new ACItem((string)content["title"], (string)content["url"], (string)content["comments"], TimeFuc.getTime((long)content["releaseDate"]).ToString(), (string)content["username"], (string)content["description"]));
                    }
                    foreach (var item in obj["commentContentArr"].Values())
                    {
                        if (!commentContentArr.ContainsKey(item.ToObject <comment>().cid))
                        {
                            commentContentArr.Add(item.ToObject <comment>().cid, item.ToObject <comment>());
                        }
                    }

                    if (commentList.Count > 0)
                    {
                        for (int i = 0; i < commentList.Count; i++)
                        {
                            try
                            {
                                Mention item = new Mention();

                                item.title  = contentList[i].title;
                                item.href   = contentList[i].href;
                                item.dis    = contentList[i].dis;
                                item.time   = contentList[i].time;
                                item.name   = contentList[i].name;
                                item.beizhu = contentList[i].beizhu;

                                comment comment = commentContentArr[commentList[i]];

                                item.content  = comment.content;
                                item.userName = comment.userName;
                                item.postDate = comment.postDate;
                                item.userImg  = comment.userImg;
                                item.count    = comment.count;

                                if (comment.quoteId != 0)
                                {
                                    comment pcomment = commentContentArr[comment.quoteId];
                                    item.pcontent  = pcomment.content;
                                    item.puserName = pcomment.userName;
                                    item.ppostDate = pcomment.postDate;
                                    item.pcount    = pcomment.count;
                                }

                                MentionList.Add(item);
                            }
                            catch { }
                        }
                    }
                }
            }
            catch { }
            islistbusy          = false;
            indicator.IsVisible = false;
        }