public void addPosts() { int loaded = 0; List <Item> items = new List <Item>(); if (postCapasity <= 99) { WallGet response = WallGet.FromJson(API.getResponse("wall.get", "owner_id=-" + id + ",offset=2" + ",count=" + postCapasity.ToString())); foreach (Item item in response.Response.Items) { items.Add(item); } } else { while (postCapasity - loaded > 99) { WallGet response1 = WallGet.FromJson(API.getResponse("wall.get", "owner_id=-" + id + ",offset=" + loaded.ToString() + ",count=99")); loaded = loaded + 99; foreach (Item item in response1.Response.Items) { items.Add(item); } if (response1.Response.Items.Length < 99) { goto GA; } } WallGet response = WallGet.FromJson(API.getResponse("wall.get", "owner_id=-" + id + ",offset=" + loaded.ToString() + ",count=" + (postCapasity - loaded).ToString())); foreach (Item item in response.Response.Items) { items.Add(item); } } GA: foreach (Item item in items) { try { Post post = new Post(); post.id = item.Id.ToString(); post.item = item; post.already_posted = false; post.hist = new Queue <HistoryPoint>(historyVolume); HistoryPoint point = new HistoryPoint(); point.likes = Convert.ToInt32(item.Likes.Count); point.reposts = Convert.ToInt32(item.Reposts.Count); point.views = Convert.ToInt32(item.Views.Count); point.time = Convert.ToInt32(item.Date); post.hist.Enqueue(point); post = setFirstPoints(post); post.domain = domain; post.groupId = id; posts.Enqueue(post); } catch { } } }
public void updatePosts() { try { WallGet response = WallGet.FromJson(API.getResponse("wall.get", "owner_id=-" + id + ",count=" + postCapasity.ToString())); foreach (Item item in response.Response.Items) { for (int i = 0; i < posts.Count; i++) { if (posts.ElementAt(i).id == item.Id.ToString()) { HistoryPoint point = new HistoryPoint(); point.likes = Convert.ToInt32(item.Likes.Count); point.reposts = Convert.ToInt32(item.Reposts.Count); if (item.Views == null) { point.views = 0; } else { point.views = Convert.ToInt32(item.Views.Count); } point.time = Convert.ToInt32(item.Date); posts.ElementAt(i).hist.Enqueue(point); setFirstPoints(posts.ElementAt(i)); if (posts.ElementAt(i).hist.Count > historyVolume) { posts.ElementAt(i).hist.Dequeue(); } } } } foreach (Item item in response.Response.Items) { bool is_new = true; for (int i = 0; i < posts.Count; i++) { if (posts.ElementAt(i).id == item.Id.ToString()) { is_new = false; } } if (is_new) { new_post = true; Post post = new Post(); post.id = item.Id.ToString(); post.item = item; post.already_posted = false; HistoryPoint point = new HistoryPoint(); point.likes = Convert.ToInt32(item.Likes.Count); point.reposts = Convert.ToInt32(item.Reposts.Count); if (item.Views == null) { point.views = 0; } else { point.views = Convert.ToInt32(item.Views.Count); } point.time = Convert.ToInt32(item.Date); post.hist = new Queue <HistoryPoint>(historyVolume); post.hist.Enqueue(point); post = setFirstPoints(post); post.domain = domain; post.groupId = id; posts.Enqueue(post); posts.Dequeue(); } } } catch { } }