Bom, para isso devemos instalar o SDK do VS 2005... ai o resto eh simples:
Para conectar:
const string SERVER = "TFSRTM";
const string PROJECT = "Module05";
private TeamFoundationServer Conect()
{
// get the Work Item store from the TeamFoundationServer
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(SERVER);
return tfs;
}
No evento click de um botao em um grid view vamos adicionar todos ou os work itens selecionados no Combo
private void button1_Click(object sender, EventArgs e)
{
TeamFoundationServer tfs = Conect();
WorkItemStore store =
(WorkItemStore)tfs.GetService(typeof(WorkItemStore));
Project project = store.Projects[PROJECT];
int queryIndex = 0;
//find the all Work Item query
String NomeQuery = "";
foreach (StoredQuery query in project.StoredQueries)
{
if (comboBox1.Text.ToString() == "Todos")
NomeQuery = "All Work Items";
if (comboBox1.Text.ToString() == "Bugs")
NomeQuery = "Active Bugs";
if (comboBox1.Text.ToString() == "Quality of Service Requirements")
NomeQuery = "All Quality of Service Requirements";
if (comboBox1.Text.ToString() == "Quality of Service Requirements")
NomeQuery = "All Quality of Service Requirements";
if (comboBox1.Text.ToString() == "Scenarios")
NomeQuery = "All Scenarios";
if (comboBox1.Text.ToString() == "Task")
NomeQuery = "All Tasks";
if (query.Name == NomeQuery)
{
break;
}
queryIndex++;
}
StoredQuery storedQuery = project.StoredQueries[queryIndex];
// Fill in the query context.
Hashtable context = new Hashtable();
context.Add("project", project.Name);
// execute the query and retrieve a collection of workitems
WorkItemCollection workitems = store.Query(storedQuery.QueryText, context);
dgvWorkItems.DataSource = workitems;
dgvWorkItems.Columns["Title"].DisplayIndex = 0;
dgvWorkItems.Columns["Title"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
dgvWorkItems.Columns["Description"].DisplayIndex = 1;
Ja para preencher o combo
comboBox1.Items.Add("Todos");
TeamFoundationServer tfs = Conect();
WorkItemStore store =
(WorkItemStore)tfs.GetService(typeof(WorkItemStore));
Project project = store.Projects[PROJECT];
foreach (WorkItemType tipo in project.WorkItemTypes)
{
comboBox1.Items.Add(tipo.Name );
}
Simples certo? alem desse exemplo podemos fazer um milhao de coisas direto na API... assim evita a necessidade da compra de VS pra todos no projeto.
[]'s