簡體   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