コード例 #1
0
        public bool Copy(DiskOprationInfo copyInfo)
        {
            //if (copyInfo.DestinationPath[0] != '~')
            //    copyInfo.DestinationPath = copyInfo.DestinationPath[0] == '/' ? "~" + copyInfo.DestinationPath : "~/" + copyInfo.DestinationPath;
            //if (copyInfo.SourcePath[0] != '~')
            //    copyInfo.SourcePath = copyInfo.SourcePath[0] == '/' ? "~" + copyInfo.SourcePath : "~/" + copyInfo.SourcePath;

            var destinationPath = AuthorizeManager.AuthorizeActionOnPath(copyInfo.DestinationPath, ActionKey.WriteToDisk);
            var sourcePath      = AuthorizeManager.AuthorizeActionOnPath(copyInfo.SourcePath, ActionKey.ReadFromDisk);

            Parallel.ForEach(copyInfo.Files, file =>
            {
                _fileSystemManager.CopyFile(sourcePath + "/" + file, destinationPath + "/" + file, copyInfo.OverWrite);
            });
            Parallel.ForEach(copyInfo.Folders, folder =>
            {
                _fileSystemManager.CopyDirectory(sourcePath + "/" + folder, destinationPath + "/" + folder, copyInfo.OverWrite);
            });
            return(true);
        }
コード例 #2
0
 public bool Copy(DiskOprationInfo copyInfo)
 {
     return(_fileSystemBiz.Copy(copyInfo));
 }
コード例 #3
0
 public bool Move(DiskOprationInfo moveInfo)
 {
     return(_fileSystemBiz.Move(moveInfo));
 }
コード例 #4
0
        public bool Move(DiskOprationInfo moveInfo)
        {
            //if (moveInfo.DestinationPath[0] != '~')
            //    moveInfo.DestinationPath = moveInfo.DestinationPath[0] == '/' ? "~" + moveInfo.DestinationPath : "~/" + moveInfo.DestinationPath;
            //if (moveInfo.SourcePath[0] != '~')
            //    moveInfo.SourcePath = moveInfo.SourcePath[0] == '/' ? "~" + moveInfo.SourcePath : "~/" + moveInfo.SourcePath;
            var rootPath = HostingEnvironment.ApplicationHost.GetPhysicalPath();
            var tempPath = _fileSystemManager.RelativeToAbsolutePath(Config.ThumbnailPath);

            if (tempPath == null)
            {
                throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, Config.ThumbnailPath));
            }

            var thumbnailRootPath = tempPath.ToLower();

            var destinationPath = AuthorizeManager.AuthorizeActionOnPath(moveInfo.DestinationPath, ActionKey.WriteToDisk);
            var sourcePath      = AuthorizeManager.AuthorizeActionOnPath(moveInfo.SourcePath, ActionKey.ReadFromDisk);


            Parallel.ForEach(moveInfo.Files, file =>
            {
                var source = _fileSystemManager.RelativeToAbsolutePath(sourcePath + "/" + file);
                var dist   = _fileSystemManager.RelativeToAbsolutePath(destinationPath + "/" + file);
                if (source == null)
                {
                    throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "source"));
                }

                if (dist == null)
                {
                    throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "dist"));
                }

                _fileSystemManager.MoveFile(source, dist);

                var thumbnailSourcePath = source.Substring(rootPath.Length);
                var thumbnailDistPath   = dist.Substring(rootPath.Length);
                if (_fileSystemManager.FileExist(thumbnailRootPath + thumbnailSourcePath))
                {
                    _fileSystemManager.MoveFile(thumbnailRootPath + thumbnailSourcePath, thumbnailRootPath + thumbnailDistPath);
                }
            });
            Parallel.ForEach(moveInfo.Folders, folder =>
            {
                var source = _fileSystemManager.RelativeToAbsolutePath(sourcePath + "/" + folder);
                var dist   = _fileSystemManager.RelativeToAbsolutePath(destinationPath + "/" + folder);
                if (source == null)
                {
                    throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "source"));
                }

                if (dist == null)
                {
                    throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "dist"));
                }

                _fileSystemManager.MoveDirectory(source, dist);

                var thumbnailSourcePath = source.Substring(rootPath.Length);
                var thumbnailDistPath   = dist.Substring(rootPath.Length);
                if (_fileSystemManager.DirectoryExists(thumbnailRootPath + thumbnailSourcePath))
                {
                    _fileSystemManager.MoveDirectory(thumbnailRootPath + thumbnailSourcePath, thumbnailRootPath + thumbnailDistPath);
                }
            });
            return(true);
        }