Exemple #1
0
        public void SkipCurrentFile(bool fastMove)
        {
            if (!File.Exists(CurrentFile.DestinyPath))
            {
                CurrentFile.CopyState            = CopyState.Processing;
                DiscoverdList.SizeOfFilesToCopy -= CurrentFile.Size;

                if (fastMove)
                {
                    Alphaleonis.Win32.Filesystem.File.Move(CurrentFile.FullName, CurrentFile.DestinyPath);
                }
                else
                {
                    FileCopier.CopyFile(CurrentFile);
                }


                AffterFileCopyAction.Invoke(CurrentFile);
            }
            else
            {
                FileCopier.TotalBytesTransferred += CurrentFile.Size;

                FileCollisionAction = AllwaysAsk;
            }
        }
Exemple #2
0
        public void AllwaysAsk(bool fastMove)
        {
            //Copy the current file.
            if (File.Exists(CurrentFile.DestinyPath))
            {
                if (FileCollisionAction == CancelCollision)
                {
                    return;
                }

                FileCollisionAction = FileExist(this, CurrentFile);

                FileCollisionAction.Invoke(fastMove);
            }
            else
            {
                CurrentFile.CopyState            = CopyState.Processing;
                DiscoverdList.SizeOfFilesToCopy -= CurrentFile.Size;

                if (fastMove)
                {
                    Alphaleonis.Win32.Filesystem.File.Move(CurrentFile.FullName, CurrentFile.DestinyPath);
                }
                else
                {
                    FileCopier.CopyFile(CurrentFile);
                }

                AffterFileCopyAction.Invoke(CurrentFile);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="index">Used to check if must start in this files index or in index + 1</param>
        public void Skip(int index)
        {
            try
            {
                //if (State == CopyHandleState.Runing && FileCopier.Writer != null)
                //{

                myThread.Pause();

                //If there is any file in copy process then stop copy,
                //free resources and delete the file with Cancel method.
                if (FileCopier.CurrentFile != null)
                {
                    FileCopier.CurrentFile.CopyState = CopyState.Skiped;
                    FileCopier.Skip();
                }

                //Terminate the copy process
                myThread.Cancel();

                myThread = new MyThread(new Action(() =>
                {
                    if (Operation != null)
                    {
                        Operation.Invoke();

                        RaiseFinished(Errors);

                        Errors.Clear();
                    }
                }));

                if (DiscoverdList.Index == index)
                {
                    DiscoverdList.Index++;
                    CopiedsFiles++;
                }

                myThread.Start();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(Error.GetErrorLog(ex.Message, "NeathCopyEngine", "NeathCopyHandle", "Skip"));
                using (var w = new StreamWriter(new FileStream(logsPath, FileMode.Append, FileAccess.Write)))
                {
                    w.WriteLine("-------------------------------");
                    w.WriteLine(System.DateTime.Now);
                    w.WriteLine(Error.GetErrorLogInLine(ex.Message, "NeathCopyEngine", "NeathCopyHandle", "Skip"));
                }
            }
        }
Exemple #4
0
        public void OverwriteAll(bool fastMove)
        {
            //Copy the current file.
            CurrentFile.CopyState            = CopyState.Processing;
            DiscoverdList.SizeOfFilesToCopy -= CurrentFile.Size;

            if (fastMove)
            {
                if (Alphaleonis.Win32.Filesystem.File.Exists(CurrentFile.DestinyPath))
                {
                    Alphaleonis.Win32.Filesystem.File.Delete(CurrentFile.DestinyPath);
                }
                Alphaleonis.Win32.Filesystem.File.Move(CurrentFile.FullName, CurrentFile.DestinyPath);
            }
            else
            {
                FileCopier.CopyFile(CurrentFile);
                AffterFileCopyAction.Invoke(CurrentFile);
            }
        }
Exemple #5
0
        public void Cancel(string cause)
        {
            try
            {
                var previousState = State;
                State = CopyHandleState.Canceled;

                //Terminate the copy process
                if (myThread != null)
                {
                    myThread.Cancel();
                }

                if (previousState == CopyHandleState.Runing && FileCopier.Writer != null)
                {
                    //If there is any file in copy process then stop copy,
                    //free resources and delete the file with Cancel method.
                    if (FileCopier.CurrentFile != null)
                    {
                        FileCopier.Cancel();
                    }
                }

                //Inform cancel action.
                RaiseCanceled(cause);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(string.Format("An Error has ocurred in Module: {0}, Class: {1}, Method: {2}, Error: {3}", "NeathCopyEngine", "NeathCopyHandle", "Cancel", ex.Message));
                using (var w = new StreamWriter(new FileStream(logsPath, FileMode.Append, FileAccess.Write)))
                {
                    w.WriteLine("-------------------------------");
                    w.WriteLine(System.DateTime.Now);
                    w.WriteLine(string.Format("Module: {0}, Class: {1}, Method: {2}, Error: {3}", "NeathCopyEngine", "NeathCopyHandle", "Cancel", ex.Message));
                }
            }
        }