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

다음 단계를 수행하여 버그, 작업 및 기타 형식의 WorkItem을 만들 수 있습니다.

  1. WorkItem을 생성합니다.

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

  3. WorkItem을 저장합니다.

예제

만드는 WorkItem의 형식에 따라 대부분의 필수 Fields에는 기본값이 있습니다. 이러한 값이 적절한 경우에는 명시적으로 설정하지 않아도 됩니다. 예를 들어 Visual Studio ALM용 MSF for Agile Software Development에 정의된 대로 사용자 스토리를 만들 수 있습니다. 이 WorkItem 형식의 경우 상태, 이유 및 배정 대상 Fields는 모두 필수 필드이며 기본값이 있습니다. 사용자 스토리를 만들 때 기본 상태는 "활성"이고 기본 이유는 "신규"이며 배정 대상 필드의 기본값은 현재 사용자입니다. 그러나 역시 필수 필드인 제목에는 기본값이 없습니다. 따라서 사용자 스토리를 만들 때는 제목을 설정해야 합니다. 자세한 내용은 사용자 스토리(Agile)[리디렉션]Visual Studio TFS에서 구성 및 사용자 지정할 수 있는 작업에 대한 종단 간 뷰를 참조하세요. 다음 예에서는 사용자 스토리를 만들고 필수 필드인 제목 및 필수 필드가 아닌 설명을 설정합니다.

사용자 스토리

이 예제를 사용하려면

  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 generally the only required field that doesn’t have a default value. 
                // You must set it, or you can’t save the work item. If you’re working with another
                // type of work item, there may be other fields that you’ll have to set.
                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("User Story")

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

       ' The title is generally the only required field that doesn’t have a default value. 
       ' You must set it, or you can’t save the work item. If you’re working with another
       ' type of work item, there may be other fields that you’ll have to set.
        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

참고

WorkItemStore.BatchSave 메서드를 사용하면 단일 왕복에서 둘 이상의 WorkItem 또는 WorkItemLink를 저장할 수 있습니다.

참고 항목

작업

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

참조

BatchSave

개념

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

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