Example #1
0
 public WeatherUnderground(
     string location,
     IUserInteraction userInteraction,
     IWebBrowser browser,
     ITimeRangeProvider timeRangeProvider)
 {
     this.location          = location;
     this.userInteraction   = userInteraction;
     this.browser           = browser;
     this.timeRangeProvider = timeRangeProvider;
 }
Example #2
0
        private async void buttonGo_Click(object sender, EventArgs e)
        {
            buttonGo.Enabled = false;
            try
            {
                ITimeRangeProvider timeRangeProvider = TimeRangeProviderFactory.GetProvider(
                    Properties.Settings.Default.StartTime,
                    Properties.Settings.Default.EndTime);

                var wu = new WeatherUnderground(textBoxLocation.Text, new UserInteraction(this.textBoxLog), this.browser, timeRangeProvider);
                List <WeatherInformation> weatherInformation = new List <WeatherInformation>();
                DateTime workingDate = dateTimePickerFrom.Value;
                DateTime endDate     = dateTimePickerTo.Value;

                int requestCount = (endDate - workingDate).Days + 1;

                this.progressBar1.Maximum = requestCount;

                while (workingDate <= endDate)
                {
                    var info = await wu.ReadWeatherInformation(workingDate);

                    if (info == null)
                    {
                        ProcessResult(weatherInformation);
                        return;
                    }
                    else
                    {
                        weatherInformation.Add(info);
                        workingDate = workingDate.AddDays(1);
                        this.progressBar1.Value++;
                    }
                }

                ProcessResult(weatherInformation);
            }
            finally
            {
                buttonGo.Enabled        = true;
                this.progressBar1.Value = 0;
            }
        }
 public CompositeProvider(ITimeRangeProvider startTime, ITimeRangeProvider endTime)
 {
     this.startTime = startTime;
     this.endTime   = endTime;
 }