/// <summary> /// Updates the mention, trend or SIR lists according to the message type. /// </summary> /// <param name="message"></param> private void UpdateLists(Message message) { // Update the relevant lists switch (message.MessageType) { case "E": URLList.Clear(); foreach (var item in processor.QuarantinedLinks) { URLList.Add("Link: " + item.Key.ToString() + "\nCount: " + item.Value.ToString()); } Email email = (Email)message; if (email.EmailType == "SIR") { SIRList.Clear(); SIR sir = (SIR)email; // Loop through SIRList and Add new instances foreach (var item in processor.SirList) { SIRList.Add("Sort Code: " + item.Key.ToString() + "\nCount: " + item.Value.ToString()); } } break; case "T": MentionList.Clear(); TrendList.Clear(); foreach (var item in processor.MentionsList) { MentionList.Add("Mention: " + item.Key.ToString() + "\nCount: " + item.Value.ToString()); } foreach (var item in processor.TrendingList) { TrendList.Add("Trend: " + item.Key.ToString() + "\nCount : " + item.Value.ToString()); } break; default: break; } }
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; }