/// <summary>
        /// Do a complete copy from a folder to another
        /// </summary>
        private void CompleteCopy()
        {
            if (Directory.Exists(SourcePath))
            {
                //The Source directory has succesfully been found

                //Search directory info from source and target path
                var diSource = new DirectoryInfo(SourcePath);
                var diTarget = new DirectoryInfo(DestinationPath);

                //Calculate the number of file in the source directory and the total size of it
                int  nbFiles       = EasySaveInfo.CompleteFilesNumber(diSource);
                long directorySize = EasySaveInfo.CompleteSize(diSource);

                EditLog.FileToSaveFound(this, nbFiles, diSource, directorySize);

                lock (Model.sync)
                {
                    CreateProgress(nbFiles, directorySize, nbFiles, 0, directorySize);
                    IsActive = true;
                }
                Model.OnSaveWorkUpdate();

                //initiate Copy from the source directory to the target directory
                EditLog.StartCopy(this);
                CompleteCopyAll(diSource, diTarget);


                lock (Model.sync)
                {
                    Progress.IsEncrypting = true;
                }
                Model.OnSaveWorkUpdate();

                //Start encryption file
                EditLog.StartEncryption(Index);
                EncryptFiles();
                EditLog.EndEncryption(Index);

                //Closing the complete save protocol
                lock (Model.sync)
                {
                    //DeleteProgress();
                    Progress.IsEncrypting = false;
                    IsActive = false;
                }
                Model.OnSaveWorkUpdate();

                EditLog.EndSaveProgram(Index);
            }
            else
            {
                //The Source Directory has not been found
                Model.OnUpdateModelError("directory");
            }
        }
Пример #2
0
        /// <summary>
        /// Do a differencial copy from a folder to another
        /// </summary>
        private void DifferencialCopy()
        {
            if (Directory.Exists(SourcePath))
            {
                //Search directory info from source and target path
                var diSource = new DirectoryInfo(SourcePath);
                var diTarget = new DirectoryInfo(DestinationPath);

                //Calculate the number of file in the source directory and the total size of it (of all )
                int  nbFiles       = EasySaveInfo.DifferencialFilesNumber(diSource, diTarget);
                long directorySize = EasySaveInfo.DifferencialSize(diSource, diTarget);

                //If there is at least one file to save then initiate the differencial saving protocol
                if (nbFiles != 0)
                {
                    EditLog.FileToSaveFound(this, nbFiles, diSource, directorySize);

                    lock (Model.sync)
                    {
                        CreateProgress(nbFiles, directorySize, nbFiles, 0, directorySize);
                        IsActive = true;
                    }

                    Model.OnSaveWorkUpdate();

                    //initiate Copy from the source directory to the target directory (only the file / directory that has been modified or are new)
                    EditLog.StartCopy(this);
                    DifferencialCopyAll(diSource, diTarget);


                    lock (Model.sync)
                    {
                        Progress.IsEncrypting = true;
                    }
                    Model.OnSaveWorkUpdate();

                    EditLog.StartEncryption(Index);
                    EncryptFiles();
                    EditLog.EndEncryption(Index);

                    lock (Model.sync)
                    {
                        //DeleteProgress();
                        Progress.IsEncrypting = false;
                        IsActive = false;
                    }
                    Model.OnSaveWorkUpdate();

                    EditLog.EndSaveProgram(Index);
                }
                //If there is no file to save then cancel the saving protocol
                else
                {
                    EditLog.NoFilesFound(Index);
                }
            }
            else
            {
                Model.OnUpdateModelError("directory");
            }
        }