public static async Task <HotFeed> GetHotFeed(int type_id, string article_id)
        {
            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>("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.ToString()));
            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];
                        HotFeed f    = new HotFeed();
                        f.GetAttributes(feed);
                        return(f);
                    }
                }
            }
            catch (Exception) { }
            return(null);
        }
        public static async Task<HotFeed> GetHotFeed(int type_id, string article_id)
        {
            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>("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.ToString()));
            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];
                        HotFeed f = new HotFeed();
                        f.GetAttributes(feed);
                        return f;
                    }
                }
            }
            catch (Exception) { }
            return null;

        }
Beispiel #3
0
 public static async Task <List <HotFeed> > GetHot(int type = 0, 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 <HotFeed> feeds = new List <HotFeed>();
         try
         {
             if (response != "" || response != "[]")
             {
                 JArray hotfeed = JArray.Parse(response);
                 for (int i = 0; i < hotfeed.Count; i++)
                 {
                     JObject hot = (JObject)hotfeed[i];
                     if (hot["status"].ToString() == "200")
                     {
                         JObject data = (JObject)hot["data"];
                         HotFeed f = new HotFeed();
                         f.GetAttributes(data);
                         feeds.Add(f);
                     }
                 }
             }
         }
         catch (Exception) { }
         return feeds;
     }));
 }
        public static async Task<List<HotFeed>> GetHot(int type = 0, 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<HotFeed> feeds = new List<HotFeed>();
               try
               {
                   if (response != "" || response != "[]")
                   {
                       JArray hotfeed = JArray.Parse(response);
                       for (int i = 0; i < hotfeed.Count; i++)
                       {
                           JObject hot = (JObject)hotfeed[i];
                           if (hot["status"].ToString() == "200")
                           {
                               JObject data = (JObject)hot["data"];
                               HotFeed f = new HotFeed();
                               f.GetAttributes(data);
                               feeds.Add(f);
                           }
                       }
                   }
               }
               catch (Exception) { }
               return feeds;
           });
        }