cmove-测试
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2025-08-12 15:33:19 +08:00
parent 1bfe23f9ec
commit 3861e7642a
1 changed files with 48 additions and 39 deletions

View File

@ -3385,51 +3385,60 @@ namespace IRaCIS.Application.Services
var task = Task.Run(async () =>
{
var client = DicomClientFactory.Create(find.IP, find.Port, false, hirClient.CalledAE, find.CalledAE);
client.NegotiateAsyncOps();
try
{
var client = DicomClientFactory.Create(find.IP, find.Port, false, hirClient.CalledAE, find.CalledAE);
client.NegotiateAsyncOps();
var cmoveRequestList = new List<DicomCMoveRequest>();
var cmoveRequestList = new List<DicomCMoveRequest>();
foreach (var item in inCommand.StudyInstanceUIDList)
foreach (var item in inCommand.StudyInstanceUIDList)
{
var cmoveConfig = _basicSystemConfigConfig.CurrentValue;
var exsitStudyId = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.CmoveStudyId(item), null);
var latestInstance = latestInstanceList.Where(t => t.StudyInstanceUid == item).FirstOrDefault();
//缓存不存在当前检查或者instance表最新的记录时间与当前时间之差超过1分钟认为完成归档可以重复拉取
if (exsitStudyId == null && (latestInstance == null || latestInstance?.CreateTime.AddMinutes(cmoveConfig.CmoveInstanceIntervalMinutes) < DateTime.Now))
{
await _fusionCache.SetAsync(CacheKeys.CmoveStudyId(item), item, TimeSpan.FromMinutes(cmoveConfig.CmoveIntervalMinutes));
var cmoveRequest = new DicomCMoveRequest(hirServer.CalledAE, item);
cmoveRequest.OnResponseReceived += responseDelegate;
#region 测试私有tag 传输信息
var privateTag = new DicomTag(0x9999, 0x1001, "PRJGROUPS");
var groupIdsJson = (new List<string> { "KTGroup1", "KTGroup2" }).ToJson();
cmoveRequest.Dataset.Add(new DicomLongString(privateTag, groupIdsJson));
#endregion
cmoveRequestList.Add(cmoveRequest);
_logger.LogInformation($"执行C-Move StudyInstanceUID{item},携带课题组信息:{groupIdsJson}");
}
else
{
_logger.LogInformation($"忽略C-Move StudyInstanceUID{item}");
}
}
await client.AddRequestsAsync(cmoveRequestList);
await client.SendAsync();
}
catch (Exception ex)
{
var cmoveConfig = _basicSystemConfigConfig.CurrentValue;
var exsitStudyId = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.CmoveStudyId(item), null);
var latestInstance = latestInstanceList.Where(t => t.StudyInstanceUid == item).FirstOrDefault();
//缓存不存在当前检查或者instance表最新的记录时间与当前时间之差超过1分钟认为完成归档可以重复拉取
if (exsitStudyId == null && (latestInstance == null || latestInstance?.CreateTime.AddMinutes(cmoveConfig.CmoveInstanceIntervalMinutes) < DateTime.Now))
{
await _fusionCache.SetAsync(CacheKeys.CmoveStudyId(item), item, TimeSpan.FromMinutes(cmoveConfig.CmoveIntervalMinutes));
var cmoveRequest = new DicomCMoveRequest(hirServer.CalledAE, item);
cmoveRequest.OnResponseReceived += responseDelegate;
#region 测试私有tag 传输信息
var privateTag = new DicomTag(0x9999, 0x1001, "PRJGROUPS");
var groupIdsJson = (new List<string> { "KTGroup1", "KTGroup2" }).ToJson();
cmoveRequest.Dataset.Add(new DicomLongString(privateTag, groupIdsJson));
#endregion
cmoveRequestList.Add(cmoveRequest);
_logger.LogInformation($"执行C-Move StudyInstanceUID{item},携带课题组信息:{groupIdsJson}");
}
else
{
_logger.LogInformation($"忽略C-Move StudyInstanceUID{item}");
}
_logger.LogError($"cmove error{ex.Message}");
}
await client.AddRequestsAsync(cmoveRequestList);
await client.SendAsync();
});
//await task;