Exemplo n.º 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);
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 public List <StorageSpace> GetStorageSpacesByLevelId(int levelId)
 {
     return(StorageSpacesController.GetStorageSpacesByLevelId(levelId));
 }
Exemplo n.º 12
0
 public void SetStorageSpaceFolderAbeStatus(int storageSpaceFolderId, bool enabled)
 {
     StorageSpacesController.SetStorageSpaceFolderAbeStatus(storageSpaceFolderId, enabled);
 }
Exemplo n.º 13
0
 public bool GetStorageSpaceFolderAbeStatus(int storageSpaceFolderId)
 {
     return(StorageSpacesController.GetStorageSpaceFolderAbeStatus(storageSpaceFolderId));
 }
Exemplo n.º 14
0
 public void SetStorageSpaceFolderEncryptDataAccessStatus(int storageSpaceFolderId, bool enabled)
 {
     StorageSpacesController.SetStorageSpaceFolderEncryptDataAccessStatus(storageSpaceFolderId, enabled);
 }
Exemplo n.º 15
0
 public bool GetStorageSpaceFolderEncryptDataAccessStatus(int storageSpaceFolderId)
 {
     return(StorageSpacesController.GetStorageSpaceFolderEncryptDataAccessStatus(storageSpaceFolderId));
 }
Exemplo n.º 16
0
 public bool CheckIsStorageSpacePathInUse(int serverId, string path, int currentServiceId)
 {
     return(StorageSpacesController.CheckIsStorageSpacePathInUse(serverId, path, currentServiceId));
 }
Exemplo n.º 17
0
 public ResultObject RemoveStorageSpace(int id)
 {
     return(StorageSpacesController.RemoveStorageSpace(id));
 }
Exemplo n.º 18
0
 public SystemFile[] GetSystemSubFolders(int serviceId, string path)
 {
     return(StorageSpacesController.GetSystemSubFolders(serviceId, path));
 }
Exemplo n.º 19
0
 public IntResult SaveStorageSpace(StorageSpace space)
 {
     return(StorageSpacesController.SaveStorageSpace(space));
 }
Exemplo n.º 20
0
 public IntResult SaveStorageSpaceLevel(StorageSpaceLevel level, List <ResourceGroupInfo> groups)
 {
     return(StorageSpacesController.SaveStorageSpaceLevel(level, groups));
 }
Exemplo n.º 21
0
 public StorageSpacesPaged GetStorageSpacesPaged(string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
 {
     return(StorageSpacesController.GetStorageSpacesPaged(filterColumn, filterValue, sortColumn, startRow, maximumRows));
 }
Exemplo n.º 22
0
 public ResultObject SaveLevelResourceGroups(int levelId, List <ResourceGroupInfo> newGroups)
 {
     return(StorageSpacesController.SaveLevelResourceGroups(levelId, newGroups));
 }
Exemplo n.º 23
0
 public List <ResourceGroupInfo> GetLevelResourceGroups(int id)
 {
     return(StorageSpacesController.GetLevelResourceGroups(id));
 }
Exemplo n.º 24
0
 public List <StorageSpaceFolder> GetStorageSpaceFoldersByStorageSpaceId(int id)
 {
     return(StorageSpacesController.GetStorageSpaceFoldersByStorageSpaceId(id));
 }
Exemplo n.º 25
0
 public StorageSpace GetStorageSpaceById(int id)
 {
     return(StorageSpacesController.GetStorageSpaceById(id));
 }
Exemplo n.º 26
0
 public SystemFile[] GetDriveLetters(int serviceId)
 {
     return(StorageSpacesController.GetDriveLetters(serviceId));
 }