コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string str      = value.ToString();
            long   timespan = Int64.Parse(str);

            return(TimeFuc.getTime(timespan).ToString());
        }
コード例 #2
0
        private async Task Search(string query, int count)
        {
            var page = 1;

            if (count == 1)
            {
                listdata.Clear();
            }
            else
            {
                page = count;
            }

            try
            {
                indicator.IsVisible = true;
                using (var stream = await new HttpHelp().Get(string.Format(StaticData.search, query, page)))
                {
                    var json = JObject.Parse(await new StreamReader(stream).ReadToEndAsync());
                    if (nextcount < Int32.Parse(json["totalpage"].ToString()))
                    {
                        nextcount++;
                    }
                    var array = json["contents"] as JArray;
                    foreach (var item in array)
                    {//ACItem(string title, string url, string dis, string time, string name, string beizhu)
                        listdata.Add(new ACItem(
                                         item["title"].ToString(),
                                         "/a/ac" + item["id"].ToString(),
                                         item["comments"].ToString(),
                                         TimeFuc.getTime(long.Parse(item["releaseDate"].ToString())).ToString(),
                                         item["username"].ToString(),
                                         item["sign"].ToString()));
                    }
                }
            }
            catch { }
            indicator.IsVisible = false;
        }
コード例 #3
0
        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;
        }