static IBuildServer GetTfsBuildServer(string tfsCollectionUri)
        {
            var collection = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(tfsCollectionUri));

            collection.EnsureAuthenticated();
            return(collection.GetService <IBuildServer>());
        }
Beispiel #2
0
 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!");
     }
 }
 static IBuildServer GetTfsBuildServer(string tfsCollectionUri)
 {
     var collection = new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(tfsCollectionUri));
     collection.EnsureAuthenticated();
     return collection.GetService<IBuildServer>();
 }
        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);
        }
 public T GetService <T>()
 {
     return(_tfs.GetService <T>());
 }