Inheritance: Repository, ISettingsRepository
コード例 #1
0
 public ImageQuestionData()
 {
     if (CurrentResolution == null)
     {
         using (var settingsRepository = new SettingsRepository())
         {
             CurrentResolution = settingsRepository.GetCurrentSettings().PhotoResolution;
         }
     }
 }
コード例 #2
0
        private void Refresh()
        {
            this.settingsRepository = new SettingsRepository();
            this.currentSettings = settingsRepository.GetCurrentSettings();
            this.Resolutions = new ObservableCollection<PhotoResolution>(settingsRepository.GetAvailablePhotoResolutions());

            this.IsCheckForNewSurveysOnStart = this.currentSettings.CheckForNewSurveys;
            this.IsGpsEnabled = this.currentSettings.IsGpsEnabled;
            this.SelectedResolution = this.Resolutions.SingleOrDefault(item => item.ID == this.currentSettings.PhotoResolutionID);
            this.UpdateLanguages();
            this.ServerPath = this.currentSettings.Server != null ? this.currentSettings.Server.Address : string.Empty;
            this.IsNeedUpdate = true;
            this.IsNeedUpdate = false;
        }
コード例 #3
0
        public void InitializeViewModelExecute()
        {
            this.serverRepository = new ServerRepository();            
            this.settingsRepository = new SettingsRepository();

            currentSettings = settingsRepository.GetCurrentSettings();
            this.Refresh();
        }
コード例 #4
0
        private void LoginCallback(AuthentificationCode result)
        {
            this.BusyCount--;
            switch (result)
            {
                case AuthentificationCode.LoginSuccessed:
#if !UNIT_TEST
                    using (var settingsRepository = new SettingsRepository())
                        settingsRepository.UpdateCurrentServer(Membership.CurrentUser.ServerID);

                    using (var settingsRespository = new SettingsRepository())
                    {
                        if (settingsRespository.GetCurrentSettings().CheckForNewSurveys && InternetChecker.IsInernetActive)
                        {
                            Locator.MySurveysStatic.RefreshExecute();
                        }
                    }

                    NavigationProvider.Navigate(new System.Uri(HOME_PAGE_SOURCE, System.UriKind.Relative));
#else
                    RaiseTestCompleted("LoginSuccess");
#endif
                    break;
                case AuthentificationCode.InvalidCredentials:
#if !UNIT_TEST
                    MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).WRONG_PASSWORD);
#else
                    RaiseTestCompleted("Wrong username/password");
#endif
                    break;
                case AuthentificationCode.ServerNotFound:
                    MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).CANNOT_LOCATE_SERVER);
                    break;
                case AuthentificationCode.NoInternetConnection:
                    MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).ERROR_LOGIN_DB);
                    break;
            }  
        }
コード例 #5
0
        /// <summary>
        /// Starts intialization of view model.
        /// </summary>
        private void InitializeViewModeExecute()
        {
            if (!this.wasInitialization)
            {
                this.wasInitialization = true;
                using (var settingsRepository = new SettingsRepository())
                {
                    if (!IsolatedStorageSettings.ApplicationSettings.Contains(_firstLaunchKey))
                    {
                        IsolatedStorageSettings.ApplicationSettings[_firstLaunchKey] = wasInitialization;
                        var result = MessageBox.Show("Would you like this application to use your phone's GPS function?", "GPS", MessageBoxButton.OKCancel);
                        var currentSettings = settingsRepository.GetCurrentSettings();
                        currentSettings.IsGpsEnabled = result == MessageBoxResult.OK;
                        settingsRepository.UpdateCurrentSettings(currentSettings);
                    }

                    bool userAcceptedEula = false;
                    var store = IsolatedStorageSettings.ApplicationSettings;
                    if (store.Contains(EULA_KEY))
                        userAcceptedEula = (bool)store[EULA_KEY];

                    if (!userAcceptedEula)
                    {
                        NotificationTool.Show(
                            "Privacy Policy",
                            "NDG",
                            new NotificationAction("Accept", () => { AcceptedPrivacy(); }),
                            new NotificationAction("Decline", () => { DeclinedPrivacy(); }));
                    }

                    GpsTracker.Instance.GpsAllowed = settingsRepository.GetCurrentSettings().IsGpsEnabled;
                    GpsTracker.Instance.StartTracking();
                }                
            }

            if (Membership.CurrentUser == null)
            {
                this.Login = string.Empty;
                this.Password = string.Empty;
                using (var settingsRepository = new SettingsRepository())
                    this.ServerPath = settingsRepository.GetCurrentSettings().Server.Address;
            }

            var pageParameters = NavigationProvider.GetNavigationParameters();
            if (pageParameters.ContainsKey(SEVER_PATH_PARAMETER))
            {
                this.ServerPath = pageParameters[SEVER_PATH_PARAMETER];
            }
        }