public static bool BackupBranch(List <string> nodePath, string zipFilePath, IProcessingCallback callback) { // remove zip path if it already exists if (System.IO.File.Exists(zipFilePath)) { System.IO.File.Delete(zipFilePath); } // build destination database path DBDescriptor dbDescTo = DBDescriptor.CreateTemp(); { // build data contexts PPDataContext dbFrom = new PPDataContext(); using (PPDataContext dbTo = new PPDataContext(dbDescTo)) { // copy format table CopyCardboardFormats(dbFrom, dbTo); // copy cardboard profiles CopyCardboardProfiles(dbFrom, dbTo); // copy document types CopyDocumentTypes(dbFrom, dbTo); // copy branch nodes recursively TreeNode nodeFrom = TreeNode.GetNodeByPath(dbFrom, null, nodePath, 0); TreeNode nodeTo = TreeNode.GetNodeByPath(dbTo, null, nodePath, 0);; CopyTreeNodesRecursively(dbFrom, dbTo, nodeFrom, nodeTo, callback); } GC.Collect(); } Thread.Sleep(1000); // archive temp database dbDescTo.Archive(zipFilePath, callback); return(true); }
public static bool BackupBranch(List <string> nodePath, string zipFilePath, IProcessingCallback callback) { // remove zip path if it already exists if (System.IO.File.Exists(zipFilePath)) { System.IO.File.Delete(zipFilePath); } // instantiate data context of current database PPDataContext dbFrom = new PPDataContext(); // get node from TreeNode nodeFrom = TreeNode.GetNodeByPath(dbFrom, null, nodePath, 0); // build list of profiles referred by branch components List <string> profileNames = new List <string>(); BuildListOfUsedCardboardProfiles(dbFrom, nodeFrom, ref profileNames); // build destination database path DBDescriptor dbDescTo = DBDescriptor.CreateTemp(); { // build data context using (PPDataContext dbTo = new PPDataContext(dbDescTo)) { // copy cardboard profiles MergeCardboardProfiles(dbFrom, dbTo, profileNames, callback); // copy document types CopyDocumentTypes(dbFrom, dbTo); // copy branch nodes recursively TreeNode nodeTo = TreeNode.GetNodeByPath(dbTo, null, nodePath, 0);; CopyTreeNodesRecursively(dbFrom, dbTo, nodeFrom, nodeTo, callback); } GC.Collect(); } Thread.Sleep(1000); // archive temp database dbDescTo.Archive(zipFilePath, callback); return(true); }