tfs服务器查询问题
最近在写查询tfs服务器的webservice,但是在查询changeset、shelveset和build的时候感觉速度很慢。
特别是changset,在tfs自身的网页版查询的时候,相同的查询条件,我用30秒,它自身的网页查询只要一瞬间。
求高手支持!
我的代码如下:
WorkItemStore workItemStore = workItemStoreProxy.GetWorkItemStoreByCollectionName(cred, tfsserver, collectionProId.CollectionName);
VersionControlServer verServer = (VersionControlServer)workItemStore.TeamProjectCollection.GetService(typeof(VersionControlServer));
Project project = workItemStore.Projects.GetById(collectionProId.TfsProjectId);
String rootFolder = "$/" + project.Name; //D11008K_SPM2.0研发项目
CommonHelper commonHelper = new CommonHelper();
var changesets = verServer.QueryHistory(rootFolder, new DateVersionSpec(date), 0, RecursionType.Full, null, null, null, int.MaxValue, true, true).Cast<Changeset>().ToList();
//根据人员过滤)
var tempC =
changesets.Where(
c => employeeNames.Contains(c.Owner == null ? "" : c.Owner.ToLower()));
//tempChangesets =
// tempC.Select(
// c =>
// new SpmChangeset(c)
// {
// ProjectName = project.Name,
// TaskNames =
// (c.WorkItems == null ? null : c.WorkItems.Select(w => w.Title).ToList()),
// Url = commonHelper.GetWebUrl(tfsserver, c.ChangesetId.ToString(), project.Uri.AbsolutePath, 0)
// }).ToList();
foreach (Changeset changeset in tempC)
{
SpmChangeset s = new SpmChangeset(changeset);
s.ProjectName = project.Name;
s.TaskNames = new List<string>();
s.TaskNames.AddRange((changeset.WorkItems.Select(w => w.Title)));
s.Url = commonHelper.GetWebUrl(tfsserver, changeset.ChangesetId.ToString(),
project.Uri.AbsolutePath, 0);
tempChangesets.Add(s);
}
if (tempChangesets.Count > 0)
{
result.AddRange(tempChangesets);
}
被注释掉的地方也是可用的,但是用linq写的感觉比foreach还慢。
求指导!求优化!
------解决方案--------------------
SpmChangeset s = null;
foreach (Changeset changeset in tempC)
{
s = new SpmChangeset(changeset);
s.ProjectName = project.Name;
s.TaskNames = new List<string>();
s.TaskNames.AddRange((changeset.WorkItems.Select(w => w.Title)));
s.Url = commonHelper.GetWebUrl(tfsserver, changeset.ChangesetId.ToString(),
project.Uri.AbsolutePath, 0);
tempChangesets.Add(s);
}
if (tempChangesets.Count > 0)
{
result.AddRange(tempChangesets);
}