質問

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

How to get WorkItem:

 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";
    }

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

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

PS - Fields :

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

EDIT: 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]
役に立ちましたか?

解決 2

I found this field.

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;

他のヒント

I'd suggest to add the What's new field to the SELECT list:

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

Many of the other fields that are returned are TFS out-of-the-box fields, so I assume that some these are returned even if they are not explicitly contained in the SELECT list.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top