获取workItemStore TFS 2013时出错 [英] Error while getting workItemStore TFS 2013

查看:88
本文介绍了获取workItemStore TFS 2013时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试获取工作项存储区时,我在以下代码中出现以下错误
.我到处搜索,但找不到任何解决方案,请帮助:(

I am having the following error in following code while trying to get workitem store
. I searched everywhere but i couldn''t find any solution please help :(

TF31002: Unable to connect to this Team Foundation Server: http://hostname:8080/tfs/tpCollectionName/tpname
Team Foundation Server Url: http://hostname:8080/tfs/tpCollectionName/tpname.




使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Threading.Tasks;
使用Microsoft.TeamFoundation;
使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.Common;
使用Microsoft.TeamFoundation.WorkItemTracking.Client;

命名空间ModifyWorkItems
{
公共静态类CWorkItems
{
公共静态无效RemoveAllWorkItems()
{
列表< workitem> workItems = new List< workitem>();
试试
{
TfsTeamProjectCollection tfs =新的TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://主机名:8080/tfs/tpCollectionName/tpname/"));

//WorkItemStore store = tfs.GetService< workitemstore>();
//TeamFoundationServer tfs =新的TeamFoundationServer("http://主机名:8080/tfs/tpCollectionName/tpname/");

//WorkItemStore m_store =(WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItemStore store = new WorkItemStore(tfs);


字符串wiql =从工作项中选择ID([工作项类型] =任务"或[工作项类型] =用户故事"或[工作项类型] =错误")和[状态]<>``关闭''AND [AreaPath]<>''/Entegrasyon'';
WorkItemCollection wicr = store.Query(wiql);

foreach(wicr中的WorkItem wi)
{
wi.Open();
wi.Fields ["State"].Value =已移除";
wi.Save();
wi.Close();
}

}
catch(ex ex例外)
{
Console.WriteLine(ex.Message);

}


}
}
}




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Common;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace ModifyWorkItems
{
public static class CWorkItems
{
public static void RemoveAllWorkItems()
{
List<workitem> workItems = new List<workitem>();
try
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://hostname:8080/tfs/tpCollectionName/tpname/"));

// WorkItemStore store = tfs.GetService<workitemstore>();
// TeamFoundationServer tfs = new TeamFoundationServer("http://hostname:8080/tfs/tpCollectionName/tpname/");

// WorkItemStore m_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItemStore store = new WorkItemStore(tfs);


string wiql = "SELECT ID FROM WorkItems WHERE ([Work Item Type]=''Task'' OR [Work Item Type]=''User Story'' OR [Work Item Type]=''Bug'') AND [State] <>''Closed'' AND [AreaPath] <> ''/Entegrasyon'' ";
WorkItemCollection wicr = store.Query(wiql);

foreach (WorkItem wi in wicr)
{
wi.Open();
wi.Fields["State"].Value = "Removed";
wi.Save();
wi.Close();
}

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);

}


}
}
}

推荐答案

尝试一下:

Try this:

TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(yourTFSUri);
WorkItemStore workitemstore = tpc.GetService<WorkItemStore >();


我更改了

TfsTeamProjectCollection tfs =新的TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://主机名:8080/tfs/tpCollectionName/tpname/"));

排成
TfsTeamProjectCollection tfs =新的TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://主机名:8080/tfs/tpCollectionName/")));

这条线,我的问题就解决了

我不得不使用TPC Uri而不是TP Uri
I changed

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://hostname:8080/tfs/tpCollectionName/tpname/"));

line into
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("http://hostname:8080/tfs/tpCollectionName/"));

this line and my problem was solved

I had to use TPC Uri instead of TP Uri


这篇关于获取workItemStore TFS 2013时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆