Esempio n. 1
0
        protected AnalyticsBase(ApplicationPage appPage, IAggregateService aggregateService)
        {
            if (aggregateService == null)
                throw new ArgumentNullException("aggregateService");

            this.AggregateService = aggregateService; 
            this.appPage = appPage;
            if (appPage != ApplicationPage.SplashScreen)
                this.weather = UnitOfWork.WeatherRepository.Get();
        }
Esempio n. 2
0
        protected virtual void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            if (gpsWatcherResponseMessage.Reason == GpsWatcherResponseMessageReason.Error)
            {
                DeregisterWatcher();

                this.ShowPopup(CustomPopupMessageType.Error, AppResources.CustomPopupGenericGpsFailureMessage, AppResources.CustomPopupGenericOkMessage, null);

                return;
            }

            if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                DeregisterWatcher();

                if (user != null && !gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    user.UpdateLocation(gpsWatcherResponseMessage.Coordinate);
                    UnitOfWork.UserRepository.Update(user);
                    UnitOfWork.Save();
                }

                if (InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.ShowWeather).Value)
                {
                    if (weather == null || weather.LastRefreshedDate < DateTime.Now.AddHours(-1))
                    {
                        Action getWeather = async () =>
                        {
                            try
                            {
                                IWeatherApi weatherApi = SimpleIoc.Default.GetInstance<IWeatherApi>();

                                if (weatherApi != null)
                                {
                                    weather = await weatherApi.GetDataWeather(gpsWatcherResponseMessage.Coordinate);

                                    UnitOfWork.WeatherRepository.DeleteAll();
                                    UnitOfWork.WeatherRepository.Insert(weather);
                                    UnitOfWork.Save();
                                }
                            }
                            catch (Exception)
                            {

                            }
                        };

                        DispatcherHelper.CheckBeginInvokeOnUI(getWeather);
                    }
                }
            }
        }