public void Copy(FileItemPathInfo sourcePathInfo, FileItemPathInfo destinationPathInfo) { if (!IsFileItemExists(sourcePathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(sourcePathInfo.GetPath()); } if (!IsFileItemExists(destinationPathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(sourcePathInfo.GetPath()); } if (!AllowCopyOrMove(sourcePathInfo, destinationPathInfo)) { FileManagementExceptionExecutor.ThrowNoAccess(); } var sourceFileItem = GetFileItem(sourcePathInfo); var copyFileItem = CreateCopy(sourceFileItem); copyFileItem.ParentId = destinationPathInfo.GetFileItemKey <int>(); copyFileItem.Name = GenerateCopiedFileItemName(destinationPathInfo.GetFileItemKey <int>(), copyFileItem.Name, copyFileItem.IsDirectory); FileManagementDbContext.FileItems.Add(copyFileItem); if (copyFileItem.IsDirectory) { CopyDirectoryContentRecursive(sourceFileItem, copyFileItem); } FileManagementDbContext.SaveChanges(); }
public void Move(FileItemPathInfo pathInfo, FileItemPathInfo destinationPathInfo) { if (!IsFileItemExists(pathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(pathInfo.GetPath()); } if (!IsFileItemExists(destinationPathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(pathInfo.GetPath()); } if (!AllowCopyOrMove(pathInfo, destinationPathInfo)) { FileManagementExceptionExecutor.ThrowNoAccess(); } var fileItem = GetFileItem(pathInfo); fileItem.ParentId = destinationPathInfo.GetFileItemKey <int>(); fileItem.Modified = DateTime.Now; fileItem.ModifiedById = GuestPersonId; FileManagementDbContext.SaveChanges(); }
public void Rename(FileItemPathInfo pathInfo, string newName) { if (!IsFileItemExists(pathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(pathInfo.GetPath()); } var fileItem = GetFileItem(pathInfo); fileItem.Name = newName; fileItem.ModifiedById = GuestPersonId; fileItem.Modified = DateTime.Now; FileManagementDbContext.SaveChanges(); }
public void Remove(FileItemPathInfo pathInfo) { if (!IsFileItemExists(pathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(pathInfo.GetPath()); } var fileItem = GetFileItem(pathInfo); FileManagementDbContext.FileItems.Remove(fileItem); if (fileItem.IsDirectory) { RemoveDirectoryContentRecursive(fileItem.Id); } FileManagementDbContext.SaveChanges(); }
public void CreateDirectory(FileItemPathInfo pathInfo, string name) { if (!IsFileItemExists(pathInfo)) { FileManagementExceptionExecutor.ThrowDirectoryExists(pathInfo.GetPath()); } var directory = new FileItem { Name = name, Modified = DateTime.Now, Created = DateTime.Now, IsDirectory = true, ParentId = pathInfo.GetFileItemKey <int>(), ModifiedById = GuestPersonId }; FileManagementDbContext.FileItems.Add(directory); FileManagementDbContext.SaveChanges(); }
string GetFileItemPath(FileItemPathInfo pathInfo) { return(pathInfo.GetPath().Replace('\\', '/')); }