예제 #1
0
        /// <summary>
        /// Saves the settings.
        /// </summary>
        /// <returns></returns>
        bool SaveSettings()
        {
            if (CurrentEnvironment.IsConnected)
            {
                if (CurrentEnvironment.AuthorizationService.IsAuthorized(AuthorizationContext.Administrator, null))
                {
                    Tracker.TrackEvent(TrackerEventGroup.Settings, TrackerEventName.SaveClicked);
                    // Need to reset sub view models so that selecting something in them fires our OnIsDirtyPropertyChanged()

                    ClearErrors();
                    if (!ValidateDuplicateResourcePermissions())
                    {
                        return(false);
                    }
                    if (!ValidateDuplicateServerPermissions())
                    {
                        return(false);
                    }
                    if (!ValidateResourcePermissions())
                    {
                        return(false);
                    }

                    SecurityViewModel.Save(Settings.Security);
                    if (LogSettingsViewModel.IsDirty)
                    {
                        LogSettingsViewModel.Save(Settings.Logging);
                    }
                    if (PerfmonViewModel.IsDirty)
                    {
                        PerfmonViewModel.Save(Settings.PerfCounters);
                    }
                    var isWritten = WriteSettings();
                    if (isWritten)
                    {
                        ResetIsDirtyForChildren();
                        IsSaved = true;
                        IsDirty = false;
                        ClearErrors();
                    }
                    else
                    {
                        IsSaved = false;
                        IsDirty = true;
                    }
                    return(IsSaved);
                }
                ShowError(StringResources.SaveSettingErrorPrefix, StringResources.SaveSettingsPermissionsErrorMsg);
                _popupController.ShowSaveSettingsPermissionsErrorMsg();
                return(false);
            }
            ShowError(StringResources.SaveSettingErrorPrefix, StringResources.SaveSettingsNotReachableErrorMsg);
            _popupController.ShowSaveSettingsNotReachableErrorMsg();
            return(false);
        }