使用C#获取待办事项级别的工作项类型(TFS 2017)

时间:2019-10-23 14:39:02

标签: azure-devops

是否可以使用C#(TFS 2017)获取积压级别的工作项类型

我现在要做的是

            TfsTeamProjectCollection teamProjectCollection = connectToTfs();
            WorkItemStore workItemStore = teamProjectCollection.GetService<WorkItemStore>();
            Project p = workItemStore.Projects[projectname];
            List<WorkItemType> col = p.WorkItemTypes.Cast<WorkItemType>().ToList();

它获取所有工作项类型,但我只需要现有的积压级工作项类型。为了澄清我的意思是积压级工作项类型,这里是屏幕

1 个答案:

答案 0 :(得分:1)

您可以调用BacklogConfiguration API来检索每个待办事项级别的工作项类型和默认工作项类型。

请参阅:https://docs.microsoft.com/en-us/rest/api/azure/devops/work/backlogconfiguration/get?view=azure-devops-rest-5.1

GET https://dev.azure.com/fabrikam/Fabrikam-Fiber/_apis/work/backlogconfiguration?api-version=5.1

{
  "taskBacklog": {
    "id": "Microsoft.TaskCategory",
    "name": "Tasks",
    "rank": 1,
    "workItemCountLimit": 1000,
    "addPanelFields": [
      {
        "referenceName": "System.Title",
        "name": "Title",
        "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
      }
    ],
    "columnFields": [
      {
        "columnFieldReference": {
          "referenceName": "System.Title",
          "name": "Title",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 400
      },
      {
        "columnFieldReference": {
          "referenceName": "System.State",
          "name": "State",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 100
      },
      {
        "columnFieldReference": {
          "referenceName": "System.AssignedTo",
          "name": "Assigned To",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 100
      },
      {
        "columnFieldReference": {
          "referenceName": "Microsoft.VSTS.Scheduling.RemainingWork",
          "name": "Remaining Work",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 50
      }
    ],
    "workItemTypes": [
      {
        "name": "Task",
        "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Task"
      }
    ],
    "defaultWorkItemType": {
      "name": "Task",
      "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Task"
    },
    "color": "F2CB1D"
  },
  "requirementBacklog": {
    "id": "Microsoft.RequirementCategory",
    "name": "Stories",
    "rank": 2,
    "workItemCountLimit": 1000,
    "addPanelFields": [
      {
        "referenceName": "System.Title",
        "name": "Title",
        "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
      }
    ],
    "columnFields": [
      {
        "columnFieldReference": {
          "referenceName": "System.WorkItemType",
          "name": "Work Item Type",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 100
      },
      {
        "columnFieldReference": {
          "referenceName": "System.Title",
          "name": "Title",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 400
      },
      {
        "columnFieldReference": {
          "referenceName": "System.State",
          "name": "State",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 100
      },
      {
        "columnFieldReference": {
          "referenceName": "Microsoft.VSTS.Scheduling.StoryPoints",
          "name": "Story Points",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 50
      },
      {
        "columnFieldReference": {
          "referenceName": "Microsoft.VSTS.Common.ValueArea",
          "name": "Value Area",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 100
      },
      {
        "columnFieldReference": {
          "referenceName": "System.IterationPath",
          "name": "Iteration Path",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 200
      },
      {
        "columnFieldReference": {
          "referenceName": "System.Tags",
          "name": "Tags",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        },
        "width": 200
      }
    ],
    "workItemTypes": [
      {
        "name": "Ticket",
        "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Ticket"
      },
      {
        "name": "User Story",
        "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/User%20Story"
      }
    ],
    "defaultWorkItemType": {
      "name": "User Story",
      "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/User%20Story"
    },
    "color": "009CCC"
  },
  "portfolioBacklogs": [
    {
      "id": "Microsoft.EpicCategory",
      "name": "My level",
      "rank": 4,
      "workItemCountLimit": 1000,
      "addPanelFields": [
        {
          "referenceName": "System.Title",
          "name": "Title",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        }
      ],
      "columnFields": [
        {
          "columnFieldReference": {
            "referenceName": "System.WorkItemType",
            "name": "Work Item Type",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 100
        },
        {
          "columnFieldReference": {
            "referenceName": "System.Title",
            "name": "Title",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 400
        },
        {
          "columnFieldReference": {
            "referenceName": "System.State",
            "name": "State",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 100
        },
        {
          "columnFieldReference": {
            "referenceName": "Microsoft.VSTS.Scheduling.Effort",
            "name": "Effort",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 50
        },
        {
          "columnFieldReference": {
            "referenceName": "Microsoft.VSTS.Common.BusinessValue",
            "name": "Business Value",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 50
        },
        {
          "columnFieldReference": {
            "referenceName": "Microsoft.VSTS.Common.ValueArea",
            "name": "Value Area",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 100
        },
        {
          "columnFieldReference": {
            "referenceName": "System.Tags",
            "name": "Tags",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 200
        }
      ],
      "workItemTypes": [
        {
          "name": "Epic",
          "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Epic"
        }
      ],
      "defaultWorkItemType": {
        "name": "Epic",
        "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Epic"
      },
      "color": "60af49"
    },
    {
      "id": "Microsoft.FeatureCategory",
      "name": "Features",
      "rank": 3,
      "workItemCountLimit": 1000,
      "addPanelFields": [
        {
          "referenceName": "System.Title",
          "name": "Title",
          "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
        }
      ],
      "columnFields": [
        {
          "columnFieldReference": {
            "referenceName": "System.WorkItemType",
            "name": "Work Item Type",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 100
        },
        {
          "columnFieldReference": {
            "referenceName": "System.Title",
            "name": "Title",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 400
        },
        {
          "columnFieldReference": {
            "referenceName": "System.State",
            "name": "State",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 100
        },
        {
          "columnFieldReference": {
            "referenceName": "Microsoft.VSTS.Scheduling.Effort",
            "name": "Effort",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 50
        },
        {
          "columnFieldReference": {
            "referenceName": "Microsoft.VSTS.Common.BusinessValue",
            "name": "Business Value",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 50
        },
        {
          "columnFieldReference": {
            "referenceName": "Microsoft.VSTS.Common.ValueArea",
            "name": "Value Area",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 100
        },
        {
          "columnFieldReference": {
            "referenceName": "System.Tags",
            "name": "Tags",
            "url": "https://dev.azure.com/fabrikam/_apis/wit/fields"
          },
          "width": 200
        }
      ],
      "workItemTypes": [
        {
          "name": "Feature",
          "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Feature"
        }
      ],
      "defaultWorkItemType": {
        "name": "Feature",
        "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/wit/workItemTypes/Feature"
      },
      "color": "773B93"
    }
  ],
  "workItemTypeMappedStates": [
    {
      "workItemTypeName": "User Story",
      "states": {
        "New": "Proposed",
        "Active": "InProgress",
        "Resolved": "InProgress",
        "In Progress": "InProgress",
        "Closed": "Completed"
      }
    },
    {
      "workItemTypeName": "Ticket",
      "states": {
        "New": "Proposed",
        "Active": "InProgress",
        "Closed": "Completed"
      }
    },
    {
      "workItemTypeName": "Feature",
      "states": {
        "New": "Proposed",
        "Active": "InProgress",
        "Resolved": "InProgress",
        "Closed": "Completed"
      }
    },
    {
      "workItemTypeName": "Epic",
      "states": {
        "New": "Proposed",
        "Active": "InProgress",
        "Closed": "Completed"
      }
    },
    {
      "workItemTypeName": "Task",
      "states": {
        "New": "Proposed",
        "Active": "InProgress",
        "Closed": "Completed"
      }
    },
    {
      "workItemTypeName": "Bug",
      "states": {
        "Proposed": "Proposed",
        "Testing": "InProgress",
        "Resolved": "Resolved",
        "Closed": "Completed"
      }
    }
  ],
  "backlogFields": {
    "typeFields": {
      "Order": "Microsoft.VSTS.Common.StackRank",
      "Effort": "Microsoft.VSTS.Scheduling.StoryPoints",
      "RemainingWork": "Microsoft.VSTS.Scheduling.RemainingWork",
      "Activity": "Microsoft.VSTS.Common.Activity"
    }
  },
  "bugsBehavior": "asTasks",
  "hiddenBacklogs": [
    "Microsoft.EpicCategory"
  ],
  "url": "https://dev.azure.com/fabrikam/c3b6da71-2b4a-497b-9137-ba8695203871/_apis/work/backlogconfiguration"
}