我正在编写一个程序,该程序将使用其子节点创建迭代。它创建一个父节点,但不创建任何子节点。 下面是我的示例代码。
WorkItemClassificationNode iterationNode = new WorkItemClassificationNode()
{
Name = "Parent Iteration",
StructureType = TreeNodeStructureType.Iteration,
Children = new List<WorkItemClassificationNode>()
{
new WorkItemClassificationNode(){ Name="child 1", StructureType= TreeNodeStructureType.Iteration },
new WorkItemClassificationNode(){ Name="child 2", StructureType= TreeNodeStructureType.Iteration },
},
Attributes = new Dictionary<string, Object>()
{
{ "startDate", DateTime.Today },
{ "finishDate", DateTime.Today.AddDays(7) },
}
};
witClient.CreateOrUpdateClassificationNodeAsync(iterationNode, Constants.TEAM_PROJECT, TreeStructureGroup.Iterations);
我只能创建“父母迭代”。需要像这样创建它: “父级迭代\子级1”和“父级迭代\子级2”
答案 0 :(得分:1)
您必须创建每个迭代(首先是父级,然后是子级)。这是我创建迭代的功能:
static WorkItemClassificationNode CreateIteration(string TeamProjectName, string IterationName, DateTime? StartDate = null, DateTime? FinishDate = null, string ParentIterationPath = null)
{
WorkItemClassificationNode newIteration = new WorkItemClassificationNode();
newIteration.Name = IterationName;
if (StartDate != null && FinishDate != null)
{
newIteration.Attributes = new Dictionary<string, object>();
newIteration.Attributes.Add("startDate", StartDate);
newIteration.Attributes.Add("finishDate", FinishDate);
}
return WitClient.CreateOrUpdateClassificationNodeAsync(newIteration, TeamProjectName, TreeStructureGroup.Iterations, ParentIterationPath).Result;
}
var newNode = CreateIteration(TeamProjectName, @"R2");
newNode = CreateIteration(TeamProjectName, @"R2.1", ParentIterationPath: @"R2");
newNode = CreateIteration(TeamProjectName, @"Ver1", new DateTime(2019, 1, 1), new DateTime(2019, 1, 7), @"R2\R2.1");