private void PopulatePendingChangedBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            this.Logger().Trace("Begin Refresh Pending Changes");

            PendingChange[] currentPendingChanges;

            var filterItems = SolutionIsOpen && FilterSolution;

            string[] solutionFilePaths = null;

            if (filterItems)
            {
                try
                {
                    solutionFilePaths = teamPilgrimVsService.GetSolutionFilePaths();
                }
                catch (Exception)
                {
                    filterItems = false;
                }
            }

            if (filterItems
                    ? teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, Workspace,
                                                                           solutionFilePaths)
                    : teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, Workspace))
            {
                var intersections = PendingChanges
                                    .Join(currentPendingChanges, model => model.Change.ItemId, change => change.ItemId,
                                          (model, change) => new { model, change })
                                    .ToArray();

                var intersectedModels =
                    intersections
                    .Select(arg => arg.model)
                    .ToArray();

                var modelsToRemove = PendingChanges.Where(model => !intersectedModels.Contains(model)).ToArray();

                var modelsToAdd = currentPendingChanges
                                  .Where(
                    pendingChange =>
                    !intersectedModels.Select(model => model.Change.ItemId).Contains(pendingChange.ItemId))
                                  .Select(change => new PendingChangeModel(change)
                {
                    IncludeChange = true
                }).ToArray();

                Application.Current.Dispatcher.Invoke(() =>
                {
                    _backgroundFunctionPreventDataUpdate = true;

                    foreach (var intersection in intersections)
                    {
                        intersection.model.Change = intersection.change;
                    }

                    foreach (var pendingChangeModel in modelsToAdd)
                    {
                        PendingChanges.Add(pendingChangeModel);
                    }

                    foreach (var modelToRemove in modelsToRemove)
                    {
                        PendingChanges.Remove(modelToRemove);
                    }

                    _backgroundFunctionPreventDataUpdate = false;

                    PendingChangesOnCollectionChanged();
                }, DispatcherPriority.Normal);
            }

            this.Logger().Trace("End Refresh Pending Changes");
        }
Esempio n. 2
0
        private void RefreshPendingChanges()
        {
            this.Logger().Trace("RefreshPendingChanges");

            PendingChange[] currentPendingChanges;

            var filterItems = SolutionIsOpen && FilterSolution;

            string[] solutionFilePaths = null;

            if (filterItems)
            {
                try
                {
                    solutionFilePaths = teamPilgrimVsService.GetSolutionFilePaths();
                }
                catch (Exception)
                {
                    filterItems = false;
                }
            }

            if (filterItems
                ? teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, _workspaceServiceModel.Workspace, solutionFilePaths)
                : teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, _workspaceServiceModel.Workspace))
            {
                var intersections = PendingChanges
                                    .Join(currentPendingChanges, model => model.Change.ItemId, change => change.ItemId, (model, change) => new { model, change })
                                    .ToArray();

                var intersectedModels =
                    intersections
                    .Select(arg => arg.model)
                    .ToArray();

                var modelsToRemove = PendingChanges.Where(model => !intersectedModels.Contains(model)).ToArray();

                var modelsToAdd = currentPendingChanges
                                  .Where(pendingChange => !intersectedModels.Select(model => model.Change.ItemId).Contains(pendingChange.ItemId))
                                  .Select(change => new PendingChangeModel(change)).ToArray();

                _backgroundFunctionPreventDataUpdate = true;

                foreach (var intersection in intersections)
                {
                    intersection.model.Change = intersection.change;
                }

                foreach (var modelToAdd in modelsToAdd)
                {
                    PendingChanges.Add(modelToAdd);
                }

                foreach (var modelToRemove in modelsToRemove)
                {
                    PendingChanges.Remove(modelToRemove);
                }

                _backgroundFunctionPreventDataUpdate = false;

                PopulateSelectedPendingChangesSummary();
                EvaluateCheckInCommand.Execute(null);
            }
        }