예제 #1
0
 /// <summary>
 /// Restore LinkedFiles to the project or a non-standard location depending on the
 /// fPutFilesInProject parameter.
 /// </summary>
 /// <param name="fPutFilesInProject"></param>
 /// <param name="filesContainedInLinkdFilesFolder"></param>
 /// <param name="linkedFilesPathInZip"></param>
 /// <param name="proposedDestinationLinkedFilesPath"></param>
 protected void RestoreLinkedFiles(bool fPutFilesInProject, Dictionary <string, DateTime> filesContainedInLinkdFilesFolder,
                                   string linkedFilesPathInZip, string proposedDestinationLinkedFilesPath)
 {
     if (fPutFilesInProject)
     {
         m_sLinkDirChangedTo = FdoFileHelper.GetDefaultLinkedFilesDir(m_restoreSettings.ProjectPath);
         //Restore the files to the project folder.
         UncompressLinkedFiles(filesContainedInLinkdFilesFolder, m_sLinkDirChangedTo, linkedFilesPathInZip);
     }
     else
     {
         if (!Directory.Exists(proposedDestinationLinkedFilesPath))
         {
             try
             {
                 Directory.CreateDirectory(proposedDestinationLinkedFilesPath);
             }
             catch (Exception error)
             {
                 CouldNotRestoreLinkedFilesToOriginalLocation(linkedFilesPathInZip, filesContainedInLinkdFilesFolder);
                 return;
             }
         }
         UncompressLinkedFiles(filesContainedInLinkdFilesFolder, proposedDestinationLinkedFilesPath, linkedFilesPathInZip);
     }
 }
예제 #2
0
        /// <summary>
        /// Displays a dialog that asks the user how to handle a situation where non-standard location linked files
        /// cannot be restored to their previous position.
        /// </summary>
        /// <param name="linkedFilesPathPersisted"></param>
        /// <param name="filesContainedInLinkdFilesFolder"></param>
        protected virtual void CouldNotRestoreLinkedFilesToOriginalLocation(string linkedFilesPathPersisted, Dictionary <string, DateTime> filesContainedInLinkdFilesFolder)
        {
            YesNoCancel userSelection = m_ui.CannotRestoreLinkedFilesToOriginalLocation();

            if (userSelection == YesNoCancel.OkYes)
            {
                m_sLinkDirChangedTo = FdoFileHelper.GetDefaultLinkedFilesDir(m_restoreSettings.ProjectPath);
                //Restore the files to the project folder.
                UncompressLinkedFiles(filesContainedInLinkdFilesFolder, m_sLinkDirChangedTo, linkedFilesPathPersisted);
            }
            else if (userSelection == YesNoCancel.OkNo)
            {
                //Do nothing. Do not restore any LinkedFiles.
            }
        }
예제 #3
0
        private void RestoreLinkedFiles(BackupFileSettings fileSettings)
        {
            Debug.Assert(fileSettings.LinkedFilesAvailable,
                         "The option to include linked files should not be allowed if they aren't available in the backup settings");

            var proposedDestinationLinkedFilesPath =
                LinkedFilesRelativePathHelper.GetLinkedFilesFullPathFromRelativePath(m_restoreSettings.ProjectsRootFolder,
                                                                                     fileSettings.LinkedFilesPathRelativePersisted, m_restoreSettings.ProjectPath);

            var linkedFilesPathInZip = fileSettings.LinkedFilesPathActualPersisted;

            if (fileSettings.LinkedFilesPathRelativePersisted.StartsWith(LinkedFilesRelativePathHelper.ksProjectRelPath))
            {
                // We store any files inside the project folder as a relative path from the project's directory.
                // Make sure we don't attempt to search for the whole directory structure in the zip file. (FWR-2909)
                linkedFilesPathInZip = fileSettings.LinkedFilesPathRelativePersisted.Substring(
                    LinkedFilesRelativePathHelper.ksProjectRelPath.Length + 1);
            }
            var filesContainedInLinkdFilesFolder = GetAllFilesUnderFolderInZipFileAndDateTimes(linkedFilesPathInZip);

            //If the proposed location is not in the default location under the project, then ask the user if they want
            //to restore the files to the default location instead. Otherwise just go ahead and restore the files.
            var defaultLinkedFilesPath = FdoFileHelper.GetDefaultLinkedFilesDir(m_restoreSettings.ProjectPath);

            if (proposedDestinationLinkedFilesPath.Equals(defaultLinkedFilesPath))
            {
                if (!Directory.Exists(defaultLinkedFilesPath))
                {
                    Directory.CreateDirectory(proposedDestinationLinkedFilesPath);
                }
                ExternalLinksDirectoryExits(linkedFilesPathInZip, proposedDestinationLinkedFilesPath, filesContainedInLinkdFilesFolder);
            }
            else
            {
                //LinkedFiles folder does not exist which means it was not in the default location when the backup was made.
                //Therefore, ask the user if we can restore these files to the default location in the project's folder.
                RestoreLinkedFiles(CanRestoreLinkedFilesToProjectsFolder(), filesContainedInLinkdFilesFolder, linkedFilesPathInZip,
                                   proposedDestinationLinkedFilesPath);
            }
        }