private static List <SystemFile> SearchInStorageSpaceFolderInternal(int storageSpaceId, int storageSpaceFolderId, string searchPath, string searchValue) { var storageSpace = StorageSpacesController.GetStorageSpaceById(storageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", storageSpaceId)); } var storageSpaceFolder = StorageSpacesController.GetStorageSpaceFolderById(storageSpaceFolderId); if (storageSpaceFolder == null) { throw new Exception(string.Format("Storage space folder with id={0} not found", storageSpaceFolderId)); } var origSearchPath = searchPath; var ss = GetStorageSpaceService(storageSpace.ServiceId); int index = searchPath.IndexOf(Path.DirectorySeparatorChar); if (index >= 0) { searchPath = searchPath.Substring(index + 1); searchPath = Path.Combine(storageSpaceFolder.Path, searchPath); } else { searchPath = storageSpaceFolder.Path; } var searchResults = ss.Search(new[] { searchPath }, searchValue, true).ToList(); foreach (var result in searchResults) { result.RelativeUrl = result.FullName.Replace(storageSpaceFolder.Path, Path.GetFileName(storageSpaceFolder.Path)); } return(searchResults); }
public StorageSpaceFolder CreateFolder(string organizationId, int itemId, string type, long quotaInBytes, QuotaType qoutaType) { var storageId = StorageSpacesController.FindBestStorageSpaceService(new DefaultStorageSpaceSelector(), ResourceGroups.HostedOrganizations, quotaInBytes); if (!storageId.IsSuccess) { throw new Exception(storageId.ErrorCodes.First()); } var folder = StorageSpacesController.CreateStorageSpaceFolder(storageId.Value, ResourceGroups.HostedOrganizations, organizationId, type, quotaInBytes, qoutaType); if (!folder.IsSuccess) { throw new Exception(string.Join("---------------------------------------", folder.ErrorCodes)); } DataProvider.AddOrganizationStoragSpacesFolder(itemId, type, folder.Value); return(StorageSpacesController.GetStorageSpaceFolderById(folder.Value)); }
public ResultObject DeleteFolder(int itemId, int folderId) { var result = TaskManager.StartResultTask <ResultObject>("ORGANIZATION_FOLDERS", "DELETE_FOLDER"); try { var folder = StorageSpacesController.GetStorageSpaceFolderById(folderId); if (folder == null) { throw new Exception("Folder not found"); } DataProvider.DeleteOrganizationStoragSpacesFolder(folderId); var deletionResult = StorageSpacesController.DeleteStorageSpaceFolder(folder.StorageSpaceId, folder.Id); if (deletionResult.IsSuccess == false) { throw new Exception(string.Join(";", deletionResult.ErrorCodes)); } } catch (Exception exception) { TaskManager.WriteError(exception); result.AddError("Error deleting organization folder", exception); } finally { if (!result.IsSuccess) { TaskManager.CompleteResultTask(result); } else { TaskManager.CompleteResultTask(); } } return(result); }