TFS二次开发系列:七、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)
在TFS二次开发中,我们可能会根据某一些情况对各个项目的PBI、BUG等工作项进行统计。在本文中将大略讲解如果进行这些数据统计。
一:连接TFS服务器,并且得到之后需要使用到的类方法。
/// <summary>
/// tfs的
/// </summary>
private TfsTeamProjectCollection server;
private WorkItemStore workstore;
private TeamSettingsConfigurationService configSvc;
private TfsTeamService teamService;
public String TfsUri { get; set; } /// <summary>
/// 初始化TFSServer
/// </summary>
/// <param name="model"></param>
public TFSServerDto(string tfsUri)
{
this.TfsUri = tfsUri;
Uri uri = new Uri(TfsUri);
server = new TfsTeamProjectCollection(uri);
workstore = (WorkItemStore)server.GetService(typeof(WorkItemStore));
configSvc = server.GetService<TeamSettingsConfigurationService>();
teamService = server.GetService<TfsTeamService>(); }
二:获取到本TFS Server 指定团队的所有项目
/// <summary>
/// 获取项目集合
/// </summary>
/// <returns></returns>
public ProjectCollection GetProjectList()
{
return workstore.Projects;
}
public Project GetProject(int projectId)
{
return workstore.Projects.GetById(projectId);
}
三:根据工作项类型获取工作项集合
/// <summary>
/// 获取工作项统计
/// </summary>
/// <param name="workitemtype">工作项类型:Bug,Impediment,Product Backlog Item,Task,Task Case</param>
/// <returns></returns>
public WorkItemCollection GetWorkItemCollection(string workitemtype, string projectName)
{
WorkItemCollection queryResults = GetWorkItemCollection(workitemtype,projectName, string.Empty);
return queryResults;
} /// <summary>
/// 获取工作项统计
/// </summary>
/// <param name="workitemtype">工作项类型:Bug,Impediment,Product Backlog Item,Task,Task Case等</param>
/// <param name="condition">查询条件:针对Bug类型的 State=‘New,Approved,Committed,Done,Removed'
/// 针对Impediment类型的State='Open'
/// 针对Product Backlog Item类型的State='New'
/// 针对Task类型的 State='To Do'
/// 针对Task Case类型的 State='Design'
/// <returns></returns>
public WorkItemCollection GetWorkItemCollection(string workitemtype,string projectName,string condition)
{
string sql = @"Select [Title] From WorkItems Where [Work Item Type] = '{0}' and [System.TeamProject] = '{1}' ";
if (!string.IsNullOrEmpty(condition))
{
sql +=" and "+ condition;
}
sql = string.Format(sql, workitemtype, projectName);
WorkItemCollection queryResults = workstore.Query(sql);
return queryResults;
}
四:获取Sprint信息和开始、结束时间
/// <summary>
/// 获取项目的Sprint信息
/// </summary>
/// <param name="projectUri">project的Uri信息</param>
/// <returns></returns>
public TeamSettings GetSprintInfo(String projectUri)
{
TeamFoundationTeam team = teamService.QueryTeams(projectUri).First();
IList<Guid> teamGuids = new List<Guid>() { team.Identity.TeamFoundationId };
TeamConfiguration config = configSvc.GetTeamConfigurations(teamGuids).FirstOrDefault();
var members = team.GetMembers(server, MembershipQuery.Direct);
var users = members.Where(m => !m.IsContainer); return config.TeamSettings;
}
/// <summary>
/// 获取项目Sprint的关键信息如开始时间和结束时间
/// </summary>
/// <param name="projectUri"></param>
/// <returns></returns>
public IEnumerable<ScheduleInfo> GetIterationDates(string projectUri)
{
var css = server.GetService<ICommonStructureService4>();
NodeInfo[] structures = css.ListStructures(projectUri);
NodeInfo iterations = structures.FirstOrDefault(n => n.StructureType.Equals("ProjectLifecycle"));
List<ScheduleInfo> schedule = null;
if (iterations != null) {
string projectName = css.GetProject(projectUri).Name;
XmlElement iterationsTree = css.GetNodesXml(new[] { iterations.Uri }, true);
GetIterationDates(iterationsTree.ChildNodes[], projectName, ref schedule);
}
return schedule;
}
/// <summary>
/// 通过解析XML得到Sprint的开始和结束时间
/// </summary>
/// <param name="node"></param>
/// <param name="projectName"></param>
/// <param name="schedule"></param>
private void GetIterationDates(XmlNode node, string projectName, ref List<ScheduleInfo> schedule)
{ if (schedule == null)
schedule = new List<ScheduleInfo>();
if (node != null)
{
string iterationPath = node.Attributes["Path"].Value;
if (!string.IsNullOrEmpty(iterationPath))
{
// Attempt to read the start and end dates if they exist.
string strStartDate = (node.Attributes["StartDate"] != null) ? node.Attributes["StartDate"].Value : null;
string strEndDate = (node.Attributes["FinishDate"] != null) ? node.Attributes["FinishDate"].Value : null;
DateTime? startDate = null, endDate = null;
if (!string.IsNullOrEmpty(strStartDate) && !string.IsNullOrEmpty(strEndDate))
{
bool datesValid = true;
// Both dates should be valid.
startDate = DateTime.Parse(strStartDate);
endDate = DateTime.Parse(strEndDate);
schedule.Add(new ScheduleInfo
{
Path = iterationPath.Replace(string.Concat("\\", projectName, "\\Iteration"), projectName),
StartDate = startDate,
EndDate = endDate
});
}
}
// Visit any child nodes (sub-iterations).
if (node.FirstChild != null)
{
// The first child node is the <Children> tag, which we'll skip.
for (int nChild = ; nChild < node.ChildNodes[].ChildNodes.Count; nChild++)
GetIterationDates(node.ChildNodes[].ChildNodes[nChild], projectName, ref schedule);
}
}
}
五:获取团队成员名单
/// <summary>
/// 获取项目的Sprint信息
/// </summary>
/// <param name="projectUri">project的Uri信息</param>
/// <returns></returns>
public IEnumerable<TeamFoundationIdentity> GetMemberInfo(String projectUri)
{
TeamFoundationTeam team = teamService.QueryTeams(projectUri).First();
var members = team.GetMembers(server, MembershipQuery.Direct);
var users = members.Where(m => !m.IsContainer);
return users;
}
TFS二次开发系列:七、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)的更多相关文章
- TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)
TFS二次开发的数据统计以PBI.Bug.Sprint等为例(一) 在TFS二次开发中,我们可能会根据某一些情况对各个项目的PBI.BUG等工作项进行统计.在本文中将大略讲解如果进行这些数据统计. 一 ...
- 微信程序开发系列教程(二)使用JavaScript给微信用户发送消息
我之前的文章 微信程序开发系列教程(一)开发环境搭建 介绍了微信开发环境的搭建,这篇文章我们就来一步步开发一些具体的功能. 功能需求:当有微信用户关注了您的公众号之后,您用JavaScript发送一个 ...
- 微信小程序开发系列七:微信小程序的页面跳转
微信小程序开发系列教程 微信小程序开发系列一:微信小程序的申请和开发环境的搭建 微信小程序开发系列二:微信小程序的视图设计 微信小程序开发系列三:微信小程序的调试方法 微信小程序开发系列四:微信小程序 ...
- 《C#微信开发系列(Top)-微信开发完整学习路线》
年前就答应要将微信开发的学习路线整理给到大家,但是因为年后回来这段时间学校还有公司那边有很多事情需要兼顾,所以没能及时更新文章.今天特地花时间整理了下,话不多说,上图,希望对大家的学习有所帮助哈. 如 ...
- TFS二次开发系列:八、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(二)
上一篇文章我们编写了此例的DTO层,本文将数据访问层封装为逻辑层,提供给界面使用. 1.获取TFS Dto实例,并且可以获取项目集合,以及单独获取某个项目实体 public static TFSSer ...
- 【Qt程序】基于Qt词典开发系列<十二>呼叫讲述
我们知道,win7系统自带有讲述人,即能够机器读出当前内容,详细能够将电脑锁定.然后点击左下角的button就可以.之前在用Matlab写扫雷游戏的时候,也以前调用过讲述人来进行游戏的语音提示. 详细 ...
- 循序渐进学.Net Core Web Api开发系列【1】:开发环境
系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.本篇概述 本篇不 ...
- Solon 开发,七、自定义注解开发汇总
Solon 开发 一.注入或手动获取配置 二.注入或手动获取Bean 三.构建一个Bean的三种方式 四.Bean 扫描的三种方式 五.切面与环绕拦截 六.提取Bean的函数进行定制开发 七.自定义注 ...
- C#.NET微信公众账号接口开发系列文章整理--微信接口开发目录,方便需要的博友查询
前言: 涉及微信接口开发比较早也做的挺多的,有时间的时候整理了开发过程中一些思路案例,供刚学习微信开发的朋友参考.其实微信接口开发还是比较简单的,但是由于调试比较麻烦,加上微信偶尔也会给开发者挖坑,并 ...
随机推荐
- LoadRunner连接Genymotion
- 新上市Lighthouse专用芯片TS3633规格介绍
背景介绍 Valve 有远大的愿景.它决心要把 SteamVR 追踪系统推向世界,从虚拟现实里的空间定位,到机器人领域,Valve 想为各种环境下的跟踪应用提供支持. 上个月,Valve 方面宣布会把 ...
- CSS/HTML 改变鼠标指针形状
改变鼠标指针形状的方法有两种:第一种:用的来改变鼠标指针形状.另一种是:利用第三方控件的方法,而我自己最常用的是第一种:用css样式表来改变鼠标指针形状 我们先来看第一种:用来改变鼠标指针形状. 有些 ...
- 判断访问的是移动端还是PC端,如果是移动端跳转页面
<script type="text/javascript"> var mobileAgent = new Array("iphone", &quo ...
- Java 线程的转换及状态
线程的状态转换是线程控制的基础. 线程状态总的可分为五大状态:分别是生.死.可运行.运行.等待/阻塞.用一个图来描述如下: 1.新建状态(New):新创建了一个线程对象. 2.就绪状态(Runnabl ...
- sublimeText jsformat 插件被当做病毒 virus
最近在个只可往他里面发邮件,不能往外上任何互联网的地方工作,用 sublimetext 要装个sublime 插件 jsformat 十分麻烦.用gmail邮箱发总是报病毒. 最后挨个尝试,发现是 j ...
- ORACLE设置id自增长
1.创建序列create sequence sequence_userinfo start with 1 increment by 1 minvalue 1 maxvalue 999999 nocyc ...
- JS的window.onload与JQuery的$(document).ready(function(){})的区别
前段时间去面试被问及JS的加载(onload)与jQuery中加载(ready)方法的区别,瞬时懵逼了,关于这个知识点平时还真没怎么注意. 最近先来无事便查了一下资料, onload 事件(W3c上给 ...
- ResultSet用法集锦
ResultSet用法集锦 结果集(ResultSet)是数据中查询结果返回的一种对象,可以说结果集是一个存储查询结果的对象,但是结果集并不仅仅具有存储的功能,他同时还具有操纵数据的功能,可能完成对数 ...
- 【金】nginx+uwsgi+django+python 应用架构部署
网上有很多这种配置,但就是没一个靠普的,费了好大的力气才完成架构部署.顺便记录一下. 一.部署前的说明 先安装好 python,django,uwsgi,nginx软件后.后配置运行的软件是分先后的. ...