Exemple #1
0
        public void DeserializeConflictResolutionRuleCollection()
        {
            using (TfsMigrationConsolidatedDBEntities context = TfsMigrationConsolidatedDBEntities.CreateInstance())
            {
                var rules = from r in context.ConfigConflictResolutionRuleSet
                            select r;

                SerializableConflictResolutionRuleCollection collection = new SerializableConflictResolutionRuleCollection();
                var serializer = new GenericSerializer <SerializableConflictResolutionRuleCollection>();
                foreach (ConfigConflictResolutionRule rule in rules)
                {
                    SerializableConflictResolutionRule serializableRule = new SerializableConflictResolutionRule(rule);
                    collection.AddRule(serializableRule);
                }

                string serializedText = serializer.Serialize(collection);
                var    ruleSerializer = new GenericSerializer <SerializableConflictResolutionRule>();
                var    newCollection  = serializer.Deserialize(serializedText);
                foreach (var serializableRule in newCollection.Rules)
                {
                    Trace.WriteLine("============================");
                    string ruleText = ruleSerializer.Serialize(serializableRule);
                    Trace.WriteLine(ruleText);
                }
            }
        }
 public void Import(SerializableConflictResolutionRuleCollection ruleCollection)
 {
     Debug.Assert(null != ruleCollection, "ruleCollection is NULL");
     foreach (var rule in ruleCollection.Rules)
     {
         ImportRule(rule);
     }
 }
Exemple #3
0
 private static void AddRules(
     IQueryable <ConfigConflictResolutionRule> sessionGroupScopeRules,
     SerializableConflictResolutionRuleCollection ruleCollection)
 {
     foreach (var rule in sessionGroupScopeRules)
     {
         ruleCollection.AddRule(new SerializableConflictResolutionRule(rule));
     }
 }
Exemple #4
0
        public Configuration Import()
        {
            string tempFolder = System.IO.Path.GetTempPath();
            string destFolder = Path.Combine(tempFolder, "TFSIntegrationImportConfig");

            ZipUtility.Unzip(m_configPackage, destFolder, true);

            string configFilePath = Path.Combine(destFolder, ConfigExporter.ConfigFileName);

            if (!File.Exists(configFilePath))
            {
                throw new ConfigNotExistInPackageException(m_configPackage);
            }

            try
            {
                Dictionary <string, string> oldToNewGuidMaps;
                Configuration importedConfig = LoadReGuidAndSaveConfig(configFilePath, out oldToNewGuidMaps);

                Debug.Assert(null != oldToNewGuidMaps, "oldToNewGuidMaps is NULL");
                string rulesFilePath = Path.Combine(destFolder, ConfigExporter.ResolutionRuleFileName);
                SerializableConflictResolutionRuleCollection ruleCollection = LoadResolutionRulesAndReGuid(rulesFilePath, oldToNewGuidMaps);

                if (null != ruleCollection)
                {
                    ResolutionRuleImporter ruleImporter = new ResolutionRuleImporter();
                    ruleImporter.Import(ruleCollection);
                }

                return(importedConfig);
            }
            finally
            {
                // clean-up the extracted temporary files
                DirectoryInfo directoryInfo = new DirectoryInfo(destFolder);
                if (directoryInfo.Exists)
                {
                    directoryInfo.Delete(true);
                }
            }
        }
Exemple #5
0
        private void ExportConflictResolutionRules(Guid sessionGroupUniqueId, string exportResolutionRulesFileName)
        {
            using (TfsMigrationConsolidatedDBEntities context = TfsMigrationConsolidatedDBEntities.CreateInstance())
            {
                SerializableConflictResolutionRuleCollection ruleCollection =
                    new SerializableConflictResolutionRuleCollection();

                #region session group scope rules
                var sessionGroupScopeRules =
                    from r in context.ConfigConflictResolutionRuleSet
                    where r.ScopeInfoUniqueId.Equals(sessionGroupUniqueId)
                    select r;
                AddRules(sessionGroupScopeRules, ruleCollection);
                #endregion

                #region session scope rules
                int activeStatus         = (int)Microsoft.TeamFoundation.Migration.BusinessModel.Configuration.ConfigurationStatus.Valid;
                var activeSessionConfigs =
                    from sc in context.SessionConfigSet
                    where sc.SessionGroupConfig.Status == activeStatus &&
                    sc.SessionGroupConfig.SessionGroup.GroupUniqueId.Equals(sessionGroupUniqueId)
                    select sc;

                foreach (var sessionConfig in activeSessionConfigs)
                {
                    Guid sessionUniqueId   = sessionConfig.SessionUniqueId;
                    var  sessionScopeRules =
                        from r in context.ConfigConflictResolutionRuleSet
                        where r.ScopeInfoUniqueId.Equals(sessionUniqueId)
                        select r;
                    AddRules(sessionScopeRules, ruleCollection);
                }
                #endregion

                using (FileStream fs = new FileStream(exportResolutionRulesFileName, FileMode.Create))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(SerializableConflictResolutionRuleCollection));
                    serializer.Serialize(fs, ruleCollection);
                }
            }
        }