February 2009 - Posts
Wit-It! 1.4 – New Features 
If you don’t know what is Wit-It! please read Wit-It! – Outlook Add-in for TFS Work Item Alerts
I saw that lots of people are downloading Wit-It! and I get lots of feedbacks.
Also I got a place on MSDN forums.
It’s time for the next version of Wit-It!
I fixed couple of performance problems, change the Design to some thing more friendly.
Add couple new features to Wit-It!
Here is the list:
New Work Item
Convert Email message to Work Item


Add Email message as Attachment to Work Item


TFS API Part 16: Mapping Source Control Using VersionControlServer
In this post I’ll show how to use VersionControlServer class to map your Source Control.
This post will be the basic start of how to use VersionControlServer class in TFS API.
Download Demo
First add reference for
Microsoft.TeamFoundation
Microsoft.TeamFoundation.Client
Microsoft.TeamFoundation.Common.dll
Microsoft.TeamFoundation.VersionControl.Client.dll
located in - C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
Step 1 – Connect TFS + Create VersionControlServer Object
First I create a Domain Project Picker to get Team Foundation Server instance, and after getting tfs instance create new object type VersionControlServer.
private void btn_dp_Click(object sender, RoutedEventArgs e)
{
DomainProjectPicker dp = new DomainProjectPicker(DomainProjectPickerMode.None);
dp.ShowDialog(); //Display DomainProjectPicker
if (dp.SelectedServer != null)
{
tfs = dp.SelectedServer;
//Using ICommonStructureService to get all project in TFS.
ICommonStructureService structureService = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));
ProjectInfo[] projects = structureService.ListAllProjects();
combo_projects.ItemsSource = projects;
//Create VersionControlServer object from TFS
sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
}
}
Step 2 – Get Source Control Files and Folder
To start the mapping I’m sending the starting path of the source control
GetPathFiles(SourceControlView.Items[0] as TreeViewItem, "$/" + path);
//Example: $/ALM-Group
private void GetPathFiles(TreeViewItem TreeItem, String path)
{
try
{
RecursionType recursion = RecursionType.OneLevel;
//Also have - Full, None
Item[] items = null;
// Get the latest version of the information for the items.
ItemSet itemSet = sourceControl.GetItems(path, recursion);
items = itemSet.Items;
foreach (Item keyItem in items)
{
char[] charSeparators = new char[] { '/' };
//Using split to isolated the Project Name and the File Name
string[] ss = keyItem.ServerItem.Split(charSeparators, StringSplitOptions.None);
//!= items[0] ignore the first item, the Team Project Name
if (keyItem != items[0])
{
TreeViewItem new_item = null;
Execute exe = delegate()
{
new_item = new TreeViewItem();
//Get File or Folder Name
string filename = keyItem.ServerItem.Replace(path + "/", string.Empty);
new_item.Header = filename;
TreeItem.Items.Add(new_item);
};
this.Dispatcher.Invoke(exe, null);
GetPathFiles(new_item, keyItem.ServerItem);
}
}
}
catch (Exception ex)
{
}
}
Download Demo
My Lecture On Team System Users Group (TSUG)
Not every day you get an invitation to be a lecturer in such a honored user group, and I want to thanks Dave Mckinstry for the invitation.
My lecture was about Custom Control in Team System.
I talked about the basic steps you need to take for create your custom control.
Also I gave couple of tip and tricks while writing custom control, and of course I showed couple custom control that I wrote.
This was so much fun!!!!

Wit-It! – Outlook Add-in for TFS Work Item Alerts
After a small talk with Guy Burstein he comes up with a Great Idea : use outlook form region to show Work Item from Team System.
Then I remembered that working with Event Email in Team System are so irritating.
You can customize Event Emails to work with Team System Web Access but then you can’t open the work item in XML (sometimes you may need it)
But then I noticed that not everyone have TSWA and even this sometimes can be irritating(slow, new look), so why not to open a Work Item Form?
It’s fast, familiar or why not have all the options??
Thanks to Guy Burstein now the solution to our problem is HERE!
Wit-It!
Wit-It! allows you to open work items in various ways without customizing team system event subscription.
- Window Form – just like you’d see in Team Explorer
- XML
- Team System Web Access
Wit-It! will automatically detect which emails comes from TFS and will show you the Wit-It! panel.
12/02/09 - Update 1.1 –Web Access Fix
15/02/09 - Update 1.2 – Pass encryption & Update manager
18/02/09 - Update 1.3 – Bug Fix
Open Work Item in Form

Settings Window
1.Select TFS using local cache
Use this option when your local machine works with TFS.
Use this option when working with multiply TFS servers.
2. Manually select TFS - You can set custom connection to TFS
Use this option when working remotely (VPN etc)
Use this option if window user isn’t the TFS user or TFS requires special authorization.

Download Wit-It! - 1.3

Ask The Expert On TeamSystemLive.COM
Me and couple of Team System experts around the world joined to ChrisTullier in a new Team System site called TeamSystemLive.
TeamSystemLive.com is all about Live events covering
Microsoft Visual Studio Team System.
Pre-recorded videos are great, but there is no substitute to attending a live event and getting your specific questions answered in real time.
In addition to maintaining the best list of live VSTS events on the web, we host an informal chat session each and every week to answer your questions on Wednesday between 20:00-21:00 (UTC+02:00) Jerusalem time.
If you have a problem ,need an advice or want to know more about Team System I invite you to become a member of TeamSystemLive.
Hope to see you all.
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.
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);
}
catch (XmlSchemaValidationException sex)
{
failed = true;
MessageBox.Show("Xml Schema Validation Exception: \n\n" + sex.Message);
}
if (!failed)
{
MessageBox.Show("Validation Complete");
}

Import Work Item Definition
using WorkItemStore to Import the definition:
store.Projects[m_projectName].WorkItemTypes.Import(definition);
Download Demo
TFS API Part 14: Export Work Item Definition
In this post I’ll show how to Export work item definition using TFS API.
This action can be used for Backups script or even for third party for Work Item definition editor.

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;
Connect to TFS:
DomainProjectPicker dp = new DomainProjectPicker(DomainProjectPickerMode.None);
dp.ShowDialog();
if (dp.SelectedServer != null)
{
tfs = new TeamFoundationServer(dp.SelectedServer.Name, new UICredentialsProvider());
tfs.EnsureAuthenticated();
store = (WorkItemStore)tfs.GetService(typeof (WorkItemStore));
GetProject();
}
Get TFS Project List:
private void GetProject()
{
foreach (Project p in store.Projects)
{
cob_projects.Items.Add(new ProjectType(p));
}
}
public class ProjectType
{
public string Name { get; set; }
public WorkItemTypeCollection WitTypeCollection { get; set; }
public ProjectType(Project proj)
{
this.Name = proj.Name;
this.WitTypeCollection = proj.WorkItemTypes;
}
public override string ToString()
{
return this.Name;
}
}
Calling Export Method
private void Export(string m_projectname, string m_type)
{
try
{
XmlDocument xml_e = store.Projects[m_projectname].WorkItemTypes[m_type].Export(global.IsChecked.Value);
txt_definition.Text = xml_e.InnerXml;
}
catch (WorkItemTypeDeniedOrNotExistException ex)
{
MessageBox.Show(ex.Message);
}
}
Download Demo
TFS API Part 13: More About Connecting TFS (Custom Credentials, Prompt)
I got many request regarding TFS Connection,
- How to connect TFS with Different User name?
- How to set default user name & password?
- How to prompt Credentials for TFS?
So Here it is.
In TFS API Part 1: Domain Picker we saw how to connect TFS using Domain Picker that makes the connect to TFS very easy, But some times we just want to take the TFS server from our Cache (TFS API Part 2: Domain Picker Using Registered Servers (Cache)) and save time.
Example 1 – Make Sure User Can Authenticate With TFS
//Cache Instance
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(TFSNAME);
OR
//New Instance
TeamFoundationServer tfs = new TeamFoundationServer(TFSNAME);
//Make sure that the current user has enough permissions to connect TFS, if not an exception is raised.
tfs.EnsureAuthenticated();
Example 2 – Prompt for Credentials
//If the current user don't have enough permissions then a connection dialog will be displayed
//when EnsureAuthenticated is called below
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(TFSNAME,new UICredentialsProvider());
OR
TeamFoundationServer tfs = new TeamFoundationServer(TFSNAME,new UICredentialsProvider());
tfs.EnsureAuthenticated();
Example 3 - Custom Credentials
//Connect TFS with Custom credentials
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(TFSNAME,new NetworkCredential(username,password,domain)); OR
TeamFoundationServer tfs = new TeamFoundationServer(TFSNAME,new NetworkCredential(username,password,domain));
tfs.EnsureAuthenticated();
Example 4 – Custom Credentials With Ability to Prompt
//If the custom credential is not valid a connection dialog will displayed.
TeamFoundationServer tfs = new TeamFoundationServer(TFSNAME, new NetworkCredential(username, password, domain), new UICredentialsProvider());
Announcing TFS Performance Report Pack
Grant Holliday upload TFS Performance Reports that Microsoft use.
Quote”
We have a responsibility to ensure that the server is performing as expected and to identify any efficiencies that can be made in the server or the tools. To do this, we have created a number of reports that we use ourselves and make available to our own users.
“
The Full Article + Download
Execution Time Summary

Server Status - Source Control Request Queue
Server Status - Top Users Bypassing Proxies
Server Status - Historical Performance Trends
Server Status - Recent Performance Trends
Full Article
TFS API Part 12: Set Security For Area/Iteration
In the previous post I’ve talked about
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.Server;
using Microsoft.TeamFoundation.Client;
Here is the list for the Security Types:
GENERIC_READ
GENERIC_WRITE
CREATE_CHILDREN
WORK_ITEM_WRITE
WORK_ITEM_READ
DELETE
Using IAuthorizationService. AddAccessControlEntry to add AccessControlEntry.
AccessControlEntry(string actionId,string sid,bool deny)
New static method to AccessControl.
public static string SetAccessControl(TeamFoundationServer tfs, string action,
string sid, string nodeUri,bool type)
{
try
{
IAuthorizationService auth = (IAuthorizationService)tfs.GetService(typeof(IAuthorizationService));
// Add security for user.
auth.AddAccessControlEntry(nodeUri, new AccessControlEntry(action, sid, type));
return "OK";
}
catch(Exception ex)
{
return ex.Message;
}
}


Download Demo
SIGiST Israel Event – 02 February 2009
SIGiST live from Crowne Plaza tel aviv.
SIGiST Israel was founded in June 2000, by Mr. Alon Linetzki, and was self sponsored, for the first few meetings. Today, after many meetings, out of which several were sponsored by RadView, Rational (IBM) and Mercury (HP-Software), SIGiST Israel is the most reorganized testing community in the Israeli market. The SIGiST board today includes also Mr. Yan Baron, Director PLM Testing & Field Operations, Aternity, and Mrs. Debi Zylbermann, senior consultant in software quality assurance and website promotion.
There is not Team System lectures but still there is a lot of interesting information about the testing area.
Agenda
17:00 – 17:45 - SNAP – Innovation makes test automation a reality.
18:15 – 19:00 - Let’s Auto IT - Free Functional Test Automation Platform.
19:15 – 20:00 - All-Pairs and PICT – All-Pairs & Orthogonal Arrays Free Tools for Test Design Optimization.
Come Quick!
TFS API Part 11: Get Area/Iteration Security Settings Using IAuthorizationService
In the previous post TFS API Part 9: Get Area/Iteration Programmatically I talked about how to get Area/Iteration nodes from TFS.
In this post I’ll show to get Area/Iteration security settings using TFS IAuthorizationService.
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.Server;
using Microsoft.TeamFoundation.Client;
Download Demo
Get Node Path
XmlNode Node = tree.ChildNodes[0].ChildNodes[i];
NodeItem nodeitem = new NodeItem(Node.Attributes["Name"].Value,
Node.Attributes["NodeID"].Value, type);
if (type == StructureType.Area)
list_area.Items.Add(nodeitem);
else
list_iteration.Items.Add(nodeitem);
I made a NodeItem to collect Node Path for each from TFS.
public class NodeItem
{
public string Name { get; set; }
public string Uri { get; set; }
public Get_Area_Iteration_Security.Window1.StructureType Structure { get; set; }
public NodeItem(string name, string uri, Get_Area_Iteration_Security.Window1.StructureType structure)
{
this.Name = name;
this.Uri = uri;
this.Structure = structure;
}
public override string ToString()
{
return Name;
}
}
Using IAuthorizationService to get AccessControlEntry by NodePath
public static AccessControlEntry[] GetAccessControl(TeamFoundationServer tfs, string nodeuri)
{
IAuthorizationService auth = (IAuthorizationService)tfs.GetService(typeof(IAuthorizationService));
AccessControlEntry[] auth_list = auth.ReadAccessControlList(nodeuri);
return auth_list;
}
Selecting specific Node and write Security
NodeItem item = (NodeItem)list_area.SelectedItem;
AccessControlEntry[] list = AccessControl.GetAccessControl(server, item.Uri);
StringBuilder sb = new StringBuilder();
foreach (AccessControlEntry entry in list)
{
sb.AppendLine(entry.ActionId + "=" + entry.Deny.ToString());
}
MessageBox.Show(sb.ToString(), "Security", MessageBoxButton.OK, MessageBoxImage.Information);

Download Demo