Пример #1
0
        public IEnumerable <ConflictResolutionResult> SaveToDB()
        {
            if (CanSave)
            {
                // create new rule
                ConflictResolutionRule newRule = SelectedResolutionAction.NewRule(Scope, Description, DataFields.ToDictionary(x => x.FieldName, x => x.FieldValue));

                // save new rule
                int newRuleId = m_conflictManager.SaveNewResolutionRule(ConflictType, newRule);
                newRule.InternalId = newRuleId;
                try
                {
                    // try to resolve existing conflicts
                    IEnumerable <ConflictResolutionResult> results = m_conflictManager.ResolveExistingConflictWithExistingRule(newRule);

                    // remove old rule from db
                    RemoveFromDB();

                    // get new rule from db
                    RuntimeEntityModel context = RuntimeEntityModel.CreateInstance();
                    var v = from r in context.RTResolutionRuleSet
                            where r.Id == newRuleId
                            select r;
                    m_rule = v.First();

                    SetDataFields();
                    OnPropertyChanged("CreationTime");
                    OnPropertyChanged("ResolutionAction");
                    OnPropertyChanged("Scope");
                    OnPropertyChanged("CanSave");

                    m_appViewModel.SetResolvedConflicts(results, newRule.InternalId);

                    return(results);
                }
                catch (ConflictManagementGeneralException)
                {
                    throw new Exception("Could not save rule.");
                }
            }
            else
            {
                throw new Exception("Invalid scope");
            }
        }
Пример #2
0
        public IEnumerable <ConflictResolutionResult> Save()
        {
            if (CanSave)
            {
                ConflictResolutionRule newRule = SelectedResolutionAction.NewRule(Scope, Description, DataFields.ToDictionary(x => x.FieldName, x => x.FieldValue));
                int newRuleId = m_conflictManager.SaveNewResolutionRule(ConflictType, newRule);

                newRule.InternalId = newRuleId;
                try
                {
                    // try to resolve existing conflicts
                    IEnumerable <ConflictResolutionResult> results = m_conflictManager.ResolveExistingConflictWithExistingRule(newRule);

                    m_appViewModel.SetResolvedConflicts(results, newRule.InternalId);

                    // get new rule from db
                    RuntimeEntityModel context = RuntimeEntityModel.CreateInstance();
                    var v = from r in context.RTResolutionRuleSet
                            where r.Id == newRuleId
                            select r;
                    if (v.Count() > 0)
                    {
                        m_appViewModel.Rules.Insert(0, new ExistingRuleViewModel(v.First(), m_appViewModel));
                    }

                    return(results);
                }
                catch (ConflictManagementGeneralException)
                {
                    throw new Exception("Could not save rule.");
                }
            }
            else
            {
                throw new Exception("Invalid scope");
            }
        }
Пример #3
0
        public IEnumerable <ConflictResolutionResult> Save()
        {
            if (CustomControl != null && !ShowAdvancedOptions)
            {
                CustomControl.Save();
            }

            if (CanSave)
            {
                m_newRule = SelectedResolutionAction.NewRule(Scope, Description, DataFields.ToDictionary(x => x.FieldName, x => x.FieldValue));

                List <ConflictResolutionResult> results = new List <ConflictResolutionResult>();
                ConflictResolutionResult        firstConflictResolutionResult = m_conflictManager.ResolveExistingConflictWithNewRule(m_conflict.Id, m_newRule);
                firstConflictResolutionResult.ConflictInternalId = ConflictInternalId;
                results.Add(firstConflictResolutionResult);

                if (firstConflictResolutionResult.Resolved)
                {
                    try
                    {
                        IEnumerable <ConflictResolutionResult> otherConflictsResolutionResult = m_conflictManager.ResolveExistingConflictWithExistingRule(m_newRule);
                        results.AddRange(otherConflictsResolutionResult);
                    }
                    catch (MigrationException)
                    { }
                    catch (EntityException)
                    { }
                }

                foreach (ConflictResolutionResult result in results)
                {
                    if (this.ConflictInternalId == result.ConflictInternalId)
                    {
                        if (result.Resolved)
                        {
                            IsResolved       = ResolvedStatus.Resolved;
                            ResolvedByRuleId = m_newRule.InternalId;
                        }
                        else
                        {
                            IsResolved = ResolvedStatus.Failed;
                        }
                    }
                }

                m_appViewModel.SetResolvedConflicts(results, m_newRule.InternalId);

                // add new rule to rules list
                RuntimeEntityModel context = RuntimeEntityModel.CreateInstance();
                var v = from r in context.RTResolutionRuleSet
                        where r.Id == ResolvedByRuleId
                        select r;
                if (v.Count() > 0)
                {
                    m_appViewModel.Rules.Insert(0, new ExistingRuleViewModel(v.First(), m_appViewModel));
                }

                return(results);
            }
            else
            {
                throw new Exception("Invalid scope");
            }
        }