Exemplo n.º 1
0
        public async void GetUserAttention(int pageNum)
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                IsLoading          = true;


                string results = await WebClientClass.GetResults(new Uri("https://api.bilibili.com/x/relation/followings?vmid=" + Uid + "&ps=20&pn=" + pageNum + "&order=desc&jsonp=json"));

                //一层
                GetUserFollow model1 = JsonConvert.DeserializeObject <GetUserFollow>(results);
                if (model1.code == 0)
                {
                    //二层
                    // GetUserAttention model2 = JsonConvert.DeserializeObject<GetUserAttention>(model1.data.ToString());
                    // MaxPage = model2.pages;
                    //三层
                    //  List<GetUserAttention> lsModel = JsonConvert.DeserializeObject<List<GetUserAttention>>(model2.list.ToString());
                    foreach (GetUserFollow item in model1.data.list)
                    {
                        list_AUser.Items.Add(item);
                    }
                    page++;
                }
                else
                {
                    Utils.ShowMessageToast(model1.message, 2000);
                }
            }
            catch (Exception)
            {
                if (list_AUser.Items.Count == 0)
                {
                    Utils.ShowMessageToast("没有关注任何人", 2000);
                }
                else
                {
                    Utils.ShowMessageToast("读取关注失败!", 2000);
                }
                //await new MessageDialog("读取关注失败!\r\n" + ex.Message).ShowAsync();
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
                IsLoading          = false;
            }
        }
Exemplo n.º 2
0
        private GetUserFollow GetGetUserFollow(DataRow dataRow)
        {
            GetUserFollow getUserFollow = new GetUserFollow
            {
                Qusitonid       = Convert.ToInt32(dataRow["Qusitonid"]),
                Askerid         = Convert.ToInt32(dataRow["Askerid"]),
                AskTime         = Convert.ToDateTime(dataRow["AskTime"].ToString()),
                UpAskTime       = Convert.ToDateTime(dataRow["UpAskTime"].ToString()),
                QusitionTitle   = dataRow["QusitonTitle"].ToString(),
                QusitionContent = dataRow["QusitonContent"].ToString(),
                Answerednum     = Convert.ToInt32(dataRow["Answerednum"]),
                Followednum     = Convert.ToInt32(dataRow["Followednum"]),
                Qlabel0         = dataRow["QLabel0"].ToString(),
                Qlabel1         = dataRow["QLabel1"].ToString(),
                Qlabel2         = dataRow["QLabel2"].ToString(),
                FollowQTime     = Convert.ToDateTime(dataRow["FollowQTime"].ToString())
            };

            return(getUserFollow);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到某个人关注的全部问题
        /// </summary>
        /// <param name="Userid"></param>
        /// <returns></returns>
        public string GetUserFQ(int Userid)
        {
            SqlConnection sqlConnection = new SqlConnection(connectionstring);

            sqlConnection.Open();
            try
            {
                string sql = "select Qusitonid,FollowQTime,UpAskTime," +
                             " Askerid,AskTime,QusitonTitle,QusitonContent,Answerednum,Followednum,QLabel0,QLabel1,QLabel2 " +
                             "from QusitonFollowTable inner join QusitonTable" +
                             " on QusitonFollowTable.Userid=@Userid and QusitonFollowTable.Qusitionid = QusitonTable.Qusitonid and QusitonFollowTable.Qusitionid not in " +
                             "(select Qusitonid from AnswerTable where AnswerTable.Userid = @LUserid) ORDER BY FollowQTime desc";
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                sqlCommand.CommandText = sql;
                sqlCommand.Parameters.AddWithValue("@Userid", Userid);
                sqlCommand.Parameters.AddWithValue("@LUserid", Userid);
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter
                {
                    SelectCommand = sqlCommand
                };
                DataTable dataTable = new DataTable();
                sqlDataAdapter.Fill(dataTable);
                List <GetUserFollow> qusitions = new List <GetUserFollow>();
                GetUserFollow        getUserFollow;
                foreach (DataRow item in dataTable.Rows)
                {
                    getUserFollow = new GetUserFollow();
                    getUserFollow = GetGetUserFollow(item);
                    qusitions.Add(getUserFollow);
                }
                return(JsonConvert.SerializeObject(qusitions));
            }
            catch (SqlException)
            {
                return(string.Empty);
            }
            finally
            {
                sqlConnection.Close();
            }
        }