using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using System.Net;
using System.Collections ;
namespace tfs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
TeamFoundationServer tfsh;
VersionControlServer versionControl;
//string Collection = string.Empty;
private void Button1_Click(object sender, EventArgs e)
{
TeamFoundationServer tfsh;
VersionControlServer versionControl;
System.Net.NetworkCredential credential = new System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text);
string TFSServerPath = @"http://wr03svr80610728:8080/tfs/ICICIL";
//string TFSServerPath = @"https://app2.icicilombard.com/tfs/ilprojectcollection04";
tfsh = new TeamFoundationServer(TFSServerPath, credential);
tfsh.Authenticate();
MessageBox.Show("Connected To TFS");
versionControl = (VersionControlServer)tfsh.GetService(typeof(VersionControlServer));
string fromdate = textBox3.Text;
string todate = textBox4.Text;
DateTime fd = Convert.ToDateTime(fromdate);
DateTime td = Convert.ToDateTime(todate);
VersionSpec fromDateVersion = new DateVersionSpec(fd);
VersionSpec toDateVersion = new DateVersionSpec(td);
//IEnumerable Data = versionControl.QueryHistory(”$/”, VersionSpec.Latest, 0, RecursionType.Full, null, fromDateVersion, toDateVersion, int.MaxValue,true, true);
string user = "";
IEnumerable Data = versionControl.QueryHistory("$/ICICIL/MIGRATION_UAT/PRODUCTS/LoanProducts.ICICI", VersionSpec.Latest, 0, RecursionType.Full, user, fromDateVersion, toDateVersion, int.MaxValue, true, true);
ItemSet items = versionControl.GetItems("$/ICICIL/MIGRATION_UAT/PRODUCTS/LoanProducts.ICICI", VersionSpec.Latest, RecursionType.Full);
IEnumerable item = items.Items;
StringBuilder sb = new StringBuilder();
string Collection = string.Empty;
string test = string.Empty;
try
{
foreach (Changeset o in Data)
{
Collection += " Changeset: " + o.ChangesetId + " ----- " + o.CreationDate + "\r\n";
}
richTextBox1.Text = Collection.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
try
{
foreach (Item i in Data)
{
test += " Item: " + i.ServerItem + " ----- " + "\r\n";
}
richTextBox2.Text = test.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//richTextBox1.Text = Collection.ToString();
//richTextBox1.Text = sb.ToString();
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
DateTime d1 = dateTimePicker1.Value;
this.textBox3.Text = d1.Date.ToString();
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
DateTime d2 = dateTimePicker2.Value;
this.textBox4.Text = d2.Date.ToString();
}
}
}
Unable to cast object of type 'Microsoft.TeamFoundation.VersionControl.Client.Changeset' to type 'Microsoft.TeamFoundation.VersionControl.Client.Item'.