public async Task QueryLikeNotesTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     List<Note> nr = await mine.QueryLikeNotes(0, result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(nr);
 }
        private async Task QueryActivity()
        {
            UserContentProvider user = new UserContentProvider();
            List<ActivityResult> result = await user.QueryFriendActivities(0, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);


            ActivityResult = new ObservableCollection<ActivityItem>();

            foreach (var item in result)
            {
                ActivityResult.Add(ConvertToActivityItem(item));
            }

            //循环添加数据到20条
            while(ActivityResult.Count <20)
            {
                List<ActivityResult> loop = await user.QueryFriendActivities(ActivityResult[ActivityResult.Count - 1].ActivityId - 1, 
                    GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

                if (loop.Count == 0) break;

                foreach (var item in loop)
                {
                    ActivityResult.Add(ConvertToActivityItem(item));
                }
            }
        }
 public async Task QueryBaseInfoTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     UserBaseInfo mr = await mine.QueryBaseInfo(result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(mr);
 }
 public async Task UnlikeNoteTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     LikeResult nr = await mine.UnlikeNote(1664660, result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(nr);
 }
 public async Task QueryActivitiesTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     //7998636为上一个动态的ID-1的值
     List<ActivityResult> fr = await mine.QueryActivities(7998636, result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(fr);
 }
Exemplo n.º 6
0
        private async void ExecuteLoginCommand(string password)
        {
            UserContext user = new UserContext();
            user.Username = Username;
            user.Password = password;

            UserContentProvider provider = new UserContentProvider();
            LoginResult result =await provider.Login(user.Username, user.Password);
            if(result.Error?.Count >= 0)
            {
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new ShowMessage() { MessageContent = result.Error[0].Message });
            }
            else
            {
                user.UserId = result.Id.ToString();
                user.MobileToken = result.MobileToken;
                user.IsLogin = true;
                user.Avatar = result.Avatar;
                user.Slug = result.Slug;

                this.MessengerInstance.Send(new ChangeView() { FromView = ViewType.Login, ToView= ViewType.Home, Event = EventType.LoginSuccess,Context = user });
            }
        }
 public async Task QueryOtherFollowerTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     List<FollowUserInfo> nr = await mine.QueryFollowers(1, "580197", result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(nr);
 }
Exemplo n.º 8
0
 private async void QueryDetail(string id)
 {
     var temp = Untils.ReadNoteDetial(id);
     if (temp == null)
     {
         UserContentProvider user = new UserContentProvider();
         NoteDetail = await user.QueryNoteDetail(id, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
         Untils.WriteNoteDetial(NoteDetail);
     }
     else
     {
         NoteDetail = temp;
     }
 }
 public async Task QuerySubscriptionTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     List<Subscription> sb = await mine.QuerySubscription(1, result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(sb);
 }
 public async Task QueryMsgCountTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     MsgCountResult nr = await mine.QueryMsgCount(result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(nr);
 }
 public async Task QueryGetFeedsMsgTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     List<FeedsMsgResult> nr = await mine.QueryFeedMsg(result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(nr);
 }
 private async void ExecuteFollowUserCommand(string userid)
 {
     FollowUser follower = FollowerUsers.FirstOrDefault(x => x.Id == userid);
     FollowUser following = FollowingUsers.FirstOrDefault(x => x.Id == userid);
     if(follower?.IsFollowing == true || following?.IsFollowing == true)
     {
         UserContentProvider user = new UserContentProvider();
         FollowResult result = await user.UnFollowUser(userid, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
         if (result.Error == null || result.Error.Count == 0)
         {
             if(follower != null) follower.IsFollowing = false;
             if (following != null) following.IsFollowing = false;
         }
     }
     else
     {
         UserContentProvider user = new UserContentProvider();
         FollowResult result = await user.FollowUser(userid, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
         if (result.Error == null || result.Error.Count == 0)
         {
             if (follower != null) follower.IsFollowing = true;
             if (following != null) following.IsFollowing = true;
         }
     }
 }
        private async Task QueryTopics()
        {            
            if(page == 1)
            {
                if(TopicItems == null)
                {
                    TopicItems = new ObservableCollection<TopicItem>();
                }
                else
                {
                    TopicItems.Clear();
                }
            }

            UserContentProvider user = new UserContentProvider();
            List<DiscoverResult> reuslt = await user.QueryTopic(TypeSelectedItem.Type, page, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

            reuslt.ForEach(x => TopicItems.Add(ConvertToTopicItem(x)));

            page++;
        }
Exemplo n.º 14
0
 public static async Task<bool> SendComment(string commentContent, Tuple<string, string> replyTarget, string noteId)
 {
     UserContentProvider content = new UserContentProvider();
     var result = await content.AddComment(noteId, commentContent, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
     if(result.Error == null || result.Error.Count == 0)
     {
        GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new ShowMessage() { MessageContent = "评论成功!" });
         return true;
     }
     else
     {
         GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new ShowMessage() { MessageContent = "评论失败!" });
         return false;
     }
 }
        private async Task QuerySubscriptions()
        {
            if(subscriptionPage == 1)
            {
                if(SubscriptionItems == null)
                {
                    SubscriptionItems = new ObservableCollection<SubscriptionItem>();
                }
                else
                {
                    SubscriptionItems.Clear();
                }
            }

            UserContentProvider user = new UserContentProvider();
            List<Subscription> reuslt = await user.QuerySubscription(subscriptionPage, currentUserId ,GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

            reuslt.ForEach(x => SubscriptionItems.Add(ConvertToSubscriptionItem(x)));

            subscriptionPage++;

            if (SubscriptionItems.Count <= 10 && subscriptionPage == 2)
            {
                await QuerySubscriptions();
            }
        }
Exemplo n.º 16
0
        private async Task QueryNote(string type)
        {
            UserContentProvider user = new UserContentProvider();
            
            if(type == "喜欢")
            {
                if(likePage == 0)
                {
                    DisplayCollection = new ObservableCollection<NoteItem>();
                    likeList = new List<NoteItem>();
                }

                List<Note> temp = await user.QueryLikeNotes(likePage, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

                temp.ForEach(x =>
                {
                    var v = ConvertToNoteItem(x);
                    likeList.Add(v);
                    DisplayCollection.Add(v);
                });
                likePage++;
            }
            else
            {
                if(markPage == 0)
                {
                    DisplayCollection = new ObservableCollection<NoteItem>();
                    markList = new List<NoteItem>();
                }

                List<BookmarkResult> temp = await user.QueryBookmark(markPage, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
                temp.ForEach(x =>
                {
                    var v = ConvertToNoteItem(x.Note);
                    markList.Add(v);
                    DisplayCollection.Add(v);
                });
            }
        }
        private async Task QueryFollowings()
        {
            if (followingPage == 1)
            {
                if (FollowingUsers == null)
                {
                    FollowingUsers = new ObservableCollection<FollowUser>();
                }
                else
                {
                    FollowingUsers.Clear();
                }
            }
            UserContentProvider user = new UserContentProvider();
            List<FollowUserInfo> result = await user.QueryFollowingUsers(followingPage, currentUserId, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

            result.ForEach(x => FollowingUsers.Add(ConvertToFollowUser(x)));

            followingPage++;

            if(FollowingUsers.Count <= 10 && followingPage == 2)
            {
                await QueryFollowings();
            }
        }
 private async Task QueryBaseInfo()
 {
     if (IsSelf)
     {
         UserContentProvider user = new UserContentProvider();
         baseInfo = await user.QueryBaseInfo(GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
     }
     else
     {
         CommonProvider common = new CommonProvider();
         baseInfo = await common.QueryUserInfo(currentUserId);
     }
     Avatar = new Uri(baseInfo.Avatar);
     FollowerCount = baseInfo.FollowersCount;
     FollowingCount = baseInfo.FollowingCount;
     LikedNotesCount = baseInfo.LikedNotesCount;
     BookmarksCount = baseInfo.BookmarksCount;
     SubscribingCount = baseInfo.SubscribingCollectionsCount + baseInfo.SubscribingNotebooksCount;
     TotalWordage = baseInfo.TotalWordage;
     TotalLikesReceived = baseInfo.TotalLikesReceived;
     NotebooksCount = baseInfo.NotebooksCount;
     currentUserId = baseInfo.Id.ToString();
 }
 private async void ExecuteSubscriptionCommand(int id)
 {
    SubscriptionItem value =  SubscriptionItems.First(x => x.Id == id);
     if(value.IsSubscribed)
     {
         UserContentProvider user = new UserContentProvider();
         DiscoverSubscribeResult reuslt = await user.Unsubscribe(id, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
         if(reuslt.Error == null || reuslt.Error.Count == 0)
         {
             value.IsSubscribed = false;
         }
     }
     else
     {
         UserContentProvider user = new UserContentProvider();
         DiscoverSubscribeResult reuslt = await user.Subscribe(id, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
         if (reuslt.Error == null || reuslt.Error.Count == 0)
         {
             value.IsSubscribed = true;
         }
     }
 }
 public async Task QueryOtherNotebookTest()
 {
     UserContentProvider mine = new UserContentProvider();
     LoginResult result = await mine.Login(Config.username, Config.password);
     List<NotebookResult> nr = await mine.QueryOhterNotebook("580197", 0, result.Id.ToString(), result.MobileToken);
     Assert.IsNotNull(nr);
 }
        private async void LikeClick(object sender, RoutedEventArgs e)
        {
            UserContentProvider user = new UserContentProvider();
            LikeResult reuslt = null;
            if (LikeBtn.Visibility == Visibility.Collapsed)
            {
                reuslt = await user.LikeNote(NoteDetail.Id, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
            }
            else
            {
                reuslt = await user.UnlikeNote(NoteDetail.Id, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
            }

            Untils.UpdateNoteDetail(NoteDetail);

            LikeBtn.Visibility = reuslt.isLiked ? Visibility.Visible : Visibility.Collapsed;
            if (reuslt.isLiked)
            {
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new ShowMessage() { MessageContent = App.Current.Resources["LikeMessage"].ToString() });
            }
            else
            {
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new ShowMessage() { MessageContent = App.Current.Resources["UnlikeMessage"].ToString() });
            }
        }
        private async Task QueryOwnerCollection()
        {
            if(notebookPage == 1)
            {
                if(OwnNotebooks == null)
                {
                    OwnNotebooks = new ObservableCollection<NotebookResult>();
                }
                else
                {
                    OwnNotebooks.Clear();
                }
            }

            UserContentProvider user = new UserContentProvider();
            List<NotebookResult> result;

            if(currentUserId == GlobalValue.CurrentUserContext.UserId)
            {
                result = await user.QueryNotebook(notebookPage, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
            }
            else
            {
                result = await user.QueryOhterNotebook(currentUserId, notebookPage, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
            }

            result.ForEach(x => OwnNotebooks.Add(x));

            notebookPage++;

            if (OwnNotebooks.Count <= 10 && notebookPage == 2)
            {
                await QueryOwnerCollection();
            }
        }
Exemplo n.º 23
0
        private async Task MoreActivity()
        {
            UserContentProvider user = new UserContentProvider();
            List<ActivityResult> result = await user.QueryFriendActivities(
                ActivityResult[ActivityResult.Count - 1].ActivityId - 1, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

            foreach (var item in result)
            {
                ActivityResult.Add(ConvertToActivityItem(item));
            }
        }
Exemplo n.º 24
0
 private async Task QueryDetail(string id)
 {
     UserContentProvider user = new UserContentProvider();
     NoteDetail = await user.QueryNoteDetail(id, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
     Untils.WriteNoteDetial(NoteDetail);
 }
Exemplo n.º 25
0
        private async Task QuerySubscription()
        {
            UserContentProvider user = new UserContentProvider();

            if(pageIndex == 0)
            {
                if(SubscriptionList == null)
                {
                    SubscriptionList = new ObservableCollection<SubscriptionNotesResult>();
                }
                else
                {
                    SubscriptionList.Clear();
                }
            }

            int index = 0;
            if(SubscriptionList.Count !=0)
            {
                index = SubscriptionList[SubscriptionList.Count - 1].ReceivedAt - 1;
            }
            List<SubscriptionNotesResult> result = await user.QuerySubscriptionNotes(index, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);
            result.ForEach(x => SubscriptionList.Add(x));
            pageIndex++;
        }