public void BackupConfiguration(string archiveName) { homegenie.UpdateProgramsDatabase(); homegenie.UpdateGroupsDatabase("Automation"); homegenie.UpdateGroupsDatabase("Control"); homegenie.SaveData(); if (File.Exists(archiveName)) { File.Delete(archiveName); } // Add USER-SPACE program files (only for arduino-type programs) foreach (var program in homegenie.ProgramManager.Programs) { if (program.Type.ToLower() == "arduino" && (program.Address >= ProgramManager.USERSPACE_PROGRAMS_START && program.Address < ProgramManager.PACKAGE_PROGRAMS_START)) { string arduinoFolder = Path.Combine("programs", "arduino", program.Address.ToString()); string[] filePaths = Directory.GetFiles(arduinoFolder); foreach (string f in filePaths) { Utility.AddFileToZip(archiveName, Path.Combine(arduinoFolder, Path.GetFileName(f))); } } } // Add system config files Utility.AddFileToZip(archiveName, "systemconfig.xml"); Utility.AddFileToZip(archiveName, "automationgroups.xml"); Utility.AddFileToZip(archiveName, "modules.xml"); Utility.AddFileToZip(archiveName, "programs.xml"); Utility.AddFileToZip(archiveName, "scheduler.xml"); Utility.AddFileToZip(archiveName, "groups.xml"); Utility.AddFileToZip(archiveName, "release_info.xml"); #if !NETCOREAPP // Statistics db if (File.Exists(StatisticsLogger.STATISTICS_DB_FILE)) { homegenie.Statistics.CloseStatisticsDatabase(); Utility.AddFileToZip(archiveName, StatisticsLogger.STATISTICS_DB_FILE); homegenie.Statistics.OpenStatisticsDatabase(); } #endif // Installed packages if (File.Exists(PackageManager.PACKAGE_LIST_FILE)) { Utility.AddFileToZip(archiveName, PackageManager.PACKAGE_LIST_FILE); } // Add MIG Interfaces config/data files (lib/mig/*.xml) string migLibFolder = Path.Combine("lib", "mig"); if (Directory.Exists(migLibFolder)) { foreach (string f in Directory.GetFiles(migLibFolder, "*.xml")) { // exclude Pepper1 Db from backup (only the p1db_custom.xml file will be included) // in the future the p1db.xml file should be moved to a different path if (Path.GetFileName(f) != "p1db.xml") { Utility.AddFileToZip(archiveName, f); } } } }
public void BackupConfiguration(string archiveName) { _homegenie.UpdateProgramsDatabase(); _homegenie.UpdateAutomationGroupsDatabase(); _homegenie.UpdateGroupsDatabase(); _homegenie.SaveData(); if (File.Exists(archiveName)) { File.Delete(archiveName); } // Add USERSPACE automation program binaries (csharp) foreach (var program in _homegenie.ProgramManager.Programs) { if (program.Address >= ProgramManager.USERSPACE_PROGRAMS_START && program.Address < ProgramManager.PACKAGE_PROGRAMS_START) { //var relFile = Path.Combine("programs/", program.Address + ".dll"); var relFile = Path.Combine(FilePaths.ProgramsFolder, program.Address + ".dll"); if (File.Exists(relFile)) { ArchiveHelper.AddFileToZip(archiveName, relFile); } if (program.Type.ToLower() == "arduino") { var arduinoFolder = Path.Combine(FilePaths.ProgramsFolder, "arduino", program.Address.ToString()); var filePaths = Directory.GetFiles(arduinoFolder); foreach (var f in filePaths) { ArchiveHelper.AddFileToZip(archiveName, Path.Combine(arduinoFolder, Path.GetFileName(f))); } } } } ArchiveHelper.AddFolderToZip(archiveName, FilePaths.DataFolder); }
public void BackupConfiguration(string archiveName) { homegenie.UpdateProgramsDatabase(); homegenie.UpdateGroupsDatabase("Automation"); homegenie.UpdateGroupsDatabase("Control"); homegenie.SaveData(); if (File.Exists(archiveName)) { File.Delete(archiveName); } // Add USERSPACE automation program binaries (csharp) foreach (var program in homegenie.ProgramManager.Programs) { if (program.Address >= ProgramManager.USERSPACE_PROGRAMS_START && program.Address < ProgramManager.PACKAGE_PROGRAMS_START) { string relFile = Path.Combine("programs/", program.Address + ".dll"); if (File.Exists(relFile)) { Utility.AddFileToZip(archiveName, relFile); } if (program.Type.ToLower() == "arduino") { string arduinoFolder = Path.Combine("programs", "arduino", program.Address.ToString()); string[] filePaths = Directory.GetFiles(arduinoFolder); foreach (string f in filePaths) { Utility.AddFileToZip(archiveName, Path.Combine(arduinoFolder, Path.GetFileName(f))); } } } } // Add system config files Utility.AddFileToZip(archiveName, "systemconfig.xml"); Utility.AddFileToZip(archiveName, "automationgroups.xml"); Utility.AddFileToZip(archiveName, "modules.xml"); Utility.AddFileToZip(archiveName, "programs.xml"); Utility.AddFileToZip(archiveName, "scheduler.xml"); Utility.AddFileToZip(archiveName, "groups.xml"); Utility.AddFileToZip(archiveName, "release_info.xml"); // Statistics db if (File.Exists(StatisticsLogger.STATISTICS_DB_FILE)) { homegenie.Statistics.CloseStatisticsDatabase(); Utility.AddFileToZip(archiveName, StatisticsLogger.STATISTICS_DB_FILE); homegenie.Statistics.OpenStatisticsDatabase(); } // Installed packages if (File.Exists(PackageManager.PACKAGE_LIST_FILE)) { Utility.AddFileToZip(archiveName, PackageManager.PACKAGE_LIST_FILE); } // Add MIG Interfaces config/data files (lib/mig/*.xml) string migLibFolder = Path.Combine("lib", "mig"); if (Directory.Exists(migLibFolder)) { foreach (string f in Directory.GetFiles(migLibFolder, "*.xml")) { Utility.AddFileToZip(archiveName, f); } } }