private static bool GetStorageSpaceFolderEncryptDataAccessStatusInternal(int storageSpaceFolderId) { try { var folder = GetStorageSpaceFolderById(storageSpaceFolderId); if (folder == null) { throw new Exception(string.Format("Storage space folder with id={0} not found", storageSpaceFolderId)); } var storageSpace = StorageSpacesController.GetStorageSpaceById(folder.StorageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", folder.StorageSpaceId)); } var ss = GetStorageSpaceService(storageSpace.ServiceId); return(ss.ShareGetEncyptDataAccessStatus(folder.Path)); } catch (Exception exception) { throw TaskManager.WriteError(exception); } }
private static void SetStorageSpaceFolderEncryptDataAccessStatusInternal(int storageSpaceFolderId, bool enabled) { TaskManager.StartTask("STORAGE_SPACES", "SET_ENCRYPT_DATA_ACCESS_STATUS"); try { var folder = GetStorageSpaceFolderById(storageSpaceFolderId); if (folder == null) { throw new Exception(string.Format("Storage space folder with id={0} not found", storageSpaceFolderId)); } var storageSpace = StorageSpacesController.GetStorageSpaceById(folder.StorageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", folder.StorageSpaceId)); } var ss = GetStorageSpaceService(storageSpace.ServiceId); ss.ShareSetEncyptDataAccess(folder.Path, enabled); } catch (Exception exception) { throw TaskManager.WriteError(exception); } finally { TaskManager.CompleteTask(); } }
public static byte[] GetFileBinaryChunk(int storageSpaceId, string path, int offset, int length) { var storageSpace = StorageSpacesController.GetStorageSpaceById(storageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", storageSpaceId)); } var ss = GetStorageSpaceService(storageSpace.ServiceId); return(ss.GetFileBinaryChunk(path, offset, length)); }
private static IntResult CreateStorageSpaceFolderInternal(int storageSpaceId, string groupName, string organizationId, string folderName, long quotaInBytes, QuotaType quotaType) { var result = TaskManager.StartResultTask <IntResult>("STORAGE_SPACES", "CREATE_STORAGE_SPACE_FOLDER"); try { var storageSpace = StorageSpacesController.GetStorageSpaceById(storageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", storageSpaceId)); } var ss = GetStorageSpaceService(storageSpace.ServiceId); var fullPath = CreateFilePath(storageSpace.Path, organizationId, groupName, folderName); ss.CreateFolder(fullPath); var shareName = GenerateShareName(organizationId, folderName); var share = ShareStorageSpaceFolderInternal(storageSpace.Id, fullPath, shareName); ss.UpdateFolderQuota(fullPath, quotaInBytes, quotaType); result.Value = DataProvider.CreateStorageSpaceFolder(folderName, storageSpace.Id, fullPath, share.UncPath, true, quotaType, quotaInBytes); } catch (Exception exception) { TaskManager.WriteError(exception); result.AddError("Error creating Storage Space folder", exception); if (result.Value > 0) { DataProvider.RemoveStorageSpaceFolder(result.Value); } } finally { if (!result.IsSuccess) { TaskManager.CompleteResultTask(result); } else { TaskManager.CompleteResultTask(); } } return(result); }
private static ResultObject UpdateStorageSpaceFolderInternal(int storageSpaceId, int storageSpaceFolderId, string organizationId, string groupName, string folderName, string uncPath, long quotaInBytes, QuotaType quotaType) { var result = TaskManager.StartResultTask <ResultObject>("STORAGE_SPACES", "UPDATE_STORAGE_SPACE_FOLDER"); try { var storageSpace = StorageSpacesController.GetStorageSpaceById(storageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", storageSpaceId)); } var ss = StorageSpacesController.GetStorageSpaceService(storageSpace.ServiceId); var fullPath = CreateFilePath(storageSpace.Path, organizationId, groupName, folderName); if (quotaInBytes > 0) { ss.UpdateFolderQuota(fullPath, quotaInBytes, quotaType); } DataProvider.UpdateStorageSpaceFolder(storageSpaceFolderId, folderName, storageSpace.Id, fullPath, uncPath, false, quotaType, quotaInBytes); } catch (Exception exception) { TaskManager.WriteError(exception); result.AddError("Error removing Storage Space", exception); } finally { if (!result.IsSuccess) { TaskManager.CompleteResultTask(result); } else { TaskManager.CompleteResultTask(); } } return(result); }
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); }
private static StorageSpaceFolderShare ShareStorageSpaceFolderInternal(int storageSpaceId, string fullPath, string shareName) { var result = TaskManager.StartResultTask <ResultObject>("STORAGE_SPACES", "SHARE_STORAGE_SPACE_FOLDER"); try { var storageSpace = StorageSpacesController.GetStorageSpaceById(storageSpaceId); if (storageSpace == null) { throw new Exception(string.Format("Storage space with id={0} not found", storageSpaceId)); } var ss = StorageSpacesController.GetStorageSpaceService(storageSpace.ServiceId); var share = ss.ShareFolder(fullPath, shareName); if (share == null) { throw new Exception("Error sharing folder"); } return(share); } catch (Exception exception) { result.AddError("Error sharing Storage Space folder", exception); throw TaskManager.WriteError(exception); } finally { if (!result.IsSuccess) { TaskManager.CompleteResultTask(result); } else { TaskManager.CompleteResultTask(); } } }
public StorageSpace GetStorageSpaceById(int id) { return(StorageSpacesController.GetStorageSpaceById(id)); }