Esempio n. 1
0
        public void Copy(string copyFromName, string copyFromPath, string copyToName, string copyToPath)
        {
            var folderToCopyTo = GetFolder(copyToName, copyToPath);

            if (folderToCopyTo == null)
            {
                throw new Exception("The folder you are trying to copy to does not exists!");
            }

            UpdateNextPageToWrite(folderToCopyTo);

            var folderToCopy = GetFolder(copyFromName, copyFromPath);

            if (folderToCopy == null)
            {
                throw new Exception("The folder you are trying to copy does not exists!");
            }

            _folderContentPageService.ValidateUniquenessOnAllFolderPages(folderToCopyTo, folderToCopy);
            var copyFromNewPath = string.IsNullOrEmpty(folderToCopyTo.Path) ? folderToCopyTo.Name : $"{folderToCopyTo.Path}/{folderToCopyTo.Name}";
            var oldPath         = $"{folderToCopy.Path}/{folderToCopy.Name}";
            var newPath         = $"{copyFromNewPath}/{folderToCopy.Name}";

            _folderContentFolderRepository.CopyDirectory(copyFromName, copyFromNewPath, copyFromName, copyFromPath);
            _folderContentPageService.CopyPagesToNewLocation(folderToCopy, folderToCopy.Name, copyFromPath, folderToCopy.Name, copyFromNewPath);
            folderToCopy.Path = copyFromNewPath;
            UpdateFolder(folderToCopy);
            _folderContentPageService.AddToFolderPage(folderToCopyTo, folderToCopyTo.NextPhysicalPageToWrite, folderToCopy);
            UpdateFolderChildrenPath(folderToCopy, newPath, oldPath);
        }
        public void CreateFile(string name, string path, string fileType, string tmpCreationPath, long size)
        {
            var file   = new FileObj(name, path, fileType, size);
            var parent = _folderContentFolderService.GetParentFolder(file);

            //Validate that the file is unique in all pages. If the file is unique then save it
            _folderContentPageService.ValidateUniquenessOnAllFolderPages(parent, file);
            _folderContentFileRepository.CreateOrUpdateFolderContentFile(name, path, file);

            _folderContentFileRepository.Move(name, path, tmpCreationPath);
            _folderContentFolderService.UpdateNextPageToWrite(parent);
            _folderContentPageService.AddToFolderPage(parent, parent.NextPhysicalPageToWrite, file);
        }