This commit is contained in:
2022-08-05 13:05:51 +08:00
parent d0856021db
commit 412ca21ba2
6 changed files with 61 additions and 13 deletions
@@ -24,6 +24,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.EntityFrameworkCore;
@@ -130,7 +131,7 @@ namespace IRaCIS.Core.API.Controllers
/// <summary> 流式上传 Dicom上传 </summary>
[Route("base")]
public virtual async Task<int> DicomFileUploadAsync(Func<string, Stream, Task> filePathFunc)
public virtual async Task<int> DicomFileUploadAsync(Func<string, Stream, int, Task> filePathFunc)
{
var fileCount = 0;
@@ -163,7 +164,7 @@ namespace IRaCIS.Core.API.Controllers
{
++fileCount;
await filePathFunc(entry.Key, entry.OpenEntryStream());
await filePathFunc(entry.Key, entry.OpenEntryStream(), fileCount);
}
}
}
@@ -174,7 +175,7 @@ namespace IRaCIS.Core.API.Controllers
{
++fileCount;
await filePathFunc(fileName, section.Body);
await filePathFunc(fileName, section.Body, fileCount);
}
}
@@ -224,12 +225,12 @@ namespace IRaCIS.Core.API.Controllers
[DisableRequestSizeLimit]
[TypeFilter(typeof(TrialResourceFilter))]
public async Task<IResponseOutput> ArchiveStudyNew([FromForm] ArchiveStudyCommand archiveStudyCommand,
[FromServices] ILogger<UploadDownLoadController> _logger,
[FromServices] ILogger<UploadDownLoadController> _logger,
[FromServices] IEasyCachingProvider _provider,
[FromServices] IStudyService _studyService,
[FromServices] IDicomArchiveService _dicomArchiveService,
[FromServices] IRepository _repository
[FromServices] IStudyService _studyService,
[FromServices] IHubContext<UploadHub, IUploadClient> _uploadHub,
[FromServices] IDicomArchiveService _dicomArchiveService,
[FromServices] IRepository _repository
)
{
@@ -261,7 +262,7 @@ namespace IRaCIS.Core.API.Controllers
var savedInfo = _studyService.GetSaveToDicomInfo(archiveStudyCommand.SubjectVisitId);
archiveResult.ReceivedFileCount = await DicomFileUploadAsync(async (fileName, fileStream) =>
archiveResult.ReceivedFileCount = await DicomFileUploadAsync(async (fileName, fileStream, receivedCount) =>
{
try
@@ -280,6 +281,7 @@ namespace IRaCIS.Core.API.Controllers
}
}
await _uploadHub.Clients.All.ReceivProgressAsync(archiveStudyCommand.StudyInstanceUid, receivedCount);
}
catch (Exception e)
@@ -337,7 +339,6 @@ namespace IRaCIS.Core.API.Controllers
else
{
studyMonitor.IsSuccess = false;
studyMonitor.UploadFinishedTime = DateTime.Now;
studyMonitor.Note= JsonConvert.SerializeObject(archiveResult);
_provider.Remove("StudyUid_" + archiveStudyCommand.StudyInstanceUid);