public ItemList <FileOperationResult> Download(Dictionary <object, string> folders, Dictionary <object, string> files, Dictionary <string, string> headers)
        {
            var operations = tasks.GetTasks()
                             .Where(t => t.GetProperty <Guid>(FileOperation.OWNER) == SecurityContext.CurrentAccount.ID)
                             .Where(t => t.GetProperty <FileOperationType>(FileOperation.OPERATION_TYPE) == FileOperationType.Download);

            if (operations.Any(o => o.Status <= DistributedTaskStatus.Running))
            {
                throw new InvalidOperationException(FilesCommonResource.ErrorMassage_ManyDownloads);
            }

            var op = new FileDownloadOperation(folders, files, headers);

            return(QueueTask(op));
        }
Esempio n. 2
0
        public ItemList <FileOperationResult> Download(Guid userId, Tenant tenant, Dictionary <JsonElement, string> folders, Dictionary <JsonElement, string> files, IDictionary <string, StringValues> headers)
        {
            var operations = tasks.GetTasks()
                             .Where(t => t.GetProperty <Guid>(FileOperation.OWNER) == userId)
                             .Where(t => t.GetProperty <FileOperationType>(FileOperation.OPERATION_TYPE) == FileOperationType.Download);

            if (operations.Any(o => o.Status <= DistributedTaskStatus.Running))
            {
                throw new InvalidOperationException(FilesCommonResource.ErrorMassage_ManyDownloads);
            }

            var op1 = new FileDownloadOperation <int>(ServiceProvider, new FileDownloadOperationData <int>(folders.Where(r => r.Key.ValueKind == JsonValueKind.Number).ToDictionary(r => r.Key.GetInt32(), r => r.Value), files.Where(r => r.Key.ValueKind == JsonValueKind.Number).ToDictionary(r => r.Key.GetInt32(), r => r.Value), tenant, headers), false);
            var op2 = new FileDownloadOperation <string>(ServiceProvider, new FileDownloadOperationData <string>(folders.Where(r => r.Key.ValueKind == JsonValueKind.String).ToDictionary(r => r.Key.GetString(), r => r.Value), files.Where(r => r.Key.ValueKind == JsonValueKind.String).ToDictionary(r => r.Key.GetString(), r => r.Value), tenant, headers), false);
            var op  = new FileDownloadOperation(ServiceProvider, op2, op1);

            return(QueueTask(userId, op));
        }
Esempio n. 3
0
        public ItemList <FileOperationResult> Download(AuthContext authContext, TenantManager tenantManager, Dictionary <object, string> folders, Dictionary <object, string> files, Dictionary <string, string> headers)
        {
            var operations = tasks.GetTasks()
                             .Where(t => t.GetProperty <Guid>(FileOperation.OWNER) == authContext.CurrentAccount.ID)
                             .Where(t => t.GetProperty <FileOperationType>(FileOperation.OPERATION_TYPE) == FileOperationType.Download);

            if (operations.Any(o => o.Status <= DistributedTaskStatus.Running))
            {
                throw new InvalidOperationException(FilesCommonResource.ErrorMassage_ManyDownloads);
            }

            var tenant = tenantManager.GetCurrentTenant();
            var op1    = new FileDownloadOperation <int>(ServiceProvider, new FileDownloadOperationData <int>(folders.Where(r => r.Key is long).ToDictionary(r => Convert.ToInt32(r.Key), r => r.Value), files.Where(r => r.Key is long).ToDictionary(r => Convert.ToInt32(r.Key), r => r.Value), tenant, headers), false);
            var op2    = new FileDownloadOperation <string>(ServiceProvider, new FileDownloadOperationData <string>(folders.Where(r => r.Key is string).ToDictionary(r => r.Key.ToString(), r => r.Value), files.Where(r => r.Key is string).ToDictionary(r => r.Key.ToString(), r => r.Value), tenant, headers), false);
            var op     = new FileDownloadOperation(ServiceProvider, op2, op1);

            return(QueueTask(authContext, op));
        }
Esempio n. 4
0
        public List <FileOperationResult> Download(Guid userId, Tenant tenant, Dictionary <JsonElement, string> folders, Dictionary <JsonElement, string> files, IDictionary <string, StringValues> headers)
        {
            var operations = tasks.GetTasks()
                             .Where(t => t.GetProperty <Guid>(FileOperation.OWNER) == userId)
                             .Where(t => t.GetProperty <FileOperationType>(FileOperation.OPERATION_TYPE) == FileOperationType.Download);

            if (operations.Any(o => o.Status <= DistributedTaskStatus.Running))
            {
                throw new InvalidOperationException(FilesCommonResource.ErrorMassage_ManyDownloads);
            }

            var(folderIntIds, folderStringIds) = GetIds(folders);
            var(fileIntIds, fileStringIds)     = GetIds(files);

            var op1 = new FileDownloadOperation <int>(ServiceProvider, new FileDownloadOperationData <int>(folderIntIds, fileIntIds, tenant, headers));
            var op2 = new FileDownloadOperation <string>(ServiceProvider, new FileDownloadOperationData <string>(folderStringIds, fileStringIds, tenant, headers));
            var op  = new FileDownloadOperation(ServiceProvider, TempStream, op2, op1);

            return(QueueTask(userId, op));
        }