DCSIMG
TFS API Part 15: Import Work Item Definition + Validation - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

TFS API Part 15: Import Work Item Definition + Validation

TFS API Part 15: Import Work Item Definition + Validation

In my last post TFS API Part 14: Export Work Item Definition we saw how to export specific work item definition from TFS.

In this post I’ll show how to import the work item definition to TFS and how to validate the definition.

 image

Download Demo

First add reference for Microsoft.TeamFoundation, Microsoft.TeamFoundation.Client, Microsoft.TeamFoundation.Common.dll,Microsoft.TeamFoundation.WorkItemTracking.Client.dll
located in - C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\

Add using for:

using Microsoft.TeamFoundation.Proxy;

using Microsoft.TeamFoundation.Client;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

Validate Work Item Definition

        try

        {

            if (string.IsNullOrEmpty(m_projectName))

            {

                WorkItemType.Validate(store, definition);

            }

            else

            {

                WorkItemType.Validate(store.Projects[m_projectName], definition);

            }

        }

        catch (XmlException ex)

        {

            failed = true;

            MessageBox.Show("Xml Exception: \n\n" + ex.Message);

        }

image 

        catch (XmlSchemaValidationException sex)

        {

            failed = true;

            MessageBox.Show("Xml Schema Validation Exception: \n\n" + sex.Message);

        }

image

        if (!failed)

        {

            MessageBox.Show("Validation Complete");

        }

image

Import Work Item Definition

using WorkItemStore to Import the definition:

                

store.Projects[m_projectName].WorkItemTypes.Import(definition);

 image

      

Download Demo

Comments

Shai Raiten said:

TFS API Summary & My #200 Post It’s been 4 months, 3 weeks(143 days) since my ..::: My #100 Post

# February 13, 2009 11:44 PM

anonymous said:

Definitely, thanks for the great tutorials. I have learned a lot (from don't even know what TFS to creating apps for TFS in a month).

# February 14, 2009 12:53 AM

shair said:

Thanks!!!

Good Luck

# February 15, 2009 5:19 PM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# February 16, 2009 10:12 PM

thomas engen said:

But how do you create a NEW work item with export from another template. For example export Change request from the template (or project) CMMI and import it to MSF agile project?

# March 17, 2009 9:48 AM

Importation Define | More More Pics said:

Pingback from  Importation Define | More More Pics

# February 18, 2011 11:57 PM

suraj said:

hi

can you plz tell me how can I integrat TFS task to MS project 2010

# June 16, 2011 11:49 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: