示例#1
0
        /// <summary>
        /// 获取城市天气详情信息
        /// </summary>
        /// <param name="cityId">天气城市代号</param>
        /// <returns>城市天气详情信息</returns>
        public CityWeather GetCityWeather(string cityId)
        {
            string getUrl     = string.Format("http://wthrcdn.etouch.cn/WeatherApi?citykey={0}", cityId);
            string weatherXml = SimulateRequest.HttpClientGet(getUrl, true);

            if (string.IsNullOrWhiteSpace(weatherXml))
            {
                throw new WeatherException(-200, "请求到的天气数据Xml为空!");
            }
            CityWeather cityWeather = XmlConvert.DeserializeObject <CityWeather>(weatherXml);

            return(cityWeather);
        }