繁体   English   中英

使用c#在Azure DevOps(VSTS)中使用子节点创建迭代

[英]create iteration with child nodes in Azure DevOps (VSTS) using c#

我正在编写一个程序,它将使用其子节点创建迭代。 它创建一个父节点,但不创建任何子节点。 以下是我的示例代码。

我从以下链接获得帮助: https : //github.com/microsoft/azure-devops-dotnet-samples/blob/master/ClientLibrary/Samples/WorkItemTracking/ClassificationNodesSample.cs

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);

我只能创建“父母迭代”。 需要像这样创建它:“ Parent Iteration \\ Child 1”和“ Parent Iteration \\ Child 2”

您必须创建每个迭代(首先是父级,然后是子级)。 这是我创建迭代的功能:

    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");

使用的示例在这里: https : //github.com/ashamrai/TFRestApi/blob/master/08.TFRestApiAppAreasAndIterations/TFRestApiApp/Program.cs

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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