如何从 TFS 获取 Whats New 字段值 [英] How to get Whats New field value from TFS

查看:20
本文介绍了如何从 TFS 获取 Whats New 字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过 c# 在 TFS 上找到 Whats New 字段.我可以获取 WorkItem,但新字段在哪里?

I cannot find Whats New field on TFS via c# . I can get WorkItem, but where Whats New field?

如何获得工作项:

 public WorkItemCollection GetAllWorkItemsFromCollection(String collectionName, String date)
    {
        String collNameTemp = String.Empty;
        try
        {

            var collNodes = this.GetAllCollectionsRaw();
            foreach (var c in collNodes)
            {

                TmpCl cl = new TmpCl(c, _InstanceId, _configurationServer);

                var wis = cl.teamProjectCollection.GetService<WorkItemStore>();

                foreach (var p in cl.projCollectionInfo)
                {

                    if (p.Name == collectionName)
                    {

 string newnewquery= @"SELECT [System.Id], [Microsoft.VSTS.Common.ClosedDate],  [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State] 

            FROM WorkItems 

            WHERE [System.TeamProject] = '" + p.Name + "' AND " +

       "   [System.WorkItemType] = 'Task' AND [System.ChangedDate] > '" + date + "' " +

        "    ORDER BY [System.Id]";


                        collNameTemp = p.Name;


                        Query qry1 = new Query(wis,newnewquery, null, false);
                        ICancelableAsyncResult car1 = qry1.BeginQuery();

                        WorkItemCollection items1 = qry1.EndQuery(car1);


                        return items1;

                    }
                    else { }
                }


            }

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

        return null;       

public TmpCl(CatalogNode c,String InstanceId,TfsConfigurationServer configurationServer)
  {
      try
      {
          Guid collectionId = new Guid(c.Resource.Properties[InstanceId]);
          teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);

          Iis = (ICommonStructureService)teamProjectCollection.GetService(typeof(ICommonStructureService));
          projCollectionInfo = Iis.ListAllProjects();


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

所以,我可以得到已完成的工作,例如:

So, i can get Completed Work, for example:

    public String GetCompletedWorkByTaskWI(String collectionName, WorkItem taskWI)
    {
        try
        {
            foreach (Field f in taskWI.Fields)
            {
                if (f.Value != null && f.Name.Equals("Completed Work"))
                {

                    return Convert.ToString(f.Value);

                }
                else if (f.Value == null && f.Name.Equals("Completed Work"))
                {
                    return "0";
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        return "0";
    }

但是如何获得 Whats New 字段?我找不到!

But how to get Whats New field? I cannot find it!

抱歉,这是另一个 SQL 查询.此查询用于获取 WorkItem 对象.

Sorry, it was another SQL query. This query uses for get WorkItem objects.

PS - 字段:

DesiredCompliteDate
Area Name
Finish Date
Start Date
Completed Work
Original Estimate
Remaining Work
Activity
Integration Build
Stack Rank
Priority
Closed By
Closed Date
Activated By
Activated Date
State Change Date
Related Link Count
History
Description
Created By
Created Date
Work Item Type
Assigned To
Reason
Changed By
Rev
State
Title
Authorized As
Area ID
ID
Changed Date
Revised Date
Area Path
Node Name
Attached File Count
Hyperlink Count
Team Project
External Link Count
Iteration ID
Iteration Path

这是对包含新值的获取任务的查询(tfs 查询生成器):

This is query for get tasks wich contains Whats New value (tfs query generator):

SELECT [System.Id], [System.WorkItemType], [System.Title], 
       [System.AssignedTo],  [System.State]
    FROM WorkItems WHERE [System.TeamProject] = @project  
                     AND  [System.WorkItemType] &lt;&gt; ''  
                     AND  [System.State] &lt;&gt; ''  
                     AND  [WW.WhatsNew] CONTAINS '/' 
    ORDER BY [System.Id]

推荐答案

我发现了这个字段.

答案是 - 从 WorkItem 获取修订,获取修订,然后继续:

The ansqwer is- Get Revisions from WorkItem,get Revision, and go:

if ((f.Name.Equals(Consts.WHATS_NEW) && f.Value != null))
                    this.WhatsNew = (String)f.Value;

这篇关于如何从 TFS 获取 Whats New 字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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