public static async Task <List <MyFeed> > GetMyFeeds(string stunum_other, int page = 0, int size = 15) { //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())); paramList.Add(new KeyValuePair <string, string>("stunum_other", stunum_other.ToString())); //string response = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/Article/searchtrends", paramList); string response = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/NewArticle/searchtrends", paramList); Debug.WriteLine(response); List <MyFeed> feeds = new List <MyFeed>(); 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++) { MyFeed f = new MyFeed(); f.GetAttributes((JObject)bbddarray[i]); feeds.Add(f); } } } } catch (Exception) { } return feeds; })); return(null); }
private async void getItem(object e) { if (e is MyFeed) { Item = e as MyFeed; } else if (e is MyNotification) { Item = new MyFeed(); Item.content = (e as MyNotification).article_content; Item.type_id = "5"; Item.id = (e as MyNotification).article_id; Item = await CommunityMyContentService.GetFeed(5, (e as MyNotification).article_id); } }
public static async Task <MyFeed> GetFeed(int type_id, string article_id) { //TODO:未登陆时 不添加参数stuNum和idNum 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>("type_id", type_id.ToString())); paramList.Add(new KeyValuePair <string, string>("article_id", article_id.ToString())); string response = await NetWork.getHttpWebRequest(api, paramList); Debug.WriteLine(response); try { if (response != "" || response != "[]") { JObject bbddfeeds = JObject.Parse(response); if (bbddfeeds["status"].ToString() == "200") { JObject feed = (JObject)bbddfeeds["data"][0]; MyFeed f = new MyFeed(); f.GetAttributes(feed, true); return(f); } } } catch (Exception) { } return(null); }
private async void getMark() { string id = ""; string type_id = ""; if (ViewModel.Item != null) { id = ViewModel.Item.id; type_id = ViewModel.Item.type_id; } else { type_id = "5"; id = (ee.Parameter as MyNotification).article_id; } //if (ViewModel.BBDD != null) //{ // id = ViewModel.BBDD.id; // type_id = ViewModel.BBDD.type_id; //} //else //{ // id = ViewModel.hotfeed.article_id; // type_id = ViewModel.hotfeed.type_id; //} //TODO:未登陆时 不添加参数stuNum和idNum var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >(); paramList.Add(new KeyValuePair <string, string>("article_id", id)); paramList.Add(new KeyValuePair <string, string>("type_id", type_id)); //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)); paramList.Add(new KeyValuePair <string, string>("size", "15")); paramList.Add(new KeyValuePair <string, string>("page", remarkPage.ToString())); string mark = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/Home/ArticleRemark/getremark", paramList); Debug.WriteLine(mark); try { if (mark != "") { JObject obj = JObject.Parse(mark); if (Int32.Parse(obj["state"].ToString()) == 200) { //markList.Clear(); JArray markListArray = Utils.ReadJso(mark); if (markListArray.Count != 0) { isfirst = false; NoMarkGrid.Visibility = Visibility.Collapsed; if (ViewModel.Item != null) { //ViewModel.Item.remark_num = markListArray.Count.ToString(); if (type_id == "5") { MyFeed x = await CommunityMyContentService.GetFeed(int.Parse(type_id), id); //MyFeed y = ee.Parameter as MyFeed; //y.remark_num = x.remark_num; //var z = ViewModel.Item.remark_num; ViewModel.Item.remark_num = x.remark_num; } } //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.remark_num = ViewModel.BBDD.remark_num; //} for (int i = 0; i < markListArray.Count; i++) { Mark Markitem = new Mark(); Markitem.GetListAttribute((JObject)markListArray[i]); markList.Add(Markitem); } remarkPage++; } else if (isfirst) { NoMarkGrid.Visibility = Visibility.Visible; } issend = false; } } } catch (Exception) { } isMark2Peo = false; }