c# - 快速循环 TFS 工作项或批量插入 TFS 工作项到 SQL 的快速方法
问题描述
我需要从 TFS 获取所有工作项并将每个细节存储到 SQL DB 中。我可以毫不费力地从 TFS 中获取所有内容。但没有找到将这些数据推送到 SQL Db 的完美方法。我考虑过遍历生成的对象并单独推送它们,但这非常耗时和资源消耗。所以期待一个完美的清洁解决方案。
这是我正在使用的代码
public void GetAllTfsWorkItems()
{
//List<string> projects = new List<string>();
//projects = LoadProjectsList();
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(_uri));
var workitemstore = new WorkItemStore(tpc);
Query query = new Query(workitemstore, "select * from workitems where [System.WorkItemType] in ('Epic','Bug','Feature','Product Backlog Item','Task') ");
WorkItemCollection wic = query.RunQuery();
List<string> PE = new List<string>();
List<string> fields = new List<string>();
foreach(WorkItem wi in wic)
{
PE.Add(wi.Title);
var parentlink = wi.WorkItemLinks.Cast<WorkItemLink>().FirstOrDefault(x => x.LinkTypeEnd.Name == "Parent");
WorkItem parentworkitem = null;
int parentid;
if(parentlink!=null)
{
parentid = parentlink.TargetId;
//parentworkitem = workitemstore.GetWorkItem(parentlink.TargetId);
}
}
}
public class TfsWorkItems
{
public int ID { get; set; }
public string WorkItemType { get; set; }
public string Title { get; set; }
public string AreaPath { get; set; }
public string AssignedTo { get; set; }
public string BoardColumn { get; set; }
public string State { get; set; }
public string Description { get; set; }
public string IterationPath { get; set; }
public string CreatedDate { get; set; }
public string Tags { get; set; }
public string AcceptanceCriteria { get; set; }
public string BusinessValue { get; set; }
public string Priority { get; set; }
public string Effort { get; set; }
public string PCode { get; set; }
public string Parent { get; set; }
public string Project { get; set; }
public string TeamName { get; set; }
public string DomainName { get; set; }
}
循环大约需要 10-15 分钟才能完成。但我希望有一些更简单的解决方案,例如将 WorkItem 数组对象直接映射到我的自定义类 TFSWorkItems 以及将数据推送到一起的一些方法。请提出一个更简单的解决方案。截止日期快到了,因为我猜 2019 年时间过得很快。
请注意,TFS 中大约有 250k+ 个项目
解决方案
推荐阅读
- python - 在 Eclipse FileNotFoundError 上设置 Selenium 和 Python:[WinError 2]
- sql - 我如何才能对在 SQL 中保存为 nvarchar 的日期进行排序
- css - 使用媒体查询的 Bootstrap 列顺序有问题
- javascript - 为什么手动计算字符串中的字符索引返回-1?
- r - 标记组的第一个(或第 n 个)观察
- css - AndroidSVG:如何动态更改 Inkscape svg 颜色
- oracle - 使用 Spring 4.3.0 JDBC 模板插入或更新逻辑的总记录的 5% 的处理时间很长
- javascript - 如何使用 Jasmine 监视多个类/对象方法
- python - 我正在尝试使用 notepad++ 启动一个简单的计算器程序,我做错了什么?
- javascript - 无法使用 React 实现侧导航栏