예제 #1
0
        public string Export(Guid sessionGroupUniqueId)
        {
            string preExportDir = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = System.IO.Path.GetTempPath();

                if (m_exportConfigFileOnly)
                {
                    if (string.IsNullOrEmpty(m_exportFilePath))
                    {
                        m_exportFilePath = sessionGroupUniqueId.ToString() + ConfigFileName;
                    }

                    ExportConfiguration(sessionGroupUniqueId, m_exportFilePath);
                    return(Path.GetFullPath(m_exportFilePath));
                }
                else
                {
                    string exportConfigFileName = ConfigFileName;
                    ExportConfiguration(sessionGroupUniqueId, exportConfigFileName);

                    string exportResolutionRulesFileName = ResolutionRuleFileName;
                    ExportConflictResolutionRules(sessionGroupUniqueId, exportResolutionRulesFileName);

                    string exportZipFileName = (string.IsNullOrEmpty(m_exportFilePath) ?
                                                GetZipPackageFileName(sessionGroupUniqueId) : m_exportFilePath);
                    ZipUtility.Zip(exportZipFileName, new string[2] {
                        exportConfigFileName, exportResolutionRulesFileName
                    });

                    File.Delete(exportConfigFileName);
                    File.Delete(exportResolutionRulesFileName);

                    return(Path.GetFullPath(exportZipFileName));
                }
            }
            finally
            {
                Environment.CurrentDirectory = preExportDir;
            }
        }
예제 #2
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);
                }
            }
        }