Пример #1
0
        private void StackPanel_Tapped(object sender, TappedRoutedEventArgs e)
        {
            //if (appSetting.Values.ContainsKey("idNum"))
            var vault          = new Windows.Security.Credentials.PasswordVault();
            var credentialList = vault.FindAllByResource(resourceName);

            credentialList[0].RetrievePassword();
            if (credentialList.Count > 0)
            {
                BBDDFeed b = ((StackPanel)sender).DataContext as BBDDFeed;
                App.ViewModel                   = ViewModel;
                App.CommunityPivotState         = CommunityPivot.SelectedIndex;
                App.CommunityScrollViewerOffset = BBDDScrollViewer.VerticalOffset;
                isPersonInfo = true;
                Frame.Navigate(typeof(CommunityPersonInfo), b.stunum);
            }
            else
            {
                var msgPopup = new Data.loginControl("登录即可查看他人动态~");
                msgPopup.LeftClick  += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); };
                msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); };
                msgPopup.ShowWIndow();
            }
        }
Пример #2
0
        private async void LikeButton_Click(object sender, RoutedEventArgs e)
        {
            //TODO:未登陆时 不能点赞
            //if (appSetting.Values.ContainsKey("idNum"))
            try
            {
                var vault          = new Windows.Security.Credentials.PasswordVault();
                var credentialList = vault.FindAllByResource(resourceName);
                credentialList[0].RetrievePassword();
                if (credentialList.Count > 0)
                {
                    var    b      = sender as Button;
                    string num_id = b.TabIndex.ToString();
                    Debug.WriteLine(num_id);
                    Debug.WriteLine("id " + num_id.Substring(2));
                    string like_num = "";
                    if (ViewModel.BBDD != null)
                    {
                        BBDDFeed bbddfeed = ViewModel.BBDD;
                        if (bbddfeed.is_my_like == "true" || bbddfeed.is_my_like == "True")
                        {
                            like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), false);

                            if (like_num != "")
                            {
                                bbddfeed.like_num   = like_num;
                                bbddfeed.is_my_like = "false";
                                //if (args is HotFeed)
                                //{
                                //    HotFeed h = args as HotFeed;
                                //    h.like_num = like_num;
                                //    h.is_my_Like = "false";
                                //}
                            }
                        }
                        else
                        {
                            like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), true);

                            if (like_num != "")
                            {
                                bbddfeed.like_num   = like_num;
                                bbddfeed.is_my_like = "true";
                                //if (args is HotFeed)
                                //{
                                //    HotFeed h = args as HotFeed;
                                //    h.like_num = like_num;
                                //    h.is_my_Like = "true";
                                //}
                            }
                        }
                    }

                    if (ViewModel.hotfeed != null)
                    {
                        HotFeed hotfeed = ViewModel.hotfeed;
                        if (hotfeed.is_my_Like == "true" || hotfeed.is_my_Like == "True")
                        {
                            like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), false);

                            if (like_num != "")
                            {
                                hotfeed.like_num   = like_num;
                                hotfeed.is_my_Like = "false";
                                //if (args is HotFeed)
                                //{
                                //    HotFeed h = args as HotFeed;
                                //    h.like_num = like_num;
                                //    h.is_my_Like = "false";
                                //}
                            }
                        }
                        else
                        {
                            like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), true);

                            if (like_num != "")
                            {
                                hotfeed.like_num   = like_num;
                                hotfeed.is_my_Like = "true";
                                //if (args is HotFeed)
                                //{
                                //    HotFeed h = args as HotFeed;
                                //    h.like_num = like_num;
                                //    h.is_my_Like = "true";
                                //}
                            }
                        }
                    }
                }
                else
                {
                    var msgPopup = new Data.loginControl("您还没有登录 无法点赞~");
                    msgPopup.LeftClick  += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); };
                    msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); };
                    msgPopup.ShowWIndow();
                }
            }
            catch
            {
                var msgPopup = new Data.loginControl("您还没有登录 无法点赞~");
                msgPopup.LeftClick  += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); };
                msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); };
                msgPopup.ShowWIndow();
            }
        }
Пример #3
0
        private async void liskButton_Click(object sender, RoutedEventArgs e)
        {
            //TODO:未登陆时 不能点赞
            //if (appSetting.Values.ContainsKey("idNum"))
            try
            {
                var vault          = new Windows.Security.Credentials.PasswordVault();
                var credentialList = vault.FindAllByResource(resourceName);
                credentialList[0].RetrievePassword();
                if (credentialList.Count > 0)
                {
                    var b = sender as Button;

                    string num_id = b.TabIndex.ToString();
                    Debug.WriteLine(num_id);
                    Debug.WriteLine("id " + num_id.Substring(2));
                    string like_num = "";
                    try
                    {
                        if (int.Parse(num_id[0].ToString()) < 5) //hot
                        {
                            HotFeed hotfeed = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2)));
                            if (hotfeed.is_my_Like == "true" || hotfeed.is_my_Like == "True")
                            {
                                like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), false);

                                if (like_num != "")
                                {
                                    hotfeed.like_num   = like_num;
                                    hotfeed.is_my_Like = "false";
                                    if (ViewModel.BBDD.Count(p => p.id.Equals(num_id.Substring(2))) != 0)
                                    {
                                        BBDDFeed s = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2)));
                                        if (s != null)
                                        {
                                            s.like_num   = like_num;
                                            s.is_my_like = "false";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), true);

                                if (like_num != "")
                                {
                                    hotfeed.like_num   = like_num;
                                    hotfeed.is_my_Like = "true";
                                    if (ViewModel.BBDD.Count(p => p.id.Equals(num_id.Substring(2))) != 0)
                                    {
                                        BBDDFeed s = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2)));
                                        if (s != null)
                                        {
                                            s.like_num   = like_num;
                                            s.is_my_like = "true";
                                        }
                                    }
                                }
                            }
                        }
                        else if (num_id[0] == '5') //bbdd
                        {
                            BBDDFeed bbddfeed = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2)));
                            if (bbddfeed.is_my_like == "true" || bbddfeed.is_my_like == "True")
                            {
                                like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), false);

                                if (like_num != "")
                                {
                                    bbddfeed.like_num   = like_num;
                                    bbddfeed.is_my_like = "false";
                                    if (ViewModel.HotFeeds.Count(p => p.article_id.Equals(num_id.Substring(2))) != 0)
                                    {
                                        HotFeed h = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2)));
                                        if (h != null)
                                        {
                                            h.like_num   = like_num;
                                            h.is_my_Like = "false";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), true);

                                if (like_num != "")
                                {
                                    bbddfeed.like_num   = like_num;
                                    bbddfeed.is_my_like = "true";
                                    if (ViewModel.HotFeeds.Count(p => p.article_id.Equals(num_id.Substring(2))) != 0)
                                    {
                                        HotFeed h = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2)));
                                        if (h != null)
                                        {
                                            h.like_num   = like_num;
                                            h.is_my_Like = "true";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        Debug.WriteLine("点赞异常");
                    }
                }
                else
                {
                    var msgPopup = new Data.loginControl("您还没有登录 无法点赞~");
                    msgPopup.LeftClick  += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); };
                    msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); };
                    msgPopup.ShowWIndow();
                }
            }
            catch
            {
                var msgPopup = new Data.loginControl("您还没有登录 无法点赞~");
                msgPopup.LeftClick  += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); };
                msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); };
                msgPopup.ShowWIndow();
            }
        }
Пример #4
0
        /// <summary>
        /// 获取动态列表
        /// </summary>
        /// <param name="type">动态参数,重邮新闻cyxw=>1,教务咨询jwzx=>2,xsjz=>3,xwgg=>4,bbdd=>5</param>
        /// <returns>返回参数对应的列表数据</returns>
        public static async Task <List <BBDDFeed> > GetBBDD(int type = 1, int page = 0, int size = 15, int typeid = 5)
        {
            //TODO:未登陆时 不添加参数stuNum和idNum
            return(await Task.Run(async() =>
            {
                List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >();
                try
                {
                    var vault = new Windows.Security.Credentials.PasswordVault();
                    var credentialList = vault.FindAllByResource(resourceName);
                    credentialList[0].RetrievePassword();
                    if (credentialList.Count > 0)
                    {
                        //paramList.Add(new KeyValuePair<string, string>("stuNum", appSetting.Values["stuNum"].ToString()));
                        //paramList.Add(new KeyValuePair<string, string>("idNum", appSetting.Values["idNum"].ToString()));
                        paramList.Add(new KeyValuePair <string, string>("stuNum", credentialList[0].UserName));
                        paramList.Add(new KeyValuePair <string, string>("idNum", credentialList[0].Password));
                    }
                }
                catch
                {
                }
                paramList.Add(new KeyValuePair <string, string>("page", page.ToString()));
                paramList.Add(new KeyValuePair <string, string>("size", size.ToString()));
                if (typeid != 0)
                {
                    paramList.Add(new KeyValuePair <string, string>("type_id", typeid.ToString()));
                }
                string response = await NetWork.getHttpWebRequest(feedsapi[type], paramList);
                //response = Utils.ConvertUnicodeStringToChinese(response);
                List <BBDDFeed> feeds = new List <BBDDFeed>();
                try
                {
                    if (response != "" || response != "[]")
                    {
                        JObject bbddfeeds = JObject.Parse(response);
                        if (bbddfeeds["status"].ToString() == "200")
                        {
                            JArray bbddarray = JArray.Parse(bbddfeeds["data"].ToString());
                            for (int i = 0; i < bbddarray.Count; i++)
                            {
                                BBDDFeed f = new BBDDFeed();
                                f.GetAttributes((JObject)bbddarray[i]);
                                feeds.Add(f);
                            }
                        }
                    }
                }
                catch (Exception) { }
                return feeds;
            }));

            /*    try
             *  {
             *      JArray jsonstr = JArray.Parse(response);
             *
             *      List<BBDDFeed> feedslist = new List<BBDDFeed>();
             *
             *      for (int j = 0; j < jsonstr.Count; j++)
             *      {
             *          JObject jsondetail = (JObject)(jsonstr[j]);
             *          if (jsondetail["status"].ToString() == "200")
             *          {
             *              JObject jo = (JObject)jsondetail["data"];
             *              BBDDFeed f = new BBDDFeed();
             *              f.GetAttributes(jo);
             *              feedslist.Add(f);
             *          }
             *      }
             *      return feedslist;
             *  }
             *  catch (Newtonsoft.Json.JsonReaderException)
             *  {
             *      List<BBDDFeed> feedslist = new List<BBDDFeed>();
             *      JObject jsonobj = JObject.Parse(response);
             *      if (jsonobj["status"].ToString() == "200")
             *      {
             *          string jsonstr = jsonobj["data"].ToString();
             *          JArray feedsarray = Utils.ReadJso(response);
             *          for (int i = 0; i < feedsarray.Count; i++)
             *          {
             *              JObject f = (JObject)feedsarray[i];
             *              BBDDFeed fd = new BBDDFeed();
             *              fd.GetAttributes(f);
             *              feedslist.Add(fd);
             *          }
             *          return feedslist;
             *      }
             *  }
             *  catch (InvalidCastException e)
             *  {
             *      Debug.WriteLine(e.Message);
             *  }
             */
            return(null);
        }