protected void Build_Click(object sender, EventArgs e) { PropertyInfo property = Application["CurrentProperty"] as PropertyInfo; GeoLocation geoLoc = Application["CurrentGeoLocation"] as GeoLocation; DarkSkySettings settings = Application["CurrentSettings"] as DarkSkySettings; var request = new DarkSkyRequest(); request.DarkSkyRequestAPI = settings.darkSkyApiKey; request.DarkSkyLatitude = geoLoc.Latitude; request.DarkSkyLongitude = geoLoc.Longitude; request.DarkSkyRequestUrl = settings.darkSkyUrl; Application["CurrentRequest"] = request; float buildLatitude = request.DarkSkyLatitude; float buildLongitude = request.DarkSkyLongitude; string apiKey = request.DarkSkyRequestAPI; string baseUrl = request.DarkSkyRequestUrl; string url = string.Format(baseUrl + apiKey + '/' + buildLatitude + ',' + buildLongitude); using (WebClient client = new WebClient()) { string json = client.DownloadString(url); DarkSkyResponse response = (new JavaScriptSerializer().Deserialize <DarkSkyResponse>(json)); Application["CurrentResponse"] = response; Response.Redirect("WeatherTile.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { PropertyInfo property = Application["CurrentProperty"] as PropertyInfo; GeoLocation geoLoc = Application["CurrentGeoLocation"] as GeoLocation; var settings = new DarkSkySettings() { darkSkyApiKey = "0ab072376462dd056d5a7f08c9c344a6", darkSkyUrl = "https://api.darksky.net/forecast/", darkSkyUnits = "auto", darkSkyLang = "en", darkSkyExcluded = "minutely, hourly, alerts, flags" }; propName.Text = property.PropertyName; propCity.Text = property.PropertyCity; propState.Text = property.PropertyState; propLat.Text = geoLoc.Latitude.ToString(); propLon.Text = geoLoc.Longitude.ToString(); propDays.Text = property.PropertySendDays.ToString(); apiKey.Text = settings.darkSkyApiKey; baseUrl.Text = settings.darkSkyUrl; Application["CurrentSettings"] = settings; }
public DarkSkyWeatherService( DarkSkySettings _darkSkySettings, IHttpClient _httpClient, IHttpResponseMapper _httpMapper, IWeatherCache _weatherCache ) { this._darkSkySettings = _darkSkySettings; this._httpClient = _httpClient; this._httpMapper = _httpMapper; this._weatherCache = _weatherCache; }
protected void Submit_Click(object sender, EventArgs e) { var settings = new DarkSkySettings(); settings.darkSkyUrl = baseUrl.Text; settings.darkSkyApiKey = privateApiKey.Text; settings.darkSkyUnits = selectedUnits.Text; settings.darkSkyLang = selectedLang.Text; settings.darkSkyExcluded = "minutely, hourly, alerts, flags"; Application["CurrentSettings"] = settings; }
protected void Page_Load(object sender, EventArgs e) { PropertyInfo property = Application["CurrentProperty"] as PropertyInfo; GeoLocation geoLoc = Application["CurrentGeoLocation"] as GeoLocation; DarkSkySettings settings = Application["CurrentSettings"] as DarkSkySettings; DarkSkyResponse response = Application["CurrentResponse"] as DarkSkyResponse; if (response.currently.icon != null) { divHotelName.InnerHtml = property.PropertyName; divCity.InnerHtml = property.PropertyCity + "," + " "; divState.InnerHtml = property.PropertyState + " "; divZip.InnerHtml = property.PropertyZipCode.ToString(); divCurrentTemp.InnerHtml = Math.Round(response.currently.temperature).ToString() + "°"; divCurrentDay.InnerHtml = response.currently.time.ToString(); divCurrentDate.InnerHtml = response.currently.time.ToString(); imgCurrentIcon.Alt = response.currently.icon.ToString(); imgDay0Icon.Alt = response.daily.data[0].icon.ToString(); imgDay1Icon.Alt = response.daily.data[1].icon.ToString(); imgDay2Icon.Alt = response.daily.data[2].icon.ToString(); imgDay3Icon.Alt = response.daily.data[3].icon.ToString(); imgDay4Icon.Alt = response.daily.data[4].icon.ToString(); imgDay5Icon.Alt = response.daily.data[5].icon.ToString(); divForecastDay0.InnerHtml = response.daily.data[0].time.ToString(); divForecastDay1.InnerHtml = response.daily.data[1].time.ToString(); divForecastDay2.InnerHtml = response.daily.data[2].time.ToString(); divForecastDay3.InnerHtml = response.daily.data[3].time.ToString(); divForecastDay4.InnerHtml = response.daily.data[4].time.ToString(); divForecastDay5.InnerHtml = response.daily.data[5].time.ToString(); divTemp0.InnerHtml = Math.Round(response.daily.data[0].temperatureMax).ToString() + "°"; divTemp1.InnerHtml = Math.Round(response.daily.data[1].temperatureMax).ToString() + "°"; divTemp2.InnerHtml = Math.Round(response.daily.data[2].temperatureMax).ToString() + "°"; divTemp3.InnerHtml = Math.Round(response.daily.data[3].temperatureMax).ToString() + "°"; divTemp4.InnerHtml = Math.Round(response.daily.data[4].temperatureMax).ToString() + "°"; divTemp5.InnerHtml = Math.Round(response.daily.data[5].temperatureMax).ToString() + "°"; } else { Console.WriteLine("Trouble Connecting to Dark Sky"); } }
protected void Page_Load(object sender, EventArgs e) { PropertyInfo property = Application["CurrentProperty"] as PropertyInfo; GeoLocation geoLoc = Application["CurrentGeoLocation"] as GeoLocation; DarkSkySettings settings = Application["CurrentSettings"] as DarkSkySettings; DarkSkyResponse response = Application["CurrentResponse"] as DarkSkyResponse; if (response.currently.icon != null) { pic0.AlternateText = response.currently.icon.ToString(); pic00.AlternateText = response.daily.data[0].icon; pic1.AlternateText = response.daily.data[1].icon; pic2.AlternateText = response.daily.data[2].icon; pic3.AlternateText = response.daily.data[3].icon; pic4.AlternateText = response.daily.data[4].icon; pic5.AlternateText = response.daily.data[5].icon; propName.InnerHtml = property.PropertyName; propCity.Text = property.PropertyCity; propState.Text = property.PropertyState; propZip.Text = property.PropertyZipCode.ToString(); currentTemp.Text = Math.Round(response.currently.temperature).ToString() + "°"; divHotelName.InnerHtml = property.PropertyName; divCity.InnerHtml = property.PropertyCity; divState.InnerHtml = property.PropertyState; divZip.InnerHtml = property.PropertyZipCode.ToString(); divCurrentTemp.InnerHtml = Math.Round(response.currently.temperature).ToString() + "°"; day0Day.Text = response.currently.time.ToString(); day0Date.Text = response.currently.time.ToString(); day00.InnerHtml = response.daily.data[0].time.ToString(); day1.InnerHtml = response.daily.data[1].time.ToString(); day2.InnerHtml = response.daily.data[2].time.ToString(); day3.InnerHtml = response.daily.data[3].time.ToString(); day4.InnerHtml = response.daily.data[4].time.ToString(); day5.InnerHtml = response.daily.data[5].time.ToString(); hiTemp0.InnerHtml = Math.Round(response.daily.data[0].temperatureMax).ToString() + "°"; hiTemp1.InnerHtml = Math.Round(response.daily.data[1].temperatureMax).ToString() + "°"; hiTemp2.InnerHtml = Math.Round(response.daily.data[2].temperatureMax).ToString() + "°"; hiTemp3.InnerHtml = Math.Round(response.daily.data[3].temperatureMax).ToString() + "°"; hiTemp4.InnerHtml = Math.Round(response.daily.data[4].temperatureMax).ToString() + "°"; hiTemp5.InnerHtml = Math.Round(response.daily.data[5].temperatureMax).ToString() + "°"; divTemp0.InnerHtml = Math.Round(response.daily.data[0].temperatureMax).ToString() + "°"; divTemp1.InnerHtml = Math.Round(response.daily.data[1].temperatureMax).ToString() + "°"; divTemp2.InnerHtml = Math.Round(response.daily.data[2].temperatureMax).ToString() + "°"; divTemp3.InnerHtml = Math.Round(response.daily.data[3].temperatureMax).ToString() + "°"; divTemp4.InnerHtml = Math.Round(response.daily.data[4].temperatureMax).ToString() + "°"; divTemp5.InnerHtml = Math.Round(response.daily.data[5].temperatureMax).ToString() + "°"; } else { Console.WriteLine("Trouble Connecting to Dark Sky"); } }