/// <inheritdoc /> protected override ITeamProjectCollection ConnectToTfsCollection(Uri endpoint, VssCredentials credentials) { var tfsServer = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(endpoint, credentials); tfsServer.EnsureAuthenticated(); return(tfsServer.AsProxy()); }
static IBuildServer GetTfsBuildServer(string tfsCollectionUri) { var collection = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(tfsCollectionUri)); collection.EnsureAuthenticated(); return(collection.GetService <IBuildServer>()); }
/// <summary> /// Initializes a new instance of the <see cref="TfsTeamProjectCollection" /> class. /// </summary> /// <param name="teamProjectCollection">The TFS.</param> /// <exception cref="ArgumentNullException">tfs</exception> internal TfsTeamProjectCollection(Microsoft.TeamFoundation.Client.TfsTeamProjectCollection teamProjectCollection) { Native = teamProjectCollection ?? throw new ArgumentNullException(nameof(teamProjectCollection)); AuthorizedCredentials = Native.ClientCredentials; AuthorizedIdentity = new TeamFoundationIdentity(Native.AuthorizedIdentity); Uri = Native.Uri; _css = new Lazy <ICommonStructureService>( () => ExceptionHandlingDynamicProxyFactory.Create <ICommonStructureService>( new CommonStructureService( Native .GetService < ICommonStructureService4 >()))); }
internal static IInternalTeamProjectCollection AsProxy(this Microsoft.TeamFoundation.Client.TfsTeamProjectCollection tfsNative) { return(tfsNative == null ? null : ExceptionHandlingDynamicProxyFactory.Create <IInternalTeamProjectCollection>(new TfsTeamProjectCollection(tfsNative))); }
private void btnTestTFS_Click(object sender, EventArgs e) { Microsoft.TeamFoundation.Client.TfsTeamProjectCollection tpc = null; Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer sc = null; Microsoft.TeamFoundation.VersionControl.Client.Workspace lstWS = null; try { System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(txtName.Text.Trim(), txtPassword.Text.Trim()); System.Net.ICredentials credential = (System.Net.ICredentials)networkCredential; tpc = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(txtUrl.Text.Trim()), credential); sc = (Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer)tpc.GetService(typeof(Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer)); lstWS = sc.QueryWorkspaces(null, txtName.Text.Trim().Substring(0,txtName.Text.Trim().IndexOf("@")), null).FirstOrDefault(x => x.IsLocal); if (lstWS != null) MessageBox.Show("TFS Successful connection!"); } catch (Exception ex) { MessageBox.Show("TFS Connection Failed!"); } }
private Task<bool> UpdateWorkItemWithClientObjectModel(int workItemId, string artifactId) { var result = false; try { var collectionUri = new Uri(string.Format(CollectionUri, Connection.ServerUrl, Connection.Collection)); Microsoft.TeamFoundation.Client.TfsTeamProjectCollection teamProjectCollection = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(collectionUri, new NetworkCredential(Connection.UserName, Connection.Password)); Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore workItemStore = teamProjectCollection.GetService<Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore>(); Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem workItem = workItemStore.GetWorkItem(workItemId); if (workItem.Fields.Contains("Artifact ID")) { workItem.Fields["Artifact ID"].Value = artifactId; workItem.Save(); } result = true; } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); } return Task.FromResult(result); }
static IBuildServer GetTfsBuildServer(string tfsCollectionUri) { var collection = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(tfsCollectionUri)); collection.EnsureAuthenticated(); return collection.GetService<IBuildServer>(); }
internal TfsTeamProjectCollectionProxy(Tfs.Client.TfsTeamProjectCollection tfs) { _tfs = tfs; }