示例#1
0
        private static WeatherWeek ProcessWeeksWeatherData(WeeksWeatherData daysData)
        {
            WeatherWeek week = new WeatherWeek(DateTime.Now)
            {
                //Store tomorrow's date as 'long date' format: "Thursday, 10 April 2008"
                StartDate = DateTime.Today.ToString("D"),
                EndDate   = DateTime.Today.AddDays(5).ToString("D")
            };

            //Iterate through all weather data retrieved and create BasicWeather objects
            for (int i = 1; i < daysData.cnt; i++)
            {
                DateTime date = UnixTimeStampToDateTime(daysData.list[i].dt);
                //If the current result is for today, process it and store it in today
                if (ValidTimeToday(date))
                {
                    WeatherWeekDay weather = new WeatherWeekDay()
                    {
                        HighTemperature = daysData.list[i].temp.max,
                        LowTemperature  = daysData.list[i].temp.min,
                        IconId          = daysData.list[i].weather[0].icon,
                        WeatherType     = daysData.list[i].weather[0].main,
                    };
                    week.AddDay(weather);
                }
            }
            return(week);
        }
示例#2
0
        //--------------------------------------------------------------------------------
        //-----------------------------End Tomorrow's Weather-----------------------------
        //--------------------------------------------------------------------------------


        //--------------------------------------------------------------------------------
        //---------------------------------Week's Weather---------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherWeek FetchWeeksWeather(Location location)
        {
            WeeksWeatherData forecast = GetWeeksWeatherForecastData(location);
            WeatherWeek      week     = null;

            if (forecast != null)
            {
                week = ProcessWeeksWeatherData(forecast);
            }
            return(week);
        }
示例#3
0
 private void UpdateWeeksWeather(Location location)
 {
     WeeksWeather = WeatherService.FetchWeeksWeather(location);
 }