コード例 #1
0
        private ICollection <MultipleOperationsResult> ProcessUploadedFiles(MultipleOperationsResult uploadResult)
        {
            var parsingResults = new ConcurrentBag <MultipleOperationsResult>();

            Parallel.ForEach(
                uploadResult.SuccessfulOperations,
                file => ParseUploadResultFile(file, parsingResults));

            return(parsingResults.ToList());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public async Task <ICollection <MultipleOperationsResult> > ProcessUploadedFilesAsync(MultipleOperationsResult uploadResult)
        {
            var res = await Task.Run(() => ProcessUploadedFiles(uploadResult));

            return(res);
        }