gpt4 book ai didi

c# - TFS 集成

转载 作者:太空宇宙 更新时间:2023-11-03 21:27:35 25 4
gpt4 key购买 nike

我正在尝试将 TFS 集成与 tfs 自动同步到我的数据库..我正在做的所有窗口服务......为此,我编码如下......

DataRow dr = dstSyncWorkItem.Tables["Workitems"].Rows[i];
String uri = ConfigurationManager.AppSettings["TfsUri"] + dr["ProCollectionName"];
Uri collectionUri = new Uri(uri);
NetworkCredential myNetCredentials = new NetworkCredential(ConfigurationManager.AppSettings["TfsUsername"], ConfigurationManager.AppSettings["TfsPassword"]);
ICredentials myCredentials = (ICredentials)myNetCredentials;

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri, myCredentials);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects[dr["Project"].ToString()];
WorkItemType workItemType = teamProject.WorkItemTypes[dr["Type"].ToString()];

WorkItem workItem = new WorkItem(workItemType);
workItem.Title = dr["Title"].ToString();
workItem.Description = dr["Desc"].ToString();
workItem.Save();

这将给出以下错误...

TF237124: Work Item is not ready to save.

最佳答案

您需要先验证工作项,然后才能保存它。调用:

ArrayList validation = workItem.Validate();

这将确保您所做的任何更改都是适当的,并根据您的更改进行工作项规则定义的任何其他状态更改。

如果存在验证失败,您必须妥善处理它们。否则,您可以调用:

workItem.Save();

关于c# - TFS 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26087362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com