Пример #1
0
        public BasicUserOptionsContentViewModel()
        {
            _editJenkinsServer = new JenkinsServer();

            AddServer    = new RelayCommand(HandleAddJenkinsServer);
            RemoveServer = new RelayCommand(HandleRemoveJenkinsServer);
            ApplyChanges = new RelayCommand(HandleApplyChanges, CanExecuteApplyChanges);

            JenkinsServers        = ApiHandlerSettingsManager.GetServers();
            SelectedJenkinsServer = JenkinsServers.FirstOrDefault();

            InitializeValidationRules();
        }
        private bool TrySelectPreferredView(SolutionChangedEventArgs e)
        {
            if (!ApiHandlerSettingsManager.ContainsSolutionPreference(e.SolutionPath))
            {
                return(false);
            }

            var jobLink       = ApiHandlerSettingsManager.GetJobLink(e.SolutionPath);
            var jobLinkServer = JenkinsServers.FirstOrDefault((s) => string.Equals(s.Url, jobLink.JenkinsServerUrl, StringComparison.InvariantCultureIgnoreCase));

            if (jobLinkServer == null)
            {
                // server has been removed
                return(false);
            }

            bool preferredViewSelected = false;

            if (SelectedJenkinsServer == jobLinkServer)
            {
                // Correct server already selected, just fix the view
                var preferredView = _jenkinsViews.FirstOrDefault((j) => string.Equals(j.Name, jobLink.JenkinsViewName));
                if (preferredView != null)
                {
                    SelectedView          = preferredView;
                    preferredViewSelected = true;
                }
            }
            else
            {
                SelectNewJenkinsServer(jobLinkServer, jobLink.JenkinsViewName);
                preferredViewSelected = true;
            }

            return(preferredViewSelected);
        }