private ICollection <MultipleOperationsResult> ProcessUploadedFiles(MultipleOperationsResult uploadResult) { var parsingResults = new ConcurrentBag <MultipleOperationsResult>(); Parallel.ForEach( uploadResult.SuccessfulOperations, file => ParseUploadResultFile(file, parsingResults)); return(parsingResults.ToList()); }
public async Task <MultipleOperationsResult> UploadFilesAsync(HttpContent content, HttpContext httpContext) { _userUploadsPath = new Lazy <string>(() => _directoryInfoProvider.GetUserUploadsPath(httpContext)); var provider = new MultipartMemoryStreamProvider(); await content.ReadAsMultipartAsync(provider); var uploadOperationResult = new MultipleOperationsResult(); provider.Contents.ForEach(async fileHttpContent => { var res = await TryProcesFileAsync(fileHttpContent); uploadOperationResult.AddFileResult(res); }); return(uploadOperationResult); }
public async Task <ICollection <MultipleOperationsResult> > ProcessUploadedFilesAsync(MultipleOperationsResult uploadResult) { var res = await Task.Run(() => ProcessUploadedFiles(uploadResult)); return(res); }