上一篇文章我们编写了此例的DTO层,本文将数据访问层封装为逻辑层,提供给界面使用。

  1.获取TFS Dto实例,并且可以获取项目集合,以及单独获取某个项目实体

        public static TFSServerBll Instance = new TFSServerBll();
public TFSServerDto dto;
public TFSServerBll()
{
dto = new TFSServerDto("http://server:8080/tfs/Project/");
}
public TFSServerBll(string TfsUri)
{
dto = new TFSServerDto(TfsUri);
}
/// <summary>
/// 获取项目集合
/// </summary>
/// <returns></returns>
public ProjectCollection GetProjectList()
{
return dto.GetProjectList();
}
//根据projectId获取Project实体
public Project GetProject(int projectId)
{
return dto.GetProject(projectId);
}

  2.根据规则获取项目的PBI/Bug等信息

        /// <summary>
/// 获取项目的所有数据
/// </summary>
/// <param name="project"></param>
public void GetProjectInfo(Project project)
{
TfsSprint projectSprint = GetSprintInfo(project.Uri.ToString());
GetProjectSprintPBIandBUG(projectSprint, project);
} /// <summary>
/// 获取某项目所有Sprint的PBI和BUG
/// </summary>
/// <param name="projectSprint"></param>
/// <param name="project"></param>
public void GetProjectSprintPBIandBUG(TfsSprint projectSprint, Project project)
{
IEnumerable<ScheduleInfo> list = GetFinalBugInfo(project); foreach (Sprint sprint in projectSprint.SprintList)
{
sprint.PBIInfo = GetSimplePbi(project.Name, sprint.SprintPath);
if (list.Count() > )
{
foreach (ScheduleInfo info in list)
{
if (info.Path == sprint.SprintPath)
{
sprint.BugInfo = new TfsBug() { New = info.NewBug, Done = info.Closed, opening = info.OpenBug };
break;
}
}
}
else
{
sprint.BugInfo = new TfsBug() { New = , Done = , opening = };
}
}
string s = "";
} private TfsPBI GetSimplePbi(string projectName, string IterationSprint)
{
WorkItemCollection total = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[Iteration Path]='" + IterationSprint + "'");
WorkItemCollection doneCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Done' and [Iteration Path]='" + IterationSprint + "'");
double totaleffort = GetPBIEffort(total);
double doneeffort = GetPBIEffort(doneCollection);
double effortPercent = doneeffort / totaleffort;
TfsPBI pbiinfo = new TfsPBI()
{
Total = total.Count,
Done = doneCollection.Count,
EffoctPercent = effortPercent,
EffoctCurrent = (int)doneeffort,
EffoctTotal = (int)totaleffort
};
return pbiinfo;
} private TfsBug GetSimpleBug(string projectName, string IterationSprint)
{
WorkItemCollection total = dto.GetWorkItemCollection("Bug", projectName, "[Iteration Path]='" + IterationSprint + "'");
WorkItemCollection NewCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='New' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection doneCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Done' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection RemovedCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Removed' and [Iteration Path]='" + IterationSprint + "'");
TfsBug buginfo = new TfsBug()
{
Total = total.Count,
New = NewCollection.Count,
Done = doneCollection.Count,
Removed=RemovedCollection.Count
};
return buginfo;
}

  3.另外一些获取Bug/PBI信息的组成方式

        /// <summary>
/// 获得某项目的BUG数量信息
/// </summary>
/// <param name="projectName"></param>
/// <returns></returns>
public TfsBug GetBugInfo(string projectName, string IterationSprint)
{
WorkItemCollection bugCollection = dto.GetWorkItemCollection("Bug", projectName, "[Iteration Path]='" + IterationSprint + "'");
WorkItemCollection bugNewCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='New' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection bugApprovedCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Approved' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection bugCommittedCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Committed' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection bugDoneCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Done' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection bugRemovedCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Removed' and [Iteration Path]='" + IterationSprint + "'");
TfsBug buginfo = new TfsBug()
{
Total = bugCollection.Count,
New = bugNewCollection.Count,
Approved = bugApprovedCollection.Count,
Committed = bugCommittedCollection.Count,
Done = bugDoneCollection.Count,
Removed = bugRemovedCollection.Count
};
return buginfo;
} /// <summary>
/// 获取整个项目的PBI信息
/// </summary>
/// <param name="projectName"></param>
/// <returns></returns>
public ProjectView GetAllInfo(String projectName)
{
WorkItemCollection total = dto.GetWorkItemCollection("Product Backlog Item", projectName, string.Empty);
WorkItemCollection doneCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Done'");
WorkItemCollection RemovedCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Removed'");
double totaleffort = GetPBIEffort(total);
double doneeffort = GetPBIEffort(doneCollection);
double removedeffort = GetPBIEffort(RemovedCollection);
double effortPercent = ;
if(totaleffort!=)
effortPercent = doneeffort / totaleffort; WorkItemCollection RiskOpenCollection = dto.GetWorkItemCollection("Impediment", projectName, "[State]='Open'");
int riskopenCount = RiskOpenCollection.Count; WorkItemCollection totalBug = dto.GetWorkItemCollection("Bug", projectName, string.Empty);
WorkItemCollection doneCollectionBug = dto.GetWorkItemCollection("Bug", projectName, "[State]='Done'");
WorkItemCollection RemovedCollectionBug = dto.GetWorkItemCollection("Bug", projectName, "[State]='Removed'");
int openbugCount = totalBug.Count - doneCollectionBug.Count - RemovedCollectionBug.Count; ProjectView view = new ProjectView() { PbiPercent = effortPercent, OpenBugCount = openbugCount, OpenRiskCount = riskopenCount, TotalPbiEffort = totaleffort};
return view;
}
/// <summary>
/// 获得某项目的PBI数量信息
/// </summary>
/// <param name="projectName"></param>
/// <returns></returns>
public TfsPBI GetPBIInfo(string projectName, string IterationSprint)
{
WorkItemCollection total = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[Iteration Path]='" + IterationSprint + "'");
WorkItemCollection newcollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='New' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection approvedCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Approved' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection committedCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Committed' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection doneCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Done' and [Iteration Path]='" + IterationSprint + "'");
WorkItemCollection removedCollection = dto.GetWorkItemCollection("Product Backlog Item", projectName, "[State]='Removed' and [Iteration Path]='" + IterationSprint + "'"); double totaleffort = GetPBIEffort(total);
double doneeffort=GetPBIEffort(doneCollection);
double effortPercent = doneeffort / totaleffort;
TfsPBI pbiinfo = new TfsPBI()
{
Total = total.Count,
New = newcollection.Count,
Approved = approvedCollection.Count,
Committed = committedCollection.Count,
Done = doneCollection.Count,
Removed = removedCollection.Count,
EffoctPercent = effortPercent,
EffoctCurrent=(int)doneeffort,
EffoctTotal=(int)totaleffort
};
return pbiinfo;
}
public double GetPBIEffort(WorkItemCollection collection)
{
double totalEff=;
foreach (WorkItem item in collection)
{
object o=item.Fields.GetById().Value;
if (o != null)
totalEff += (double)o; }
return totalEff;
}

  4.获取Sprint,Risk等信息集合

        /// <summary>
/// 获得某项目的Risk数量信息
/// </summary>
/// <param name="projectName"></param>
/// <returns></returns>
public List<TfsRiskInfo> GetRiskInfo(string projectName)
{
WorkItemCollection RiskOpenCollection = dto.GetWorkItemCollection("Impediment", projectName, "[State]='Open'"); List<TfsRiskInfo> list = new List<TfsRiskInfo>();
foreach (WorkItem item in RiskOpenCollection)
{
list.Add(new TfsRiskInfo() { RiskInfo=item.Description, RiskStatus="Open",RiskId=item.Id.ToString()});
}
return list;
} /// <summary>
/// 获取Sprint信息
/// </summary>
/// <param name="projectUri"></param>
/// <returns></returns>
public TfsSprint GetSprintInfo(String projectUri)
{
TeamSettings setting= dto.GetSprintInfo(projectUri);
TfsSprint tfssprint = new TfsSprint();
tfssprint.CurrentIterationPath=setting.CurrentIterationPath;
tfssprint.SprintCount=setting.IterationPaths.Count(); IEnumerable<string> ea_items =
from name in setting.IterationPaths.ToList()
where name.Contains("Sprint")
select name;
List<Sprint> list = new List<Sprint>();
foreach (string path in ea_items)
{
string sprintnum = path.Substring(path.LastIndexOf("Sprint") + ).Trim();
string sprintname ="Sprint "+sprintnum;
if(!string.IsNullOrEmpty(sprintnum))
list.Add(new Sprint() { SprintName = sprintname, SprintNum = int.Parse(sprintnum), SprintPath = path });
}
list.Sort((x, y) => x.SprintNum - y.SprintNum);
tfssprint.SprintList = list;
return tfssprint;
}
public IEnumerable<ScheduleInfo> GetSprintDate(string projectUri)
{
return dto.GetIterationDates(projectUri);
}
/// <summary>
/// 获取团队成员信息
/// </summary>
/// <param name="projectUri"></param>
/// <returns></returns>
public List<TfsMember> GetMemberInfo(String projectUri)
{
var list=new List<TfsMember>();
var members=dto.GetMemberInfo(projectUri);
foreach (TeamFoundationIdentity member in members)
{
var m = new TfsMember() { UserName=member.DisplayName,UserSimpleName=member.UniqueName.Substring(member.UniqueName.IndexOf('\\')+)};
list.Add(m);
}
return list;
} public IEnumerable<ScheduleInfo> GetFinalBugInfo(Project project)
{
IEnumerable<ScheduleInfo> sprintlist = GetSprintDate(project.Uri.ToString());
int newbug = ;
int openbug = ;
int closed = ;
int Totalbug = ;
foreach (ScheduleInfo info in sprintlist)
{ TfsBug bug = GetSingleBug(project.Name, info.StartDate,info.EndDate);
info.NewBug = bug.New;
info.Closed = bug.Done;
Totalbug += bug.New;
openbug = Totalbug - info.Closed;
info.OpenBug = openbug;
}
return sprintlist;
} private TfsBug GetSingleBug(string projectName,DateTime? createdate,DateTime? enddate)
{
WorkItemCollection total = dto.GetWorkItemCollection("Bug", projectName, "[Created Date]>'" + createdate + "' and [Closed Date]<'"+enddate+"'");
WorkItemCollection NewCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='New' and [Created Date]>'" + createdate + "' and [Closed Date]<'" + enddate + "'");
WorkItemCollection doneCollection = dto.GetWorkItemCollection("Bug", projectName, "[State]='Done' and [Created Date]>'" + createdate + "' and [Closed Date]<'" + enddate + "'");
TfsBug buginfo = new TfsBug()
{
Total = total.Count,
New = NewCollection.Count,
Done = doneCollection.Count
};
return buginfo;
}

  5.通过以上代码的封装,我们可以得到知己展示于前台的TFS数据展示。

TFS二次开发系列:八、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(二)的更多相关文章

  1. TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)

    TFS二次开发的数据统计以PBI.Bug.Sprint等为例(一) 在TFS二次开发中,我们可能会根据某一些情况对各个项目的PBI.BUG等工作项进行统计.在本文中将大略讲解如果进行这些数据统计. 一 ...

  2. 《C#微信开发系列(Top)-微信开发完整学习路线》

    年前就答应要将微信开发的学习路线整理给到大家,但是因为年后回来这段时间学校还有公司那边有很多事情需要兼顾,所以没能及时更新文章.今天特地花时间整理了下,话不多说,上图,希望对大家的学习有所帮助哈. 如 ...

  3. TFS二次开发系列:七、TFS二次开发的数据统计以PBI、Bug、Sprint等为例(一)

    在TFS二次开发中,我们可能会根据某一些情况对各个项目的PBI.BUG等工作项进行统计.在本文中将大略讲解如果进行这些数据统计. 一:连接TFS服务器,并且得到之后需要使用到的类方法. /// < ...

  4. 循序渐进学.Net Core Web Api开发系列【1】:开发环境

    系列目录 循序渐进学.Net Core Web Api开发系列目录 本系列涉及到的源码下载地址:https://github.com/seabluescn/Blog_WebApi 一.本篇概述 本篇不 ...

  5. C#.NET微信公众账号接口开发系列文章整理--微信接口开发目录,方便需要的博友查询

    前言: 涉及微信接口开发比较早也做的挺多的,有时间的时候整理了开发过程中一些思路案例,供刚学习微信开发的朋友参考.其实微信接口开发还是比较简单的,但是由于调试比较麻烦,加上微信偶尔也会给开发者挖坑,并 ...

  6. 8天掌握EF的Code First开发系列之2 Code First开发系列之领域建模和管理实体关系

    本文出自8天掌握EF的Code First开发系列,经过自己的实践整理出来. 本篇目录 理解Code First及其约定和配置 创建数据表结构 管理实体关系 三种继承模式 本章小结 本人的实验环境是V ...

  7. BizTalk开发系列(八) BizTalk Server 常识整理

    1.什么是BizTalk Server?     BizTalk 是业务流程管理服务器,用于连接人员,流程,有效管理和提升业务所需的信息.在原有版本业务 流程管理和SOA/ESB 的基础上,第5 个版 ...

  8. arcgis api for js入门开发系列八聚合效果(含源代码)

    上一篇实现了demo的图层控制模块,本篇新增聚合效果,截图如下(源代码见文章底部): 聚合效果实现的思路如下: 1.map.html引用聚合包,项目已经包含进来了的聚合文件夹: <script ...

  9. arcgis api 3.x for js 入门开发系列八聚合效果(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...

随机推荐

  1. css旋转

    翻转180度 /* entire container, keeps perspective */ .flip-container { perspective: 1000; } /* flip the ...

  2. (转)HTTP 长连接和短连接

    1. HTTP协议与TCP/IP协议的关系 HTTP的长连接和短连接本质上是TCP长连接和短连接.HTTP属于应用层协议,在传输层使用TCP协议,在网络层使用IP协议.IP协议主要解决网络路由和寻址问 ...

  3. post- build event

    Ref:http://blog.csdn.net/teng_ontheway/article/details/8307410 Ref: http://blog.csdn.net/sodickbird/ ...

  4. No Spring WebApplicationInitializer types detected on classpath。启动时不报错,但是页面打不开。

    一片红,没有黑色disPatcher的加载. 百度,但是没有用,二十分钟浪费,这个问题的本质就是web.xml中的disPatcher没有加载,但是我肯定和代码无关,配置文件也没有变化过,值可能是to ...

  5. 记得初学JS时候练个九九乘法表都写的要死要活

    还记得当初刚接触JS时候,看到视频中老师写了个九九乘法表,觉得好神奇,可是自己在下面动手写了半天还是有各种问题,甚是懊恼啊.今又看到园子里有关于乘法表的博文,出于对过去的不舍与缅怀,遂重写一遍. &l ...

  6. [原创]java WEB学习笔记109:Spring学习---spring中事物管理

    博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱好 ...

  7. ZOJ-1239 Hanoi Tower Troubles Again!

    链接:ZOJ1239 Hanoi Tower Troubles Again! Description People stopped moving discs from peg to peg after ...

  8. 夺命雷公狗-----React---25--小案例之react经典案例todos(单选框的修改)

    还是老样子,首先给li里面的单选框一个函数,然后通过props来对她进行处理 然后在ul里面对父组建进行传送 补充一下啊第一步,因为到时候要用到index属性,所以我们需要发送多一个index过来 然 ...

  9. Hadoop:操作 Hadoop Cluster

    启动Hadoop 当完成所有的必要配置后,将HADOOP_CONF_DIR目录中的所有配置文件复制到所有机器,建议将HDFS和YARN后台进程一不同的用户身份运行,比如运行HDFS进程们的用户为hdf ...

  10. GPT WIN 换硬盘 硬盘克隆或复制 无法确定的问题,硬盘大小不一致换系统。

    当你购买了一个新硬盘,希望换掉旧硬盘的时候.发现 GPT + EFI 要求硬盘上的前两个分区必须和旧的一样,否则就无法启动. 这就是你用 分区大师(PartAssist)硬盘克隆完了,也无法启动的原因 ...