Пример #1
0
        public void LoadSettings(ISettingsSource buildServerConfig)
        {
            var settings = IntegrationSettings.ReadFrom(buildServerConfig);

            if (string.IsNullOrWhiteSpace(settings.ProjectUrl))
            {
                var(vstsOrTfsProjectFound, autoDetectedProjectUrl) = ProjectUrlHelper.TryDetectProjectFromRemoteUrls(_remotes);
                if (vstsOrTfsProjectFound)
                {
                    settings.ProjectUrl = autoDetectedProjectUrl;
                }
            }

            _currentSettings = settings;
            UpdateView();
        }
Пример #2
0
        private void ExtractLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                var buildUrl = Clipboard.ContainsText() ? Clipboard.GetText() : "";
                var(success, projectUrl, buildId) = ProjectUrlHelper.TryParseBuildUrl(buildUrl);
                if (success)
                {
                    string buildDefinitionName;
                    if (!string.IsNullOrWhiteSpace(_currentSettings.ApiToken))
                    {
                        try
                        {
                            using (var apiClient = new ApiClient(projectUrl, _currentSettings.ApiToken))
                            {
                                buildDefinitionName = await apiClient.GetBuildDefinitionNameFromIdAsync(buildId) ?? "";
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(_failToLoadBuildDefinitionInfoMessage.Text, _failToExtractDataFromClipboardCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    else
                    {
                        buildDefinitionName = "";
                        MessageBox.Show(_infoNoApiTokenMessage.Text, _failToExtractDataFromClipboardCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    _currentSettings.ProjectUrl            = projectUrl;
                    _currentSettings.BuildDefinitionFilter = buildDefinitionName;
                    UpdateView();
                }
                else
                {
                    MessageBox.Show(_failToExtractDataFromClipboardMessage.Text, _failToExtractDataFromClipboardCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }).FileAndForget();
        }