I am trying to do extensive validation of work items in TFS2010. I understand that validation can be done using the out-of-box rules given by Microsoft, however I am looking to do more advanced validations. For example,
1)Sprint Planning should not happen if the previous Sprint is in-progress.
2)I am also looking for validation between work item types. For example, all the User stories should not allow a status changes other than ones that are planned in the current Sprint.
is that possible through API,if so guide me above two are my requirements....
another query,or is it possible to write validation error for this scenario..say as we try to save any workitem without title it throws TF20012...
Likewise we can handle this case...if so guide me...
But i was trying like this,to start up i am trying this below code for previous sprint say i am including start and end date to track,if so then i have to write for all n number of sprints which got over...which way is best to go ahead
Uri tfsUri = (args.Length < 1) ?
new Uri("http://cscdbche646:8080/tfs") : new Uri(args[0]);
TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);
// Get the catalog of team project collections
ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
new[] { CatalogResourceTypes.ProjectCollection },
false, CatalogQueryOptions.None);
// List the team project collections
foreach (CatalogNode collectionNode in collectionNodes)
{
// Use the InstanceId property to get the team project collection
Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
// Print the name of the team project collection
Console.WriteLine("Collection: " + teamProjectCollection.Name);
// Get a catalog of team projects for the collection
ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
new[] { CatalogResourceTypes.TeamProject },
false, CatalogQueryOptions.None);
// List the team projects in the collection
foreach (CatalogNode projectNode in projectNodes)
{
Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
// Get the work item store
WorkItemStore workItemStore = teamProjectCollection.GetService<WorkItemStore>();
// WorkItemCollection queryResults = workItemStore.Query(" Select [State], [Title] From WorkItems Where [Work Item Type] = 'Bug'");
WorkItemCollection queryResults = workItemStore.Query("Select [Work Item Type] = 'User Story' From WorkItems Where [State] = 'Closed' And ([System.StartDate.SDate] = '10/05/13') And ([System.EndDate.EDate] = '20/05/13')");
foreach (WorkItem wi in queryResults)
{
Console.WriteLine("State = " + wi.State.ToString());
Console.WriteLine("Title = " + wi.Title.ToString());
//string oldAssignedTo = (string)wi.Fields["State"].Value;
//wi.Fields["State"].Value = "In-Progress";
if (wi.IsDirty)
Console.WriteLine("The work item state cannot be changed.");
string oldAssignedTo = (string)wi.State;
wi.Fields["State"].Value = oldAssignedTo;
wi.Save();
}
}
}