private void ValidateConnection(string tfsServerUrl, string tfsLocation, string userName, string password,
                                        string personalAccessToken, out TfsServerDeployment deployment)
        {
            deployment = TfsServerDeploymentHelper.ToTfsServerDeploymentHelperEnum(tfsLocation);

            if (deployment == TfsServerDeployment.OnPremises)
            {
                if (string.IsNullOrWhiteSpace(userName))
                {
                    throw new ServiceValidationException("Please enter a user name");
                }

                if (string.IsNullOrWhiteSpace(password))
                {
                    throw new ServiceValidationException("Please enter a password");
                }
            }
            else if (deployment == TfsServerDeployment.OnlineVsts)
            {
                if (string.IsNullOrWhiteSpace(personalAccessToken))
                {
                    throw new ServiceValidationException("Please enter your VSTS personal access token");
                }
            }

            try
            {
                _tfsApiClient.TestConnection(tfsServerUrl, deployment, userName, password, personalAccessToken);
            }
            catch
            {
                throw new ServiceValidationException($"Unable to connect to the specified TFS server.");
            }
        }
Пример #2
0
        public void TestConnection(string tfsServerUrl, TfsServerDeployment deployment, string userName, string password,
                                   string personalAccessToken)
        {
            var connection = new Connection
            {
                TfsServerDeployment = deployment,
                UserName            = userName,
                Password            = password,
                PersonalAccessToken = personalAccessToken,
                TfsServerUrl        = tfsServerUrl
            };

            TestConnection(connection);
        }
Пример #3
0
        public static string ToFriendlyName(this TfsServerDeployment tfsServerDeployment)
        {
            switch (tfsServerDeployment)
            {
            case TfsServerDeployment.OnlineVsts:
                return("Visual Studio Online");

            case TfsServerDeployment.OnPremises:
                return("On Premises");

            default:
                return("Unknown");
            }
        }