1: using System;
2: using System.Collections;
3: using System.Collections.Generic;
4: using System.Text;
5: using Microsoft.TeamFoundation.Client;
6: using Microsoft.TeamFoundation.WorkItemTracking.Client;
7:
8: namespace EnterWorkItems
9: {
10: class Program
11: {
12: static void Main(string[] args)
13: {
14: TeamFoundationServer tfs = new TeamFoundationServer("TFSServer");
15: WorkItemStore wis = (WorkItemStore) tfs.GetService(typeof(WorkItemStore));
16:
17: Project teamProject = wis.Projects[0];
18: foreach (WorkItemType wit in teamProject.WorkItemTypes)
19: Console.WriteLine(wit.Name);
20:
21: WorkItemCollection wic = wis.Query("Project='Test' AND Type='Bug'");
22: foreach (WorkItem wiEntry in wic)
23: {
24: }
25:
26: WorkItemType witBug = teamProject.WorkItemTypes["Bug"];
27: if (witBug != null)
28: {
29: Console.WriteLine("Adding new bug to Team Project {0}", teamProject.Name);
30:
31: WorkItem wi = new WorkItem(witBug);
32: wi.Description = "This is a sample bug which was added through the object model";
33: wi.Reason = "New";
34: wi.Title = "You have Bugs! [Ding]";
35:
36: wi.Save();
37: Console.WriteLine("Added Work Item # {0} created by {1}", wi.Id, wi.CreatedBy);
38: }
39: }
40: }
41: }
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.