예제 #1
0
        /// <summary>
        /// Enumerate the diff items found based on the query passed in as well as the filterString and version passed
        /// to InitializeForDiff.  The return type is IEnumerable<> so that adapter implementations do not need download and keep
        /// all of the IWITDiffItems in memory at once.
        /// </summary>
        /// <param name="queryCondition">A string that specifies a query used to select a subset of the work items defined by
        /// the set that the filter string identified.</param>
        /// <returns>An enumeration of IWITDiffItems each representing a work item to be compared by the WIT Diff operation</returns>
        public IEnumerable <IWITDiffItem> GetWITDiffItems(string queryCondition)
        {
            if (null == m_workItemPager)
            {
                StringBuilder conditionBuilder = new StringBuilder(m_filterString);

                if (!string.IsNullOrEmpty(queryCondition))
                {
                    if (conditionBuilder.Length > 0)
                    {
                        conditionBuilder.Append(" AND ");
                    }
                    conditionBuilder.Append(queryCondition);
                }

                m_workItemPager = new TfsWorkItemPager(m_projectName, m_workItemStore, conditionBuilder.ToString());
            }

            WorkItemCollection workItems;
            bool workItemFromProjectFound = false;

            do
            {
                workItems = m_workItemPager.GetNextPage();
                if (null == workItems)
                {
                    yield break;
                }
                else
                {
                    foreach (WorkItem workItem in workItems)
                    {
                        IWITDiffItem witDiffItem = null;
                        try
                        {
                            if (string.Equals(workItem.Project.Name, m_projectName, StringComparison.OrdinalIgnoreCase))
                            {
                                workItemFromProjectFound = true;
                                witDiffItem = (IWITDiffItem) new TfsWITDiffItem(this, workItem);
                            }
                        }
                        catch (DeniedOrNotExistException)
                        {
                            // Ignore this work item and continue
                        }
                        if (witDiffItem != null)
                        {
                            yield return(witDiffItem);
                        }
                    }
                }
            }
            // Continue with the next page if none of the work item in the current page are in the configured project
            while (workItems != null && !workItemFromProjectFound);
        }
예제 #2
0
 /// <summary>
 /// Give the IWITDiffProvider a chance to cleanup any reources allocated during InitializeForDiff()
 /// </summary>
 public void Cleanup()
 {
     m_filterString        = null;
     m_mappedWorkItemTypes = null;
     m_workItemPager       = null;
 }