【发布时间】:2019-12-02 06:10:42
【问题描述】:
我正在创建我的第一个 ASP.NET MVC 项目。我已经开始通过 C# 连接 TFS 并在 TFS 中添加错误。
var tfsURI = new Uri("http://test:8080/tfs");
var networkCredential1 = new NetworkCredential("test", "test!");
ICredentials credential = (ICredentials)networkCredential1;
Microsoft.VisualStudio.Services.Common.WindowsCredential winCred = new Microsoft.VisualStudio.Services.Common.WindowsCredential(credential);
VssCredentials vssCredentials = new VssCredentials(winCred);
using (TfsTeamProjectCollection collection = new TfsTeamProjectCollection(tfsURI, vssCredentials))
{
collection.EnsureAuthenticated();
WorkItemStore workItemStore = collection.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["Test"];
WorkItemType workItemType = teamProject.WorkItemTypes["Bug"];
WorkItem Defect = new WorkItem(workItemType);
FileInfo fi = new FileInfo(@"C:\\Document.docx");
Attachment tfsAttachment = new Attachment(fi.FullName);
Defect.Attachments.Add(tfsAttachment);
Defect.Title = "Testing from VS to TFS Bug";
Defect.Description = "Testing from VS to entered Bug in to TFS.";
Defect.Fields["Assigned To"].Value = "Test";
Defect.Save();
}
上面显示的这段代码可以正常工作。
但是使用 SQL Server 存储过程是否可以达到相同的结果?有什么方法可以连接到 TFS 并使用存储过程将 bug 添加到 TFS 中?
我有我的数据库,我想从 sql 存储过程连接到 TFS 并创建 WorkItem。通过 C# 我已经完成了上面的示例。但是,如果可以从存储过程中实现相同的目标,我需要任何示例。
【问题讨论】:
-
在答案 @PatrickLu-MSFT 的 cmets 中,您说:'取决于表中的条目'您已经在 C# 中使用工作代码将 WorkItems 添加到 TFS -- 为什么不也使用 C# 和 ADO.NET 来发出 SQL 查询并直接在 C# 代码中获取表数据?
标签: c# sql .net sql-server tfs