Exemplo n.º 1
0
        public async Task <WeatherInformation> ReadWeatherInformation(DateTime date)
        {
            GetUrl getUrl = (attempts) =>
            {
                return($"https://www.wunderground.com/history/daily/{location}/date/{date.ToString("yyyy-M-d")}");
            };

            var htmlDocument = await WebBrowserRequest.Navigate(getUrl, IsDocumentFullyLoaded, this.userInteraction, this.browser);

            if (GetReadings(htmlDocument, date, out List <WeatherReading> readings, out int dummy) &&
                GetLocationInformation(htmlDocument, out double latitude, out double longitude, out int dummy2))
            {
                WeatherInformation daylight = this.timeRangeProvider.GetInformation(this.userInteraction, date, latitude, longitude);

                if (daylight != null)
                {
                    return(new WeatherInformation(
                               daylight.StartTime,
                               daylight.EndTime,
                               readings));
                }
            }

            return(null);
        }
            public WeatherInformation GetInformation(IUserInteraction userInteraction, DateTime date, double latitude, double longitude)
            {
                WeatherInformation start = this.startTime.GetInformation(userInteraction, date, latitude, longitude);
                WeatherInformation end   = this.endTime.GetInformation(userInteraction, date, latitude, longitude);

                return(new WeatherInformation(
                           start.StartTime,
                           end.EndTime,
                           Enumerable.Empty <WeatherReading>()));
            }