Answered Work Item TFS

Tutte le risposte

  • venerdì 2 marzo 2012 15:45
     
     Con risposta
    Answered here http://social.msdn.microsoft.com/Forums/en-US/tfsgeneral/thread/1ff5415e-0ef2-4c65-b0b7-a109187adf51 (Creating Work Items using TFS API (C#))

    Please remember to mark the replies as answers if they help.

    Tarun Arora

    Blog: http://geekswithblogs.net/TarunArora  Subscribe in a reader

  • lunedì 5 marzo 2012 10:42
     
     

    Thanks, but  I don't understand why I need get existings WorkItems from TFS? I need only create new. But using this code from example, we also get workitems from TFS.

     using (TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(value)))
                {
                    WorkItemStore workItemStore = projectCollection.GetService<WorkItemStore>();

                    WorkItem parent = workItemStore.GetWorkItem(11);
                    string parentTeamProject = parent.Fields[value].Value.ToString();
                    WorkItemType WorkItemType = workItemStore.Projects[parentTeamProject].WorkItemTypes[1];
                    WorkItem workItem = WorkItemType.NewWorkItem();
                    workItem.Fields["Title"].Value = "Random name";
                    workItem.Description = "Random Description";
                    workItem.Save();

                    int newChildWorkItemID = workItem.Id;
                }

  • mercoledì 7 marzo 2012 06:17
    Moderatore
     
     Con risposta Contiene codice

    Hello Z.Zidane,

    It is OK if you do not have the get work items lines in your sample code. So, you may have your code to be similar to the following:

    using (TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(value)))
                 {
                     WorkItemStore workItemStore = projectCollection.GetService<WorkItemStore>();
     
                     WorkItemType WorkItemType = workItemStore.Projects["TeamProjectName"].WorkItemTypes["WorkItemTypeName"];
                     WorkItem workItem = WorkItemType.NewWorkItem();
                     workItem.Fields["Title"].Value = "Random name";
                     workItem.Description = "Random Description";
                     workItem.Save();
     
                 }
    

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

  • giovedì 8 marzo 2012 15:32
     
     Con risposta

    Thanks Vicky.

    Z.Zidane - The sample showed how u can retrieve and create work item from the retrieved work items. More samples on the workItemStore available here http://blogs.microsoft.co.il/blogs/shair/archive/2011/05/18/tfs-api-index-parts-1-to-37.aspx


    Please remember to mark the replies as answers if they help.

    Tarun Arora

    Blog: http://geekswithblogs.net/TarunArora  Subscribe in a reader