private void MergeXmlRepository(string sourceFile, string destFile) { var repo = String.Empty; switch (Path.GetFileName(sourceFile)) { case "RocksmithToolkitLib.Config.xml": repo = "ConfigRepository"; break; case "RocksmithToolkitLib.SongAppId.xml": repo = "SongAppIdRepository"; break; case "RocksmithToolkitLib.TuningDefinition.xml": repo = "TuningDefinitionRepository"; break; } if (!String.IsNullOrEmpty(repo)) { AssemblyCaller.CallStatic(Path.Combine(workDir, APP_RSLIB), String.Format("RocksmithToolkitLib.XmlRepository.{0}", repo), "Merge", sourceFile, destFile); } }
private void MergeXmlRepository(string srcDir, string destDir) { ShowCurrentOperation("Preparing to merge repositories ..."); // this check must happen after download has been unzipped to the newLocalToolkitPath try { bool?replaceRepo = null; // get old replace repo from old ConfigRepo replaceRepo = (bool)AssemblyCaller.CallStatic(Path.Combine(appExecDir, APP_RSLIB), "RocksmithToolkitLib.XmlRepository.ConfigRepository", "GetBoolean", "general_replacerepo"); // get old config version from old ConfigRepo var xmlConfigVersion = (string)AssemblyCaller.CallStatic(Path.Combine(appExecDir, APP_RSLIB), "RocksmithToolkitLib.XmlRepository.ConfigRepository", "GetString", "general_configversion"); // get new config version from new GeneralConfig var generalConfigVersion = (string)AssemblyCaller.CallStatic(Path.Combine(appExecDir, APP_RSGUI), "RocksmithToolkitGUI.Config.GeneralConfig", "GetConfigVersion", null); if (String.IsNullOrEmpty(xmlConfigVersion)) { replaceRepo = true; } else if (String.IsNullOrEmpty(generalConfigVersion)) { replaceRepo = true; } else if (xmlConfigVersion != generalConfigVersion) // compare versions { replaceRepo = true; } else if (replaceRepo == null) { replaceRepo = true; } if (replaceRepo == true) { if (isDebugMe) { MessageBox.Show("XmlRepositories were not merged ..." + Environment.NewLine + "replaceRepo = " + replaceRepo.ToString() + Environment.NewLine + "xmlConfigVersion = " + xmlConfigVersion + Environment.NewLine + "generalConfigVersion = " + generalConfigVersion, "DEBUG ME"); } return; } } catch (Exception ex) { MessageBox.Show("<WARNING> XmlRepositories could not be merged ..." + Environment.NewLine + ex.Message, "RocksmithToolkit AutoUpdater", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ShowCurrentOperation("Merging repositories ..."); var repositories = new Dictionary <string, string>() { { "ConfigRepository", REPO_CONFIG }, { "SongAppIdRepository", REPO_SONGAPPID }, { "TuningDefinitionRepository", REPO_TUNINGDEF } }; foreach (KeyValuePair <string, string> repo in repositories) { var srcPath = Path.Combine(srcDir, repo.Value); var destPath = Path.Combine(destDir, repo.Value); // merge if srcPath and destPath exist if (File.Exists(srcPath) && File.Exists(destPath)) { try { AssemblyCaller.CallStatic(Path.Combine(appExecDir, APP_RSLIB), String.Format("RocksmithToolkitLib.XmlRepository.{0}", repo.Key), "Merge", srcPath, destPath); } catch (Exception ex) { MessageBox.Show("<ERROR> MergeXmlRepository file, AssemblyCaller failure ..." + Environment.NewLine + "srcPath = " + srcPath + Environment.NewLine + "destPath = " + destPath + Environment.NewLine + ex.InnerException.Message, "RocksmithToolkit AutoUpdater", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }