Esempio n. 1
0
 private void ProcessCheckCityResult(WeatherResult result)
 {
     GlobalLoading.Instance.IsLoading = false;
     if (result.ActualCityName == null)
     {
         Location = string.Empty;
         MessageBox.Show("unknown city / postal code", "oops", MessageBoxButton.OK);
     }
     else
     {
         Location = result.ActualCityName;
         var newCity = new City { CityAndState = Location };
         _cityService.AddCity(newCity);
         Location = string.Empty;
         (App.Current as App).Cities = _cities;
         SendMessage(true);
     }
 }
Esempio n. 2
0
 public WeatherService(IHandleResourcesFactory handlerFactory)
 {
     _handlerFactory = handlerFactory;
     _weatherResult = new WeatherResult();
 }
Esempio n. 3
0
        private WeatherResult MapWeatherForecast(xml_api_reply result)
        {
            var wr = new WeatherResult();

            try
            {
                int count = result.weather[0].forecast_conditions.Count();
                for (int i = 0; i < count; i++)
                {
                    var wc = new WeatherForecast
                                 {
                                     ConditionDescription = result.weather[0].forecast_conditions[i].condition[0].data,
                                     DayOfWeek = result.weather[0].forecast_conditions[i].day_of_week[0].data,
                                     High = Convert.ToDouble(result.weather[0].forecast_conditions[i].high[0].data),
                                     Low = Convert.ToDouble(result.weather[0].forecast_conditions[i].low[0].data),
                                     IconUri = result.weather[0].forecast_conditions[i].icon[0].data.Replace("gif", "png")
                                 };
                    wr.WeatherForecast.Add(wc);
                }
            }
            catch (ArgumentNullException e)
            {
            }
            return wr;
        }
Esempio n. 4
0
 public WeatherService()
 {
     _handlerFactory = new ResourceClientFactory();
     _weatherResult = new WeatherResult();
 }
Esempio n. 5
0
        private WeatherResult MapCurrentConditions(xml_api_reply r, WeatherResult wr)
        {
            try
            {
                wr.ActualCityName = r.weather[0].forecast_information[0].city[0].data;

                var currentConditions = new CurrentWeatherConditions()
                                            {
                                                City = r.weather[0].forecast_information[0].city[0].data,
                                                PostalCode = r.weather[0].forecast_information[0].postal_code[0].data,
                                                ForecastDate = Convert.ToDateTime(r.weather[0].forecast_information[0].forecast_date[0].data),
                                                CurrentCondition = r.weather[0].current_conditions[0].condition[0].data,
                                                CurrentHumidity = r.weather[0].current_conditions[0].humidity[0].data,
                                                CurrentWind = r.weather[0].current_conditions[0].wind_condition[0].data,
                                                CurrentIconUri = r.weather[0].current_conditions[0].icon[0].data.Replace("gif", "png"),
                                                CurrentF = Convert.ToDouble(r.weather[0].current_conditions[0].temp_f[0].data),
                                                CurrentC = Convert.ToDouble(r.weather[0].current_conditions[0].temp_c[0].data)
                                            };
                wr.WeatherConditions = currentConditions;
            }
            catch (Exception e)
            {
            }
            return wr;
        }