Team Foundation용 클라이언트 개체 모델을 사용하여 작업 항목 만들기

버그, 작업 및 다른 유형을 만들 수 있습니다 WorkItems가 다음 단계를 수행 하십시오.

  1. 생성 된 WorkItem.

  2. 필수 필드의 값을 설정 합니다.

  3. Save the WorkItem.

예제

종류에 따라 WorkItem 가장 필요한 만드는 Fields 기본값이 있습니다.이러한 값을 해당 하는 경우 명시적으로 설정할 필요가 없습니다.예를 들어, 사용자 사용자 스토리에 정의 된 대로 만들 수 있습니다 Visual Studio ALM용 Agile 프로세스 템플릿.이 형식에 대 한 WorkItem, 상태, 이유, 그리고 담당자 Fields 모두 필요 하지만 기본값이 있습니다.사용자 스토리를 만들 때, 기본 상태 이며 "새로 만들기", "활성", 해당 기본 이유입니다 담당자 필드의 기본값은 현재 사용자입니다.그러나 제목 필요 하며 기본 값이 없습니다.따라서, 사용자 스토리를 만들 때 제목을 설정 해야 합니다.자세한 내용은 사용자 스토리(Agile)팀 프로젝트 및 프로세스 사용자 지정를 참조하십시오.사용자 스토리를 만드는 예제입니다. 반드시 제목을 설정 합니다. 필요 하지 않은 설명을 설정 합니다.

사용자 스토리

이 예제를 사용 하려면

  1. C# (또는 VB) 콘솔 응용 프로그램을 만듭니다.

  2. 다음 어셈블리에 대한 참조를 추가합니다.

  3. Program.cs (또는 Module1.vb)의 내용을이 예제로 바꿉니다.

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace WorkItemTrackingSample
{
    class Program
    {
        static void Main(string[] args)
        {            // Connect to the server and the store, and get the WorkItemType object
            // for user stories from the team project where the user story will be created. 
            Uri collectionUri = (args.Length < 1) ?
                new Uri("http://server:port/vdir/DefaultCollection") : new Uri(args[0]);
            TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
            WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
            Project teamProject = workItemStore.Projects["DinnerNow"];
            WorkItemType workItemType = teamProject.WorkItemTypes["User Story"];

            // Create the work item. 
            WorkItem userStory = new WorkItem(workItemType)
            {
                // The title is the only required field that does not have a default value. 
                // You must set it, or you cannot save the work item. 
                Title = "Recently ordered menu",
                Description =
                    "As a return customer, I want to see items that I've recently ordered."
            };

            // Save the new user story. 
            userStory.Save();
        }
    }
}
Imports System
Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client
Module Module1

    Sub Main(ByVal sArgs() As String)
        ' Connect to the server and the store and get the WorkItemType object
        ' for user stories from the team project where the user story will be created.

        Dim collectionUri As Uri
        If sArgs.Length = 0 Then
            collectionUri = New Uri("https://Server:8080/tfs/DefaultCollection")
        Else
            collectionUri = New Uri(sArgs(1))
        End If

        Dim tpc As New TfsTeamProjectCollection(collectionUri)
        Dim workItemStore As WorkItemStore
        workItemStore = tpc.GetService(Of WorkItemStore)()
        Dim teamProject As Project
        teamProject = workItemStore.Projects("DinnerNow")
        Dim workItemType As WorkItemType
        workItemType = teamProject.WorkItemTypes("UserTypes")

        ' Create the work item
        Dim userStory As New Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem(workItemType)

        ' The title is the only required field that does not have a default value
        ' You must set it, or you cannot save the item
        userStory.Title = "Recently Ordered Menu"
        userStory.Description = "As a return customer, I want to see items that I've recently ordered"

        ' Save the new user story
        userStory.Save()



    End Sub

End Module

[!참고]

두 개 이상 저장할 수 있습니다 WorkItem 또는 WorkItemLink 를 사용 하 여 단일 라운드트립에서 WorkItemStore.BatchSave 메서드.

참고 항목

작업

Team Foundation용 클라이언트 개체 모델을 사용하여 작업 항목 편집 및 저장

참조

BatchSave

개념

Team Foundation용 클라이언트 개체 모델을 사용하여 작업 항목 추적 확장

Team Foundation용 클라이언트 개체 모델을 사용하여 여러 형식의 작업 항목에 대한 코드 작성