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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create under new temp directory and fill with archive content
        /// </summary>
        /// <returns>created DBDescriptor</returns>
        public static DBDescriptor CreateTempFromArchive(string zipFilePath, IProcessingCallback callback)
        {
            DBDescriptor desc = DBDescriptor.CreateTemp(false);

            FillFromArchive(desc, zipFilePath, callback);
            return(desc);
        }
        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);
        }
Exemplo n.º 4
0
 /// <summary>
 /// create in temp directory with empty database file
 /// </summary>
 /// <returns>Ready to use descriptor</returns>
 public static DBDescriptor CreateTemp()
 {
     return(DBDescriptor.CreateTemp(true));
 }