YahooWeatherObject LiveCall() { string results = string.Empty; string URL = string.Empty; YahooWeatherObject Response = new YahooWeatherObject(); try { if (SharedObjects.Cache.Exists(this.GetType().Name)) { return((YahooWeatherObject)SharedObjects.Cache.Value(this.GetType().Name)); } URL = string.Format(Properties.Resources.Yahoo_Weather_Url, _zip); results = SharedObjects.CompressedCallSite(URL); JavaScriptSerializer jsSerialization = new JavaScriptSerializer(); Response = jsSerialization.Deserialize <YahooWeatherObject>(results); SharedObjects.Cache.Set(this.GetType().Name, Response, _HardWiredUpdateInterval); } catch (Exception x) { Exception eResults = new Exception(results, x); Exception Mask = new Exception("Error calling yahoo..." + URL, eResults); _ThrownException = x; } return(Response); }
public ISharedResponse Invoke() { if (!HasBeenCalled || DateTime.Now > _lastCall.AddMinutes(UpdateInterval)) { _cache = new WeatherResponse(); YahooWeatherObject result = new YahooWeatherObject(); try { result = LiveCall(); HasBeenCalled = true; _lastCall = DateTime.Now; _cache.Temp = int.Parse(result.query.results.channel.item.condition.temp); _cache.ForcastDescription = RemoveMarkup(result.query.results.channel.item.description); _cache.WType = GetWeatherType(int.Parse(result.query.results.channel.item.condition.code)); } catch (Exception ex) { _status = ex.Message; _ThrownException = ex; } } return(_cache); }