tags:

views:

18

answers:

1

Hi,

I have created proxy in asp.net and calling it from java. thanks for your support. Now, I want to query workitem history to get all change events. For an example. If I change assignee of the bug , as it shows in history column of Studio 2010, I want to query history , which should result xyz workitem has changed from old value to new value. I have tried to query WorkItems as following :

String queryWorkItemByDate = "SELECT * FROM WorkItems WHERE [System.TeamProject] = '" + projectName + "' and [System.WorkItemType] = 'Bug' and [System.ChangedDate] >= '6/22/2010 6:00:00 PM'";

But, this query gives current state of work item not history. How can I query WorkItem History using object model ?

Regards.

Riddhi Shah

A: 

You will want to look at the embedded revision collection to see what changed.

    TeamFoundationServer tfs = new TeamFoundationServer("http://tfs:8080");
    tfs.EnsureAuthenticated();

    WorkItemStore wis = tfs.GetService<WorkItemStore>();

    var results = wis.Query("select * from workitems where [System.WorkitemType] = 'Bug'");

    WorkItem wi = results[0];

    foreach (Revision r in wi.Revisions)
    {
        System.Diagnostics.Debug.WriteLine("Revisions:");

        for(int i = 0; i < r.Fields.Count; i++)
        {
            string revisionText = string.Format("Field {0} was '{1}' and is now '{2}'",
                                               r.Fields[i].Name,
                                               r.Fields[i].OriginalValue,
                                               r.Fields[i].Value);

            System.Diagnostics.Debug.WriteLine(revisionText);
            }

    }
Robaticus
Hi,Thanks a lot for solution. This has a drawback of iterating all the revisions. What I am aiming is, I should directly get revisions which are done after certain date. I think , WIQL does not support to query revisions. I have also tried to see in the database. But I till now I haven't get ant luck in finding , where (In which table) these data is maintained.If you have any clue around this , please let me know.Once again , thank you so much for the reply.Regards,Riddhi Shah
Riddhi
Which database are you looking at? TFSWarehouse?
Robaticus