private void PopulateProjectNameComboBox() { string url = tfsAddressTextBox.Text; string username = tfsUsernameTextBox.Text; string password = tfsPasswordTextBox.Text; Uri tfsUri; if (!Uri.TryCreate(url, UriKind.Absolute, out tfsUri)) { return; } var credentials = new VSS.VssCredentials(); if (!string.IsNullOrEmpty(username)) { credentials = new VSS.VssCredentials( new VSS.WindowsCredential(new System.Net.NetworkCredential( username, password)), VSS.CredentialPromptType.PromptIfNeeded); } var tfs = new TfsTeamProjectCollection(tfsUri, credentials); tfs.Authenticate(); var workItemStore = tfs.GetService <WorkItemStore>(); projectComboBox.Items.Clear(); foreach (Project project in workItemStore.Projects) { projectComboBox.Items.Add(project.Name); } int existingProjectIndex = -1; if (!string.IsNullOrEmpty(options.ProjectName)) { existingProjectIndex = projectComboBox.Items.IndexOf(options.ProjectName); } projectComboBox.SelectedIndex = existingProjectIndex > 0 ? existingProjectIndex : 0; }
private WorkItemStore ConnectToTfs() { Uri tfsUri; if (!Uri.TryCreate(options.ServerName, UriKind.Absolute, out tfsUri)) { return(null); } var credentials = new VSS.VssCredentials(); if (!string.IsNullOrEmpty(options.UserName)) { credentials = new VSS.VssCredentials( new VSS.WindowsCredential(new System.Net.NetworkCredential( options.UserName, options.UserPassword)), VSS.CredentialPromptType.PromptIfNeeded); } _tfs = new TfsTeamProjectCollection(tfsUri, credentials); _tfs.Authenticate(); return(_tfs.GetService <WorkItemStore>()); }