Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        private static ResultObject RenameFolderInternal(int storageSpaceId, int folderId, string organizationId, string group, string fullPath, string newName)
        {
            var result = TaskManager.StartResultTask <ResultObject>("STORAGE_SPACES", "RENAME_FOLDER");

            try
            {
                if (storageSpaceId < 0)
                {
                    throw new ArgumentException("Storage Space iD must be greater than 0");
                }

                var storage = GetStorageSpaceById(storageSpaceId);

                if (storage == null)
                {
                    throw new Exception(string.Format("Storage space with id={0} not found", storageSpaceId));
                }

                var ss = GetStorageSpaceService(storage.ServiceId);

                ss.RemoveShare(fullPath);

                ss.RenameFolder(fullPath, newName);

                var newPath = Path.Combine(Directory.GetParent(fullPath).ToString(), newName);

                var shareName = GenerateShareName(organizationId, newName);

                var share = ShareStorageSpaceFolderInternal(storageSpaceId, newPath, shareName);

                var folder = GetStorageSpaceFolderById(folderId);

                StorageSpacesController.UpdateStorageSpaceFolder(storageSpaceId, folderId, organizationId, group, newName, share.UncPath, folder.FsrmQuotaSizeBytes, folder.FsrmQuotaType);
            }
            catch (Exception exception)
            {
                TaskManager.WriteError(exception);
                result.AddError("Error during folder rename", exception);
            }
            finally
            {
                if (!result.IsSuccess)
                {
                    TaskManager.CompleteResultTask(result);
                }
                else
                {
                    TaskManager.CompleteResultTask();
                }
            }

            return(result);
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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();
                }
            }
        }
Beispiel #8
0
        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);
        }
 public List <StorageSpace> GetStorageSpacesByLevelId(int levelId)
 {
     return(StorageSpacesController.GetStorageSpacesByLevelId(levelId));
 }
 public void SetStorageSpaceFolderAbeStatus(int storageSpaceFolderId, bool enabled)
 {
     StorageSpacesController.SetStorageSpaceFolderAbeStatus(storageSpaceFolderId, enabled);
 }
 public bool GetStorageSpaceFolderAbeStatus(int storageSpaceFolderId)
 {
     return(StorageSpacesController.GetStorageSpaceFolderAbeStatus(storageSpaceFolderId));
 }
 public void SetStorageSpaceFolderEncryptDataAccessStatus(int storageSpaceFolderId, bool enabled)
 {
     StorageSpacesController.SetStorageSpaceFolderEncryptDataAccessStatus(storageSpaceFolderId, enabled);
 }
 public bool GetStorageSpaceFolderEncryptDataAccessStatus(int storageSpaceFolderId)
 {
     return(StorageSpacesController.GetStorageSpaceFolderEncryptDataAccessStatus(storageSpaceFolderId));
 }
 public bool CheckIsStorageSpacePathInUse(int serverId, string path, int currentServiceId)
 {
     return(StorageSpacesController.CheckIsStorageSpacePathInUse(serverId, path, currentServiceId));
 }
 public ResultObject RemoveStorageSpace(int id)
 {
     return(StorageSpacesController.RemoveStorageSpace(id));
 }
 public SystemFile[] GetSystemSubFolders(int serviceId, string path)
 {
     return(StorageSpacesController.GetSystemSubFolders(serviceId, path));
 }
 public IntResult SaveStorageSpace(StorageSpace space)
 {
     return(StorageSpacesController.SaveStorageSpace(space));
 }
 public IntResult SaveStorageSpaceLevel(StorageSpaceLevel level, List <ResourceGroupInfo> groups)
 {
     return(StorageSpacesController.SaveStorageSpaceLevel(level, groups));
 }
 public StorageSpacesPaged GetStorageSpacesPaged(string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
 {
     return(StorageSpacesController.GetStorageSpacesPaged(filterColumn, filterValue, sortColumn, startRow, maximumRows));
 }
 public ResultObject SaveLevelResourceGroups(int levelId, List <ResourceGroupInfo> newGroups)
 {
     return(StorageSpacesController.SaveLevelResourceGroups(levelId, newGroups));
 }
 public List <ResourceGroupInfo> GetLevelResourceGroups(int id)
 {
     return(StorageSpacesController.GetLevelResourceGroups(id));
 }
 public List <StorageSpaceFolder> GetStorageSpaceFoldersByStorageSpaceId(int id)
 {
     return(StorageSpacesController.GetStorageSpaceFoldersByStorageSpaceId(id));
 }
 public StorageSpace GetStorageSpaceById(int id)
 {
     return(StorageSpacesController.GetStorageSpaceById(id));
 }
 public SystemFile[] GetDriveLetters(int serviceId)
 {
     return(StorageSpacesController.GetDriveLetters(serviceId));
 }