Exemple #1
0
        void activeConflictsBW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                ConflictChanges conflictChanges = (ConflictChanges)e.Result;

                foreach (RTConflict conflict in conflictChanges.NewConflicts)
                {
                    m_allActiveConflicts.Add(new ConflictRuleViewModel(conflict, this));
                }

                foreach (int resolvedConflictId in conflictChanges.ResolvedConflictIds)
                {
                    IEnumerable <ConflictRuleViewModel> conflictModelsToRemove = m_allActiveConflicts.Where(x => x.ConflictInternalId == resolvedConflictId);
                    // Create a separate list of items to remove because you can't remove while enumerating over m_allActiveConflicts
                    List <ConflictRuleViewModel> conflictModelsToRemoveList = new List <ConflictRuleViewModel>();
                    foreach (ConflictRuleViewModel conflictModelToRemove in conflictModelsToRemove)
                    {
                        conflictModelsToRemoveList.Add(conflictModelToRemove);
                    }
                    foreach (ConflictRuleViewModel conflictModelToRemove in conflictModelsToRemoveList)
                    {
                        m_allActiveConflicts.Remove(conflictModelToRemove);
                    }
                }
            }

            RefreshFilteredConflicts();
            if (ShellViewModel != null)
            {
                ShellViewModel.NotificationBarViewModel.RefreshDefaultNotification();
            }
            IsActiveConflictsBWBusy = false;
        }
Exemple #2
0
        void activeConflictsBW_DoWork(object sender, DoWorkEventArgs e)
        {
            IsActiveConflictsBWBusy = true;
            ConflictChanges conflictChanges = GetConflictChanges();

            e.Result = conflictChanges;
        }
Exemple #3
0
        private ConflictChanges GetConflictChanges()
        {
            int lastConflictId;

            if (m_allActiveConflicts == null || m_allActiveConflicts.Count == 0)
            {
                lastConflictId = 0;
            }
            else
            {
                lastConflictId = m_allActiveConflicts.Select(x => x.ConflictInternalId).Max();
            }

            // Build a Hashset with all of the existing conflict Ids
            HashSet <int> currentConflictIdsResolved = new HashSet <int>();

            foreach (ConflictRuleViewModel conflictView in m_allActiveConflicts)
            {
                if (!currentConflictIdsResolved.Contains(conflictView.ConflictInternalId))
                {
                    currentConflictIdsResolved.Add(conflictView.ConflictInternalId);
                }
            }

            ConflictChanges conflictChanges = new ConflictChanges();

            foreach (RTConflict conflict in GetActiveConflicts(SessionGroupUniqueId))
            {
                if (conflict.Id > lastConflictId)
                {
                    conflictChanges.NewConflicts.Add(conflict);
                }
                else
                {
                    if (currentConflictIdsResolved.Contains(conflict.Id))
                    {
                        // The conflict was returned by GetActiveConflicts and was already in memory, so remove it from the Resolved list
                        currentConflictIdsResolved.Remove(conflict.Id);
                    }
                }
            }

            // Anything remaining in currentConflictIdsResolved must have been resolved because it was not returned by GetActiveConflicts
            foreach (int conflictId in currentConflictIdsResolved)
            {
                conflictChanges.ResolvedConflictIds.Add(conflictId);
            }

            return(conflictChanges);
        }