Пример #1
0
        /// <summary>
        /// The as weather forecast.
        /// </summary>
        /// <param name="forecastReturn">
        /// The forecast return.
        /// </param>
        /// <returns>
        /// The <see cref="WeatherForecast"/>.
        /// </returns>
        public static WeatherForecast AsWeatherForecast(this ForecastReturn forecastReturn)
        {
            var result = new WeatherForecast
            {
                City   = forecastReturn.WeatherStationCity,
                State  = forecastReturn.State,
                Result = forecastReturn.ResponseText
            };

            if (forecastReturn.Success)
            {
                foreach (var day in forecastReturn.ForecastResult)
                {
                    result.Forecast.Add(day.AsForecastEntry());
                }
            }

            return(result);
        }
Пример #2
0
        public string getWeather(string zip)
        {
            WeatherS.ServiceReference1.WeatherSoapClient w = new WeatherS.ServiceReference1.WeatherSoapClient();
            //var v=w.GetCityForecastByZIP(TextBox1.Text);
            XmlDocument xmlDoc = new XmlDocument();

            ForecastReturn fr = w.GetCityForecastByZIP(zip);
            string         s  = "";

            for (int i = 0; i < fr.ForecastResult.Length; i++)
            {
                s += "Date " + fr.ForecastResult.ElementAt(i).Date.ToString() + "<br/>";
                s += "weatherID " + fr.ForecastResult.ElementAt(i).WeatherID.ToString() + "<br/>";
                s += "Description " + fr.ForecastResult.ElementAt(i).Desciption.ToString() + "<br/>";
                s += "Temperatures" + " Morning Low " + fr.ForecastResult.ElementAt(i).Temperatures.MorningLow.ToString() + "\t" + "Daytime High " + fr.ForecastResult.ElementAt(i).Temperatures.DaytimeHigh.ToString() + "<br/>";
                s += "Probability of Precipitation " + "Nighttime " + fr.ForecastResult.ElementAt(i).ProbabilityOfPrecipiation.Nighttime.ToString() + "\t" + " Daytime " + fr.ForecastResult.ElementAt(i).ProbabilityOfPrecipiation.Daytime.ToString() + "<br/>";
            }
            string s1 = "State= " + fr.State + "\n" + "City= " + fr.City + "\n" + "Weather Station City=" + fr.WeatherStationCity + "\n" + s;

            return(s1);
        }