private void LiveCall()
 {
     try
     {
         string value = GetValue;
         JavaScriptSerializer jsSerialization = new JavaScriptSerializer();
         OpenWeatherMapObject weatherObject   = jsSerialization.Deserialize <OpenWeatherMapObject>(value);
         _Cache = weatherObject;
         if (!SharedObjects.LatLong.HasRecord())
         {
             SharedObjects.LatLong.Set(_Cache.coord.lat, _Cache.coord.lon);
         }
     }
     catch (Exception x) { _Status = x.Message; _ThrownException = x; }
 }
예제 #2
0
        public override void Invoke()
        {
            try
            {
                string value = GetValue;
                //JavaScriptSerializer jsSerialization = new JavaScriptSerializer();
                OpenWeatherMapObject weatherObject = JsonConvert.DeserializeObject <OpenWeatherMapObject>(value); //jsSerialization.Deserialize<OpenWeatherMapObject>(value);
                _Temp    = (int)weatherObject.main.temp;
                _forcast = GenerateForcast(weatherObject.main, weatherObject.weather[0]);
                _type    = GetWeatherType(weatherObject.weather[0].id);

                _sunRise   = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(weatherObject.sys.sunrise).ToLocalTime();
                _sunSet    = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(weatherObject.sys.sunset).ToLocalTime();
                _solarNoon = DateTime.Now;
                _status    = string.Empty;
                _Success   = true;
            }
            catch (Exception x) { _err = x.ToString(); _Success = false; }
        }