Set force ratings through the TFS SDK work file

I want to create a new work item in TFS using the SDK, and I would like to set the item effort ratings. My code currently 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 nothing exists on the WorkItem interface that allows me to establish an effort rating. Does anyone know how to do this?

+5
source share
1 answer

It turns out that this is done using the operator of the []object WorkItem.

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();
+7
source

All Articles