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)); }