Exemplo n.º 1
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.º 2
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();
                }
            }
        }