Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Effort estimates through TFS Work Item SDK

Tags:

.net

tfs

tfs-sdk

I want to create a new work item in TFS using the SDK, and I'd like to set the item's effort estimates. My code at the moment looks like this

    var coll = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://galaxy:8080/tfs/crisp"));

    var workItemService = coll.GetService<WorkItemStore>();

    var parent = workItemService.GetWorkItem(parentWorkItemId);

    WorkItemType workItemType =parent.Project.WorkItemTypes
            .Cast<WorkItemType>()
            .First(candidateType => candidateType.Name.Equals("Task"));



    WorkItem item = workItemType.NewWorkItem();
    item.Title = work.Name;


    //Set effort estimate here

    workItemService.BatchSave(new WorkItem[]{ item });

But there doesn't seem to be anything on the interface for WorkItem which allows me to set an effort estimate. Does anyone know how this is done?

like image 913
Ceilingfish Avatar asked Jan 16 '12 14:01

Ceilingfish


1 Answers

Turns out it's done by using the [] operator on the WorkItem object.

var coll = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://galaxy:8080/tfs/crisp"), new UICredentialsProvider());

var workItemService = coll.GetService<WorkItemStore>();

var parent = workItemService.GetWorkItem(parentWorkItemId);

WorkItemType workItemType =parent.Project.WorkItemTypes
            .Cast<WorkItemType>()
            .First(candidateType => candidateType.Name.Equals("Task"));

WorkItem item = workItemType.NewWorkItem();
item.Title = "A name";

item["Original Estimate"] = duration.TotalHours;
item["Completed Work"] = duration.TotalHours;
item["Remaining Work"] = 0.0;

int workItemId = item.Save();
like image 112
Ceilingfish Avatar answered Sep 28 '22 15:09

Ceilingfish