【发布时间】:2013-11-20 21:24:34
【问题描述】:
我正在尝试对 TFS2010 中的工作项进行广泛的验证。我知道可以使用 Microsoft 提供的开箱即用规则来完成验证,但是我希望进行更高级的验证。例如,
1)如果前一个 Sprint 正在进行中,则不应进行 Sprint 计划。
2)我也在寻找工作项类型之间的验证。例如,除了当前 Sprint 中计划的状态之外,所有用户故事都不应允许状态更改。
是否可以通过 API 实现,如果可以,请指导我以上两个是我的要求....
另一个查询,或者是否可以为这种情况编写验证错误..说当我们尝试保存任何没有标题的工作项时它会抛出 TF20012...
同样我们可以处理这种情况...如果可以的话请指导我...
但我正在尝试这样,开始我正在尝试下面的代码,用于之前的 sprint 说我包括要跟踪的开始和结束日期,如果是这样,那么我必须为所有 n 个结束的 sprint 编写。 ..哪条路最好走
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();
}
}
}
【问题讨论】: