示例#1
0
 public string GetWeatherbyCityName()
 {
     try
     {
         string   cityName             = Request["city"];
         string[] arr                  = new string[23];
         Weather.WeatherWebService web = new Weather.WeatherWebService();
         arr = web.getWeatherbyCityName(cityName);
         List <string> list = arr.ToList();
         var           res  = JsonConvert.SerializeObject(list);
         return("success:" + res.ToString());
     }
     catch (System.TimeoutException ex)
     {
         return("请求超时:" + ex.Message);
     }
     catch (Exception ex)
     {
         return("异常信息:" + ex.Message);
     }
 }
示例#2
0
        public ActionResult GetWeather(string city)
        {
            Weather.WeatherWebService ws = new Weather.WeatherWebService();
            var strlist = ws.getWeatherbyCityName(city);

            if (strlist[8] == "")
            {
                ViewBag.Msg = "The city you inquire for is not supported currently!";
            }
            else
            {
                ViewBag.ImgUrl      = @"/Content/weather/a_" + strlist[8];
                ViewBag.CityName    = strlist[1];
                ViewBag.Temp        = strlist[5];
                ViewBag.General     = strlist[6];
                ViewBag.Wind        = strlist[7];
                ViewBag.Actual      = strlist[10];
                ViewBag.Life        = strlist[11];
                ViewBag.CityDetails = strlist[22];
            }
            return(View());
        }