Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Return true if the backup should be canceled to allow the user to correct the
		/// comment or something because there are problems with the file name. May show various
		/// messages to the user.
		/// </summary>
		/// <remarks>Ideally, showing the message boxes should be done directly from the dialog
		/// box, not here in the Presenter.</remarks>
		/// ------------------------------------------------------------------------------------
		internal bool FileNameProblems(Form messageBoxOwner)
		{
			BackupProjectSettings settings = new BackupProjectSettings(m_cache, m_backupProjectView, FwDirectoryFinder.DefaultBackupDirectory);
			settings.DestinationFolder = m_backupProjectView.DestinationFolder;
			if (settings.AdjustedComment.Trim() != settings.Comment.TrimEnd())
			{
				string displayComment;
				string format = FwCoreDlgs.ksCharactersNotPossible;
				if (File.Exists(settings.ZipFileName))
					format = FwCoreDlgs.ksCharactersNotPossibleOverwrite;
				displayComment = settings.Comment.Trim();
				if (displayComment.Length > 255)
					displayComment = displayComment.Substring(0, 255) + "...";


				string msg = string.Format(format, settings.AdjustedComment, displayComment);
				return MessageBox.Show(messageBoxOwner, msg, FwCoreDlgs.ksCommentWillBeAltered, MessageBoxButtons.OKCancel,
					File.Exists(settings.ZipFileName) ? MessageBoxIcon.Warning : MessageBoxIcon.Information)
					== DialogResult.Cancel;
			}
			if (File.Exists(settings.ZipFileName))
			{
				string msg = string.Format(FwCoreDlgs.ksOverwriteDetails, settings.ZipFileName);
				return MessageBox.Show(messageBoxOwner, msg, FwCoreDlgs.ksOverwrite, MessageBoxButtons.OKCancel,
					MessageBoxIcon.Warning) == DialogResult.Cancel;
			}
			return false; // no problems!
		}
Ejemplo n.º 2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="BackupFileSettings"/> class from an
 /// existing BackupProjectSettings object
 /// </summary>
 /// <param name="settings">The BackupProjectSettings.</param>
 /// ------------------------------------------------------------------------------------
 private BackupFileSettings(BackupProjectSettings settings)
 {
     m_backupTime              = settings.BackupTime;
     m_comment                 = settings.Comment;
     m_configurationSettings   = settings.IncludeConfigurationSettings;
     m_supportingFiles         = settings.IncludeSupportingFiles;
     m_linkedFiles             = settings.IncludeLinkedFiles;
     m_projectName             = settings.ProjectName;
     m_projectPathPersisted    = FdoFileHelper.GetPathWithoutRoot(settings.ProjectPath);
     m_spellCheckAdditions     = settings.IncludeSpellCheckAdditions;
     m_dbVersion               = settings.DbVersion;
     m_fwVersion               = settings.FwVersion;
     m_linkedFilesPathRelative = LinkedFilesRelativePathHelper.GetLinkedFilesRelativePathFromFullPath(settings.ProjectsRootFolder, settings.LinkedFilesPath, settings.ProjectPath, settings.ProjectName);
     m_linkedFilesPathActual   = settings.LinkedFilesPath;
     m_appAbbrev               = settings.AppAbbrev;
 }
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Backs up the project.
		/// </summary>
		/// <returns>The path to the backup file, or <c>null</c></returns>
		/// ------------------------------------------------------------------------------------
		internal string BackupProject(IThreadedProgress progressDlg)
		{
			BackupProjectSettings settings = new BackupProjectSettings(m_cache, m_backupProjectView, FwDirectoryFinder.DefaultBackupDirectory);
			settings.DestinationFolder = m_backupProjectView.DestinationFolder;
			settings.AppAbbrev = m_appAbbrev;

			ProjectBackupService backupService = new ProjectBackupService(m_cache, settings);
			string backupFile;
			if (!backupService.BackupProject(progressDlg, out backupFile))
			{
				string msg = string.Format(FwCoreDlgs.ksCouldNotBackupSomeFiles, backupService.FailedFiles.ToString(", ", Path.GetFileName));
				if (MessageBox.Show(msg, FwCoreDlgs.ksWarning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
					File.Delete(backupFile);
				backupFile = null;
			}
			return backupFile;
		}
Ejemplo n.º 4
0
 ///<summary>
 /// Constructor
 ///</summary>
 public ProjectBackupService(FdoCache cache, BackupProjectSettings settings)
 {
     m_cache    = cache;
     m_settings = settings;
 }
Ejemplo n.º 5
0
		///<summary>
		/// Constructor
		///</summary>
		public ProjectBackupService(FdoCache cache, BackupProjectSettings settings)
		{
			m_cache = cache;
			m_settings = settings;
		}
Ejemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Writes out the given backup settings to the given stream, which will normally
		/// be a file, but for testing we can use a memory stream.
		/// </summary>
		/// <param name="settings">The settings to persist.</param>
		/// <param name="stream">The persistence stream.</param>
		/// ------------------------------------------------------------------------------------
		public static void SaveToStream(BackupProjectSettings settings, Stream stream)
		{
			DataContractSerializer serializer = new DataContractSerializer(typeof(BackupFileSettings));
			serializer.WriteObject(stream, new BackupFileSettings(settings));
		}
Ejemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="BackupFileSettings"/> class from an
		/// existing BackupProjectSettings object
		/// </summary>
		/// <param name="settings">The BackupProjectSettings.</param>
		/// ------------------------------------------------------------------------------------
		private BackupFileSettings(BackupProjectSettings settings)
		{
			m_backupTime = settings.BackupTime;
			m_comment = settings.Comment;
			m_configurationSettings = settings.IncludeConfigurationSettings;
			m_supportingFiles = settings.IncludeSupportingFiles;
			m_linkedFiles = settings.IncludeLinkedFiles;
			m_projectName = settings.ProjectName;
			m_projectPathPersisted = FdoFileHelper.GetPathWithoutRoot(settings.ProjectPath);
			m_spellCheckAdditions = settings.IncludeSpellCheckAdditions;
			m_dbVersion = settings.DbVersion;
			m_fwVersion = settings.FwVersion;
			m_linkedFilesPathRelative = LinkedFilesRelativePathHelper.GetLinkedFilesRelativePathFromFullPath(settings.ProjectsRootFolder, settings.LinkedFilesPath, settings.ProjectPath, settings.ProjectName);
			m_linkedFilesPathActual = settings.LinkedFilesPath;
			m_appAbbrev = settings.AppAbbrev;
		}
Ejemplo n.º 8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes out the given backup settings to the given stream, which will normally
        /// be a file, but for testing we can use a memory stream.
        /// </summary>
        /// <param name="settings">The settings to persist.</param>
        /// <param name="stream">The persistence stream.</param>
        /// ------------------------------------------------------------------------------------
        public static void SaveToStream(BackupProjectSettings settings, Stream stream)
        {
            DataContractSerializer serializer = new DataContractSerializer(typeof(BackupFileSettings));

            serializer.WriteObject(stream, new BackupFileSettings(settings));
        }