上传 心跳包处理

Uat_Study
hang 2023-05-16 10:32:53 +08:00
parent 43ef5bcdd9
commit 8875595012
2 changed files with 172 additions and 127 deletions

View File

@ -178,6 +178,8 @@ namespace IRaCIS.Core.Application.Contracts
public class PreArchiveDicomStudyCommand
{
//public string StudyInstanceUid { get; set; }
[NotDefault]
public Guid TrialId { get; set; }
[NotDefault]

View File

@ -21,7 +21,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
[ApiExplorerSettings(GroupName = "Image")]
public class StudyService : BaseService, IStudyService
{
private static object lockCodeGenerate = new object();
private static object lockObj = new object();
private static readonly AsyncLock _mutex = new AsyncLock();
private static readonly AsyncLock _mutex2 = new AsyncLock();
@ -93,8 +93,18 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
public async Task<IResponseOutput> PreArchiveDicomStudy(PreArchiveDicomStudyCommand preArchiveStudyCommand)
{
//lock (lockObj)
//{
// if (_provider.Exists($"StudyUid_{preArchiveStudyCommand.TrialId}_{preArchiveStudyCommand.StudyInstanceUid}"))
// {
// //---当前已有人正在上传和归档该检查!
// return ResponseOutput.NotOk(StaticData.International("UploadDownLoad_ArchiveInProgress"));
// }
// else
// {
// _provider.Set($"StudyUid_{preArchiveStudyCommand.TrialId}_{preArchiveStudyCommand.StudyInstanceUid}", _userInfo.Id, TimeSpan.FromSeconds(30));
// }
//}
var studyMonitor = new StudyMonitor()
{
@ -111,7 +121,6 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
IsDicomReUpload = preArchiveStudyCommand.IsDicomReUpload,
FileSize = preArchiveStudyCommand.FileSize,
FileCount = preArchiveStudyCommand.FileCount,
//FailedFileCount = preArchiveStudyCommand.FailedFileCount,
};
@ -123,9 +132,20 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
}
public IResponseOutput DicomUploadInprogress(Guid trialId, string studyInstanceUid)
{
_provider.Set($"StudyUid_{trialId}_{studyInstanceUid}", _userInfo.Id, TimeSpan.FromSeconds(30));
return ResponseOutput.Ok();
}
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
public async Task<IResponseOutput> AddOrUpdateArchiveStudy(NewArchiveStudyCommand incommand)
{
try
{
var trialId = incommand.TrialId;
@ -289,7 +309,20 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
{
await _dicomInstanceRepository.SaveChangesAsync();
}
}
catch (Exception ex)
{
return ResponseOutput.NotOk(ex.Message);
}
finally
{
_provider.Remove($"StudyUid_{incommand.TrialId}_{incommand.Study.StudyInstanceUid}");
}
@ -729,7 +762,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
var result = new VerifyStudyUploadResult();
if (_provider.Exists("StudyUid_" + studyInstanceUid))
if (_provider.Exists($"StudyUid_{trialId}_{studyInstanceUid}"))
{
result.AllowUpload = false;
@ -790,6 +823,16 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
}
}
result.StudyInstanceUid = studyInstanceUid;
if (result.AllowReUpload || result.AllowUpload)
{
lock (lockObj)
{
_provider.Set($"StudyUid_{trialId}_{studyInstanceUid}", _userInfo.Id, TimeSpan.FromMinutes(30));
}
}
return result;
}