Saturday, March 1, 2014

Create Task in TFS Using C# Code

Hi All,
Now a day’s most people make use of Team Foundation Server. We perform any activity either in form or a Task or a Bug. I have come up with a sample code by using which we can create a Task in the TFS server using Programming or C# code. I have try this With Team Foundation Server 2010 and Visual Studio 2010. For doing this we required the 2 important DLL’s of team Foundation Server which we can find while adding reference in the .Net section, the DLL’s are



We will make use of a code and will try to add a task in our TFS repository, for this we required the details to connect to our TFS server like the Root folder name, Username, Port and Password details.

Either task or Bug both the Part of the Work Item so we will create the object of the Work Item Class like

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace SampleTFSTask
    class Program
        static void Main(string[] args)
            Console.WriteLine(" // Connect to the TFS, and get the WorkItemType object");
            Uri collectionUri = (args.Length < 1) ?
                new Uri("") : new Uri(args[0]);

            TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);

            WorkItemStore workItemStore = tpc.GetService();

            Project teamProject = workItemStore.Projects["MVP"];

            WorkItemType workItemType = teamProject.WorkItemTypes["User Story"];

            // Create the work item.
            WorkItem userStory = new WorkItem(workItemType)
                // The title is the only required field that does not have a default value.
                // You must set it, or you cannot save the work item.
                Title = "Recently awarded MVP",
                Description = " I want to see List of all MVP."

            // Save the new user story.

Hope You find this piece of information useful. Please feel free to extend and provide comment on the same.

Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM
What is KANBAN
Kanban is a new technique for managing a software development process in a highly efficient way. Kanban underpins Toyota's "just-in-time" (JIT) production system. It is first developed and used by them. Kanban is a visual signal that’s used to trigger an action. As we know the word kanban is Japanese. Roughly translated, it means “card you can see.”
Toyota introduced and refined the use of kanban in a relay system to standardize the flow of parts in their production lines in the 1950s.  Kanban process starts with the customer’s order and follows production downstream. Because all requests for parts are pulled from the order, kanban is sometimes referred to as a "pull" system.
In software development process, it can be thought of as a pipeline with feature requests entering one end and improved software emerging from the other end. In simple terms the requirement comes in simple form from the user and finally comes with a finished product or services or part of service.
We can divide the input and output as below mentioned category:-
1. Analyze the requirements
2.  Develop the code
3. Test it works.
Simply we make use of a Board generally called the KanaBan Board which can have the representation as

There are six generally accepted rules for kanban:
1.      Downstream processes may only withdraw items in the precise amounts specified on the kanban.
2. Upstream processes may only send items downstream in the precise amounts and sequences specified by the kanban.
3. No items are made or moved without a kanban.
4. A kanban must accompany each item at all times.
5. Defects and incorrect amounts are never sent to the next downstream process.
6. The number of kanbans should be monitored carefully to reveal problems and opportunities for improvement.

Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM