首页 > 学院 > 开发设计 > 正文

IFS二次开发03——Item

2019-11-17 03:17:34
字体:
来源:转载
供稿:网友

IFS二次开发03——Item

Posted on 2014-03-15 17:12 祥叔 阅读(...) 评论(...) 编辑 收藏

在TFS 中把每个文件夹被抽象成“ItemSet”或“Item”,相对于父级目录来讲就是Item ,相对于子级目录来讲就是“ItemSet”。每个文件都被抽象成“Item”。

//连接TFSstring tpcURL = "http://192.168.83.62:8080";TfsTeamPRojectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL));VersionControlServer version = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer;//获取指定目录下的ItemString Path="$/"  ;         ItemSet its = version.GetItems("$/", RecursionType.OneLevel); //获取Path 下的所有Item, 包括Path 自己,并且是第一个。第一个参数支持通配符,如:ItemSet its = version.GetItems("$/*.xaml", RecursionType.OneLevel);//  RecursionType.OneLevel   递归向下读取一层//  RecursionType.Full       递归读取所有//  RecursionType.None       不递归//遍历Itemforeach (Item item in its.Items){  //item.ArtifactUri      在服务器上的绝对路径 如:http://192.168.82.63:88/########  //item.ItemType         枚举,表明是文件还是文件  //item.ServerItem       在服务器上的绝对路径  如:$/CtripSolution/CommDll  // item.IsBranch      是否是分支  //item.DownloadFile() 下载到本地  //......... }

结合上面的代码,我们可以做出下面的效果:

 //显示已经删除掉的Item string tpcURL = "http://192.168.83.62:8080"; TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL)); VersionControlServer version = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer; ItemSpec spec = new ItemSpec("$/CtripSolution/Customer/MAINLINE/ScrmApp/SinaWeiTravel", RecursionType.Full); var deletedItems = version.GetItems(spec, VersionSpec.Latest, DeletedState.Deleted, ItemType.Any, true);


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表