Exemplo n.º 1
0
        private void GetDataFromTfs(int?lastId, int itemSize, bool isFullCall = false)
        {
            IEnumerable <TFSCore.IHistoryItem> historyItems;

            Debug.WriteLine($"Getting HistoryItems from TFS {lastId} {itemSize}");
            historyItems = Tfs.GetHistory(TeamProject.ServerItem, lastId, itemSize);

            IList <TFSCore.IHistoryItem> modifiedHistoryItems = new List <IHistoryItem>();

            foreach (HistoryItem historyItem in historyItems)
            {
                if (CancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }


                modifiedHistoryItems.Add(HistoryItems.AddOrUpdateWithoutNotification(historyItem, (item, item1) => item.ChangeSetId == item1.ChangeSetId, (items, index, newItem) =>
                {
                    // make sure we keep our "ExtendedProperties"
                    IHistoryItem.CopyTo(items[index], newItem);
                }));
            }
            HistoryItems.NotifyReset();

            Debug.WriteLine($"Got {historyItems.Count()} HistoryItems from TFS");

            SaveDataToCache(true, false);

            Debug.WriteLine($"Resolving Workitems for {historyItems.Count()}");
            foreach (HistoryItem historyItem in modifiedHistoryItems)
            {
                if (CancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }
                foreach (WorkItem workItem in historyItem.WorkItems)
                {
                    if (CancellationTokenSource.IsCancellationRequested)
                    {
                        return;
                    }
                    Debug.WriteLine($"Resolved Workitems for {historyItem.ChangeSetId}");
                    workItem.UpdateIndexedWords(true);
                    WorkItems.AddOrUpdate(workItem, (item, item1) => item.Id == item1.Id, (items, index, newItem) => items[index] = newItem);
                }
                // Updating Cache
                historyItem.UpdateIndexedWords(true);
            }

            SaveDataToCache(true, true);
            if (!isFullCall)
            {
                GetDataFromTfs(null, Int32.MaxValue, true);
            }
        }