protected override async void OnNavigatedTo(NavigationEventArgs e) { foreach (var card in Card.ProcessCards((await Api.GetFeed()).Cards)) { Cards.Add(card); } }
public async Task get_feed() { var args = new GetFeedArgs { Account = User.Login, StartEntryId = 0, Limit = 10 }; var resp = await Api.GetFeed(args, CancellationToken.None); TestPropetries(resp); }
public void get_feed() { var resp = Api.GetFeed(User.Login, 0, 10, CancellationToken.None); WriteLine(resp); Assert.IsFalse(resp.IsError); var obj = Api.CustomGetRequest <JArray>(KnownApiNames.Follow, "get_feed", new object[] { User.Login, 0, 10 }, CancellationToken.None); TestPropetries(resp.Result.GetType(), obj.Result); WriteLine("----------------------------------------------------------------------------"); WriteLine(obj); }
public void get_feed() { var resp = Api.GetFeed(User.Login, 0, 10, CancellationToken.None); Console.WriteLine(resp.Error); Assert.IsFalse(resp.IsError); Console.WriteLine(JsonConvert.SerializeObject(resp.Result)); var obj = Api.CallRequest <JArray>(KnownApiNames.FollowApi, "get_feed", new object[] { User.Login, 0, 10 }, CancellationToken.None); TestPropetries(resp.Result.GetType(), obj.Result); Console.WriteLine("----------------------------------------------------------------------------"); Console.WriteLine(JsonConvert.SerializeObject(obj)); }
public void get_feed() { var args = new GetFeedArgs() { Account = User.Login, StartEntryId = 0, Limit = 10, }; var resp = Api.GetFeed(args, CancellationToken.None); WriteLine(resp); Assert.IsFalse(resp.IsError); var obj = Api.CustomGetRequest <JObject>(KnownApiNames.FollowApi, "get_feed", args, CancellationToken.None); TestPropetries(resp.Result.GetType(), obj.Result); WriteLine("----------------------------------------------------------------------------"); WriteLine(obj); }
public async Task get_feed() { var resp = await Api.GetFeed(User.Login, 0, 10, CancellationToken.None); TestPropetries(resp); }
private void DoGetFeed() { DateTime?lastNotification = null; bool haveUser; using (var ctx = _db.OpenContext()) { using (var reader = ctx.ExecuteReader("SELECT last_notification FROM user")) { haveUser = reader.Read(); if (haveUser) { lastNotification = DbUtil.ParseDateTime(reader.GetString(0)); } } ctx.Commit(); } var feed = _api.GetFeed(lastNotification); using (var ctx = _db.OpenContext()) { string name = feed.User.Name; int points = feed.User.Points; int badgesBronze = 0; int badgesSilver = 0; int badgesGold = 0; lastNotification = feed.Notifications.Select(p => (DateTime?)p.DateTime).Max() ?? lastNotification; foreach (var badge in feed.User.Badges) { switch (badge.Type) { case "bronze": badgesBronze = badge.Count; break; case "silver": badgesSilver = badge.Count; break; case "gold": badgesGold = badge.Count; break; } } string sql; if (haveUser) { sql = "UPDATE user SET name = @name, points = @points, badges_bronze = @badges_bronze, badges_silver = @badges_silver, badges_gold = @badges_gold, last_notification = @last_notification"; } else { sql = "INSERT INTO user (name, points, badges_bronze, badges_silver, badges_gold, last_notification) VALUES (@name, @points, @badges_bronze, @badges_silver, @badges_gold, @last_notification)"; } ctx.ExecuteNonQuery( sql, ("@name", name), ("@points", points), ("@badges_bronze", badgesBronze), ("@badges_silver", badgesSilver), ("@badges_gold", badgesGold), ("@last_notification", DbUtil.PrintDateTimeOpt(lastNotification)) ); foreach (var notification in feed.Notifications) { ctx.ExecuteNonQuery( "INSERT INTO notification (datetime, kind, user, poster, title, message, parentid, postid) VALUES (@datetime, @kind, @user, @poster, @title, @message, @parentid, @postid)", ("@datetime", DbUtil.PrintDateTime(notification.DateTime)), ("@kind", notification.Kind), ("@user", notification.User), ("@poster", notification.Poster), ("@title", notification.Title), ("@message", notification.Message), ("@parentid", notification.ParentId), ("@postid", notification.PostId) ); notification.Id = ctx.LastInsertRowId; } ctx.Commit(); } OnFeedUpdated(new FeedEventArgs(feed)); }