简体   繁体   中英

TFS Integration

I am trying to do a TFS integration with automatic sync with tfs to my db.. All I m doing with window service... For that I have coded as below...

DataRow dr = dstSyncWorkItem.Tables["Workitems"].Rows[i];
String uri = ConfigurationManager.AppSettings["TfsUri"] + dr["ProCollectionName"];
Uri collectionUri = new Uri(uri);
NetworkCredential myNetCredentials = new NetworkCredential(ConfigurationManager.AppSettings["TfsUsername"], ConfigurationManager.AppSettings["TfsPassword"]);
ICredentials myCredentials = (ICredentials)myNetCredentials;

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri, myCredentials);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects[dr["Project"].ToString()];
WorkItemType workItemType = teamProject.WorkItemTypes[dr["Type"].ToString()];

WorkItem workItem = new WorkItem(workItemType);
workItem.Title = dr["Title"].ToString();
workItem.Description = dr["Desc"].ToString();
workItem.Save();

and This will giving following error...

TF237124: Work Item is not ready to save.

You need to validate the work item before you can save it. Call:

ArrayList validation = workItem.Validate();

This will ensure that any changes you've made are appropriate, and make any additional state changes that your work item rules have defined based on your changes.

If there are validation failures, you must deal with them appropriately. Otherwise, you can then call:

workItem.Save();

You have not filled out all of the required fields. While calling the Validate() function will give you a list of errors you will be required to fill out Area & Iteration paths. Along with Title these are the only OOB required fields.

You don't see this in any of the UI's as they are populated by default. If you fill them out with something like "Iteration/myproject/" you should pass.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM