private void QueryWeatherData(WUGSettings weatherSettings)
        {
            try
            {
                WeatherService weather   = new WeatherService(weatherSettings);
                var            readings  = new List <WeatherReading>();
                var            summaries = new List <WeatherSummary>();

                var watermark  = getWeatherHighWaterMark();
                var today      = DateTime.Now;
                int totalCalls = 0;

                var mostRecent = watermark;

                while (mostRecent < today && totalCalls < 200)
                {
                    Utils.Log("Querying weather for {0}", mostRecent);

                    if (!weather.GetHistory(mostRecent, readings, summaries))
                    {
                        break;
                    }

                    totalCalls++;

                    mostRecent = mostRecent.AddDays(1);

                    // Max of 10 weather calls per minute
                    Thread.Sleep(6 * 1000);

                    if (totalCalls % 25 == 0)
                    {
                        StoreWeatherReadings(watermark, readings, summaries);
                    }
                }

                StoreWeatherReadings(watermark, readings, summaries);
            }
            catch (Exception ex)
            {
                Utils.Log("Exception querying Weather data. {0}", ex);
            }
        }
Example #2
0
        private ICollection <Reading> QueryWeatherData(WUGSettings weatherSettings)
        {
            WeatherService weather     = new WeatherService(weatherSettings);
            var            allReadings = new List <Reading>();

            var mostRecent = getWeatherHighWaterMark();
            var today      = DateTime.Now;
            int totalCalls = 0;

            while (mostRecent < today && totalCalls < 200)
            {
                Utils.Log("Querying weather for {0}", mostRecent);

                var readings = weather.GetHistory(mostRecent);
                allReadings.AddRange(readings);
                totalCalls++;

                // Max of 10 weather calls per minute
                Thread.Sleep(6 * 1000);
            }

            return(allReadings);
        }