protected override void Do()
        {
            _trashId = FolderDao.GetFolderIDTrash(true);
            Folder root = null;

            if (0 < Folders.Count)
            {
                root = FolderDao.GetRootFolder(Folders[0]);
            }
            else if (0 < Files.Count)
            {
                root = FolderDao.GetRootFolderByFile(Files[0]);
            }
            if (root != null)
            {
                Status += string.Format("folder_{0}{1}", root.ID, SPLIT_CHAR);
            }
            if (_isEmptyTrash)
            {
                DeleteFiles(Files);
                DeleteFolders(Folders);
                MessageService.Send(_headers, MessageAction.TrashEmptied);
            }
            else
            {
                DeleteFiles(Files, true);
                DeleteFolders(Folders, true);
            }
        }
        protected override void Do(IServiceScope scope)
        {
            var fileMarker = scope.ServiceProvider.GetService <FileMarker>();

            Status += string.Format("folder_{0}{1}", _toFolderId, FileOperation.SPLIT_CHAR);

            //TODO: check on each iteration?
            var toFolder = FolderDao.GetFolder(_toFolderId);

            if (toFolder == null)
            {
                return;
            }
            if (!FilesSecurity.CanCreate(toFolder))
            {
                throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
            }

            if (FolderDao.GetParentFolders(toFolder.ID).Any(parent => Folders.Contains(parent.ID.ToString())))
            {
                Error = FilesCommonResource.ErrorMassage_FolderCopyError;
                return;
            }

            if (_copy)
            {
                Folder rootFrom = null;
                if (0 < Folders.Count)
                {
                    rootFrom = FolderDao.GetRootFolder(Folders[0]);
                }
                if (0 < Files.Count)
                {
                    rootFrom = FolderDao.GetRootFolderByFile(Files[0]);
                }
                if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy from Trash.");
                }
                if (toFolder.RootFolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy to Trash.");
                }
            }

            MoveOrCopyFolders(scope, Folders, toFolder, _copy);
            MoveOrCopyFiles(scope, Files, toFolder, _copy);

            _needToMark.Distinct().ToList().ForEach(x => fileMarker.MarkAsNew(x));
        }
        protected override void Do()
        {
            Status += string.Format("folder_{0}{1}", _toFolderId, SplitCharacter);

            //TODO: check on each iteration?
            var toFolder = FolderDao.GetFolder(_toFolderId);

            if (toFolder == null)
            {
                return;
            }
            if (!FilesSecurity.CanCreate(toFolder))
            {
                throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
            }

            if (_copy)
            {
                Folder rootFrom = null;
                if (0 < Folders.Count)
                {
                    rootFrom = FolderDao.GetRootFolder(Folders[0]);
                }
                if (0 < Files.Count)
                {
                    rootFrom = FolderDao.GetRootFolderByFile(Files[0]);
                }
                if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy from Trash.");
                }
                if (toFolder.RootFolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy to Trash.");
                }
            }

            MoveOrCopyFolders(Folders, toFolder, _copy);
            MoveOrCopyFiles(Files, toFolder, _copy, _resolveType);

            _needToMarkAsNew.Distinct().ToList().ForEach(x => FileMarker.MarkAsNew(x, _markAsNewRecipientIDs));
        }
        protected override void Do()
        {
            _trashId = FolderDao.GetFolderIDTrash(true);
            Folder root = null;

            if (0 < Folders.Count)
            {
                root = FolderDao.GetRootFolder(Folders[0]);
            }
            else if (0 < Files.Count)
            {
                root = FolderDao.GetRootFolderByFile(Files[0]);
            }
            if (root != null)
            {
                Status += string.Format("folder_{0}{1}", root.ID, SPLIT_CHAR);
            }

            DeleteFiles(Files);
            DeleteFolders(Folders);
        }
Exemplo n.º 5
0
        protected override void Do()
        {
            Status += string.Format("folder_{0}{1}", _toFolder, splitCharacter);

            //TODO: check on each iteration?
            var to = FolderDao.GetFolder(_toFolder);

            if (to == null)
            {
                return;
            }
            if (!FilesSecurity.CanCreate(to))
            {
                throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
            }

            if (_copy)
            {
                Folder rootFrom = null;
                if (0 < Folders.Count)
                {
                    rootFrom = FolderDao.GetRootFolder(Folders[0]);
                }
                if (0 < Files.Count)
                {
                    rootFrom = FolderDao.GetRootFolderByFile(Files[0]);
                }
                if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy from Trash.");
                }
                if (to.RootFolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy to Trash.");
                }
            }

            MoveOrCopyFolders(Folders, _toFolder, _copy);
            MoveOrCopyFiles(Files, _toFolder, _copy, _resolveType);
        }