Ejemplo n.º 1
0
        /// <summary>
        /// Performs a file modification.
        /// </summary>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="targetFileSystem">The target file system.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="targetDirectory">The target directory.</param>
        /// <param name="execute">if set to true, the operation gets executed.</param>
        private void PerformFileModificationOperation(IFileSystem sourceFileSystem, IFileSystem targetFileSystem, IFileInfo sourceFile, IDirectoryInfo targetDirectory, bool execute)
        {
            var eventArgs = new FileCopyEventArgs(sourceFile, sourceFile.Directory, targetDirectory);

            this.OnModifyingFile(eventArgs);

            if (execute)
            {
                EventHandler <DataTransferEventArgs> handler = (sender, e) =>
                {
                    e.Cancel = this.IsStopped; //Stop the copy operation if the job is stopped

                    this.OnFileProgressChanged(e);
                };

                targetFileSystem.FileCopyProgressChanged += handler;

                try
                {
                    targetFileSystem.CopyFile(sourceFileSystem, sourceFile, targetDirectory);

                    this.OnModifiedFile(eventArgs);
                }

                catch (AccessException)
                {
                    this.OnFileCopyError(new FileCopyErrorEventArgs(sourceFile, targetDirectory));
                }

                targetFileSystem.FileCopyProgressChanged -= handler;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs a file modification.
        /// </summary>
        /// <param name="sourceFileSystem">The source file system.</param>
        /// <param name="targetFileSystem">The target file system.</param>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="targetDirectory">The target directory.</param>
        /// <param name="execute">if set to true, the operation gets executed.</param>
        private void PerformFileModificationOperation(IFileSystem sourceFileSystem, IFileSystem targetFileSystem, IFileInfo sourceFile, IDirectoryInfo targetDirectory, bool execute)
        {
            var eventArgs = new FileCopyEventArgs(sourceFile, sourceFile.Directory, targetDirectory);

            this.OnModifyingFile(eventArgs);

            if (execute)
            {
                EventHandler<DataTransferEventArgs> handler = (sender, e) =>
                {
                    e.Cancel = this.IsStopped; //Stop the copy operation if the job is stopped

                    this.OnFileProgressChanged(e);
                };

                targetFileSystem.FileCopyProgressChanged += handler;

                try
                {
                    targetFileSystem.CopyFile(sourceFileSystem, sourceFile, targetDirectory);

                    this.OnModifiedFile(eventArgs);
                }

                catch (AccessException)
                {
                    this.OnFileCopyError(new FileCopyErrorEventArgs(sourceFile, targetDirectory));
                }

                targetFileSystem.FileCopyProgressChanged -= handler;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Raises the <see cref="ModifyingFile"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 protected virtual void OnModifyingFile(FileCopyEventArgs e)
 {
     this.ModifyingFile.RaiseSafe(this, e);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Raises the <see cref="CreatingFile"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 protected virtual void OnCreatingFile(FileCopyEventArgs e)
 {
     this.CreatingFile.RaiseSafe(this, e);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Handles the CreatedFile event of the currentJob control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 private void currentJob_CreatedFile(object sender, FileCopyEventArgs e)
 {
     this.CreatedFile.RaiseSafe(this, e);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Handles the ModifyingFile event of the currentJob control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 private void currentJob_ModifyingFile(object sender, FileCopyEventArgs e)
 {
     this.ModifyingFile.RaiseSafe(this, e);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Handles the CreatedFile event of the currentJob control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 private void currentJob_CreatedFile(object sender, FileCopyEventArgs e)
 {
     this.CreatedFile.RaiseSafe(this, e);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Handles the ModifyingFile event of the currentJob control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 private void currentJob_ModifyingFile(object sender, FileCopyEventArgs e)
 {
     this.ModifyingFile.RaiseSafe(this, e);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Raises the <see cref="ModifiedFile"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 protected virtual void OnModifiedFile(FileCopyEventArgs e)
 {
     this.ModifiedFile.RaiseSafe(this, e);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Raises the <see cref="CreatedFile"/> event.
 /// </summary>
 /// <param name="e">The <see cref="FlagSync.Core.FileCopyEventArgs"/> instance containing the event data.</param>
 protected virtual void OnCreatedFile(FileCopyEventArgs e)
 {
     this.CreatedFile.RaiseSafe(this, e);
 }