示例#1
0
        //TODO IOC GlobalWeatherSoap
        //private readonly GlobalWeather.GlobalWeatherSoap _client;
        public string GetCitiesJSON(string country)
        {
            GlobalWeather.GlobalWeatherSoapClient _client = new GlobalWeather.GlobalWeatherSoapClient();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(_client.GetCitiesByCountry(country));
            string jsonText = JsonConvert.SerializeXmlNode(doc);

            return(jsonText);
        }
示例#2
0
        public string GetWeatherJSON(string country, string city, out string mode)
        {
            GlobalWeather.GlobalWeatherSoapClient _client = new GlobalWeather.GlobalWeatherSoapClient();
            XmlDocument doc    = new XmlDocument();
            var         result = _client.GetWeather(city, country);

            if (result == "Data Not Found")
            {
                var soaClient = new WebClient();
                mode = "openweathermap";
                return(soaClient.DownloadString($"{ConfigurationManager.AppSettings["MFM:openweathermap.URL"]}?q={city},{country}&units=metric&appid={ConfigurationManager.AppSettings["MFM:openweathermap.Key"]}"));
            }
            doc.LoadXml(result);
            mode = "GlobalWeather";
            return(JsonConvert.SerializeXmlNode(doc));
        }