Exemple #1
0
        public SerializableConflictType(ConfigConflictType edmConflictType)
        {
            if (null == edmConflictType)
            {
                throw new ArgumentNullException("edmConflictType");
            }

            this.StorageId      = edmConflictType.Id;
            this.ReferenceName  = edmConflictType.ReferenceName;
            this.FriendlyName   = edmConflictType.FriendlyName;
            this.DescriptionDoc = edmConflictType.DescriptionDoc;
            this.IsActive       = edmConflictType.IsActive;
            edmConflictType.ProviderReference.Load();
            this.Provider = edmConflictType.Provider == null
                ? null : new SerializableProvider(edmConflictType.Provider);
        }
        private ConfigConflictType ImportConflictType(SerializableConflictType serializableConflictType)
        {
            if (m_oldStorageIdToNewEdmConflictType.ContainsKey(serializableConflictType.StorageId))
            {
                return(m_oldStorageIdToNewEdmConflictType[serializableConflictType.StorageId]);
            }
            else
            {
                Provider edmProvider = ImportProvider(serializableConflictType.Provider);

                Guid referenceName = serializableConflictType.ReferenceName;
                IQueryable <ConfigConflictType> query;
                if (edmProvider == null)
                {
                    query = from ct in m_context.ConfigConflictTypeSet
                            where ct.Provider == null &&
                            ct.ReferenceName.Equals(referenceName)
                            select ct;
                }
                else
                {
                    query = from ct in m_context.ConfigConflictTypeSet
                            where ct.Provider.ReferenceName.Equals(edmProvider.ReferenceName) &&
                            ct.ReferenceName.Equals(referenceName)
                            select ct;
                }

                ConfigConflictType edmConflictType;
                if (query.Count() > 0)
                {
                    edmConflictType = query.First();
                }
                else
                {
                    edmConflictType = ConfigConflictType.CreateConfigConflictType(
                        0, serializableConflictType.ReferenceName, serializableConflictType.FriendlyName);
                    edmConflictType.DescriptionDoc = serializableConflictType.DescriptionDoc;
                    edmConflictType.IsActive       = serializableConflictType.IsActive;
                    edmConflictType.Provider       = edmProvider;

                    m_context.AddToConfigConflictTypeSet(edmConflictType);
                    m_context.TrySaveChanges();
                }
                m_oldStorageIdToNewEdmConflictType.Add(serializableConflictType.StorageId, edmConflictType);
                return(edmConflictType);
            }
        }
        private void ImportRule(SerializableConflictResolutionRule rule)
        {
            if (!m_oldRuleRefNameToNewOne.ContainsKey(rule.ReferenceName))
            {
                ConfigConflictType                edmConflictType     = ImportConflictType(rule.ConflictType);
                ConfigConflictResolutionAction    edmResolutionAction = ImportResolutionAction(rule.ResolutionAction);
                ConfigConflictResolutionRuleScope edmRuleScope        = ImportScope(rule.Scope);

                Guid   newRuleRefName                = Guid.NewGuid();
                string newRuleDataXmlDocString       = rule.RuleDataXmlDocString.Replace(rule.ReferenceName.ToString(), newRuleRefName.ToString());
                ConfigConflictResolutionRule edmRule = ConfigConflictResolutionRule.CreateConfigConflictResolutionRule(
                    0, newRuleRefName, rule.ScopeInfoUniqueId, rule.SourceInfoUniqueId, newRuleDataXmlDocString, DateTime.Now, rule.Status);
                m_context.AddToConfigConflictResolutionRuleSet(edmRule);

                edmRule.ConflictType     = edmConflictType;
                edmRule.ResolutionAction = edmResolutionAction;
                edmRule.RuleScope        = edmRuleScope;

                m_context.TrySaveChanges();

                m_oldRuleRefNameToNewOne.Add(rule.ReferenceName, newRuleRefName);
            }
        }