/// <summary> /// This event handler method calls /// the ProcessHistoricalData method of the ProcessorClass class /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DisplayHistoricalDataButton_Click(object sender, EventArgs e) { //ProcessorClass.ProcessHistoricalData(); try { String location = SearchTextBox.Text.ToString(); PastWeatherInput input = new PastWeatherInput(); input.query = location; input.date = "2013-03-01"; input.enddate = "2018-03-03"; input.format = "JSON"; /* Call the GetPastWeather method and pass in input parameters*/ API_Implementation api = new API_Implementation(); PastWeather pastWeather = api.GetPastWeather(input); /*Display Results*/ DisplayResultsTextBox.Text = "\r\n Date: " + pastWeather.data.weather[0].date; DisplayResultsTextBox.Text += "\r\n Max Temp(C): " + pastWeather.data.weather[0].maxtempC; DisplayResultsTextBox.Text += "\r\n Max Temp(F): " + pastWeather.data.weather[0].maxtempF; DisplayResultsTextBox.Text += "\r\n Min Temp(C): " + pastWeather.data.weather[0].mintempC; DisplayResultsTextBox.Text += "\r\n Min Temp(F): " + pastWeather.data.weather[0].mintempF; DisplayResultsTextBox.Text += "\r\n Cloud Cover: " + pastWeather.data.weather[0].hourly[0].cloudcover; DisplayResultsTextBox.Text += "\r\n Humidity: " + pastWeather.data.weather[0].hourly[0].humidity; DisplayResultsTextBox.Text += "\r\n Pressure: " + pastWeather.data.weather[0].hourly[0].pressure; DisplayResultsTextBox.Text += "\r\n Visibility: " + pastWeather.data.weather[0].hourly[0].visibility; DisplayResultsTextBox.Text += "\r\n Wind Speed: " + pastWeather.data.weather[0].hourly[0].windspeedMiles; } catch (Exception ex) { ex.GetBaseException(); } }
/// <summary> /// This method consumes the WorldWeather Premium API /// to show past weather data of any given location /// for a given period /// </summary> public void GetHistoricalData() { try { String location = SearchTextBox.Text.ToString(); PastWeatherInput input = new PastWeatherInput(); input.query = location; input.date = "2017-01-01"; input.enddate = "2019-01-01"; input.format = "JSON"; /* Call the GetPastWeather method and pass in input parameters*/ API_Implementation api = new API_Implementation(); PastWeather pastWeather = api.GetPastWeather(input); /*Display Results*/ DisplayResultsTextBox.Text = "\r\n Date: " + pastWeather.data.weather[0].date; DisplayResultsTextBox.Text += "\r\n Max Temp(C): " + pastWeather.data.weather[0].maxtempC; DisplayResultsTextBox.Text += "\r\n Max Temp(F): " + pastWeather.data.weather[0].maxtempF; DisplayResultsTextBox.Text += "\r\n Min Temp(C): " + pastWeather.data.weather[0].mintempC; DisplayResultsTextBox.Text += "\r\n Min Temp(F): " + pastWeather.data.weather[0].mintempF; DisplayResultsTextBox.Text += "\r\n Cloud Cover: " + pastWeather.data.weather[0].hourly[0].cloudcover; } catch (Exception ex) { ex.GetBaseException(); } }