积极答复者
如何从TFS数据库读取一个工作项的历史记录、revisions或 discussion ?

问题
-
我需要快速获取工作项的历史记录(发表意见)
个人测试得到:
- 从api获取不可取(归咎于 workitem.open()耗时严重和java tfs sdk的1000个工作项报内存溢出),现在打算通过数据库以读的方法 快速获取历史记录。 具体过程如下方附上的问题。
- 尝试爬取整个TFS数据库的表结构,查找出所有能匹配到 history或revision的字段,方法如下
ResultSet res = dmd.getColumns(null, null, "%", null); while (res.next()) { if(res.getString("COLUMN_NAME").contains("history") || res.getString("COLUMN_NAME").contains("History") || res.getString("COLUMN_NAME").contains("HISTORY") || res.getString("COLUMN_NAME").contains("Revision") || res.getString("COLUMN_NAME").contains("REVISION") || res.getString("COLUMN_NAME").contains("revision")) { System.out.println( res.getString("TABLE_NAME") + ", "+res.getString("COLUMN_NAME") + ", "+res.getInt("COLUMN_SIZE") + ", "+res.getInt("NULLABLE")); } }
结果如下,没有找到有用的字段,但发现"sysfos"这张表无法在SQLServer控制台访问
- tbl_Board, Revision, 10, 1
tbl_BugFieldMapping, Revision, 10, 0
tbl_Configuration, Revision, 10, 0
tbl_Discussion, Revision, 10, 0
tbl_MergeHistory, RenameHistory, 1, 0
tbl_PendingRollback, KeepMergeHistory, 1, 0
tbl_Plan, Revision, 10, 0
tbl_Point, Revision, 10, 0
tbl_RollbackHistory, KeepMergeHistory, 1, 0
tbl_Session, Revision, 10, 0
tbl_Suite, Revision, 10, 0
tbl_TestActionResult, SharedStepRevision, 10, 1
tbl_TestResult, TestCaseRevision, 10, 0
tbl_TestResult, Revision, 10, 0
tbl_TestResultReset, Revision, 10, 0
tbl_TestRun, Revision, 10, 0
tbl_TestSettings, Revision, 10, 0
tbl_Variable, Revision, 10, 0
vw_Configuration, Revision, 10, 0
vw_Plan, Revision, 10, 0
vw_Point, Revision, 10, 0
vw_RecursivePoints, Revision, 10, 0
vw_Session, Revision, 10, 0
vw_Suite, Revision, 10, 0
vw_TestResult, TestCaseRevision, 10, 0
vw_TestResult, Revision, 10, 0
vw_TestRun, Revision, 10, 0
vw_TestSettings, Revision, 10, 0
sysfos, history, 6000, 1
请问如何从数据库获取工作项的历史记录(发表意见)呢?需要具体的表和字段名。
以下是关于workitem.open()耗时的验证
workItemClient.query().getWorkItem(0).getRevisions().size() always is 0 before use workitem.open()
- workItemClient.query() 返回集合中的工作项使用getRevisions() 总是得到空的集合
WorkItem workItem = workItemClient.query(wiql).getWorkItem(0);
RevisionCollection revisionCollection = workItem.getRevisions(); int sizeBeforeOpen = revisionCollection.size(); workItem.open(); int sizeAfterOpen = revisionCollection.size();
以上代码中
- sizeBeforeOpen 为 0 , sizeAfterOpen 为 3
- workitem.open()耗时严重,300个工作项顺序执行open(),平均耗时达到45ms,直接使每个工作项的操作耗时翻倍。
- 如何使query()返回的workitemcollection中所用workitem的Revisions都能不经open操作,自动载入?
- 使用的是java
以上,感谢
工作就是爱好。
- 已编辑 Allen WOE 2016年6月20日 3:30
答案
-
make it !!!
use sql like blow
select [System.Id],[system.ChangedBy],[system.Rev],[words] from Tfs_DefaultCollection.dbo.WorkItemsEverable left join Tfs_DefaultCollection.dbo.WorkItemLongTexts on [System.Id] = [ID] and [System.Rev] = [Rev] where [id]=32862 and FldID=54 order by rev
all is done ...
congratulation for myself.
TFS C#开发不动人员 这个职业不广泛
- 已标记为答案 Allen WOE 2016年6月21日 6:30
全部回复
-
你好,
你可以参考这个链接:http://geekswithblogs.net/TarunArora/archive/2011/08/21/tfs-sdk-work-item-history-visualizer-using-tfs-api.aspx 。但是TFS API 好像不支持java 语言。
public WorkItem GetWorkItemDetails(int id) { var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection( new Uri("https://tfs2010:8080/defaultcollection")); var service = tfs.GetService<WorkItemStore>(); return service.GetWorkItem(id); } // Returns a work item object var wi = GetWorkItemDetails(299); // This will NOT give you work item history // will only loop through revisions and // actually not load the work item history // but will load the latest work item revision // again and again foreach (Revision revision in wi.Revisions) { Debug.Write(revision.WorkItem); }
或者你可以使用TFS REST API: https://www.visualstudio.com/en-us/docs/integrate/api/wit/revisions#get-a-work-item-revision
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
-
make it !!!
use sql like blow
select [System.Id],[system.ChangedBy],[system.Rev],[words] from Tfs_DefaultCollection.dbo.WorkItemsEverable left join Tfs_DefaultCollection.dbo.WorkItemLongTexts on [System.Id] = [ID] and [System.Rev] = [Rev] where [id]=32862 and FldID=54 order by rev
all is done ...
congratulation for myself.
TFS C#开发不动人员 这个职业不广泛
- 已标记为答案 Allen WOE 2016年6月21日 6:30