我在使用C#和TFS编程编写自定义应用程序时遇到困难,我想要分配WorkItem的日期,即当X工作项被分配给用户时。
请帮帮我。我试过以下查询
private void getWorkItems(TfsTeamProjectCollection projectCollection, string user)
{
WorkItemStore workItemStore = (WorkItemStore)projectCollection.GetService(typeof(WorkItemStore));
string query = string.Format("select * from WorkItems WHERE [Work Item Type] <> 'Code Review Request' AND [Work Item Type] <> 'Code Review Response' AND( [Assigned To]='{0}' OR [Changed By]='{1}' AND [Changed Date]>='{1}' AND [Changed Date]<='{2}') ",
user,
user);
var workitems = workItemStore.Query(query).Cast<WorkItem>().Select(wi => wi);
workItemGrid.DataSource = getWorkItemDetails(workitems, workItemStore, user).OrderBy(w => w.WorkItemNumber).ToList();
workItemGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
progressBarworkItems.Visible = false;
}
答案 0 :(得分:0)
您应该能够调整以下代码:
public static WorkItem GetWorkItem(int workItemId)
{
Uri tfsUri = new Uri("http://mytfsserver:8080/tfs");
TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri);
WorkItemStore workItemStore = tfs.GetService<WorkItemStore>();
return workItemStore.GetWorkItem(workItemId);
}
public static void PrintRevisions(int workItemId)
{
WorkItem wi = GetWorkItem(workItemId);
foreach (Revision revision in wi.Revisions)
{
Console.WriteLine("Revision {0}", revision.Fields["Rev"].Value);
string assignedTo = revision.Fields["Assigned To"].Value.ToString();
string changedDate = revision.Fields["Changed Date"].Value.ToString();
string changedBy = revision.Fields["Changed By"].Value.ToString();
if (!string.IsNullOrEmpty(assignedTo))
Console.WriteLine("Assigned To: {0} Date: {1} By: {2}", assignedTo, changedDate, changedBy);
}
}