修改验证 和测试
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2024-12-19 14:30:14 +08:00
parent 5f338de0cd
commit 88669ccbff
2 changed files with 47 additions and 18 deletions

View File

@ -50,7 +50,7 @@ namespace IRaCIS.Core.Application.Service
{
var verifyExp1 = new EntityVerifyExp<DicomAE>()
{
VerifyExp = u => u.IP == addOrEditDicomAE.IP && u.Port == addOrEditDicomAE.Port,
VerifyExp = u => u.IP == addOrEditDicomAE.IP && u.Port == addOrEditDicomAE.Port && u.PacsTypeEnum==addOrEditDicomAE.PacsTypeEnum,
VerifyMsg = "不允许添加相同的IP和端口的记录"
};
@ -96,24 +96,36 @@ namespace IRaCIS.Core.Application.Service
client.NegotiateAsyncOps();
await client.AddRequestAsync(new DicomCEchoRequest());
client.ServiceOptions.RequestTimeout = TimeSpan.FromSeconds(5);
// 创建一个超时任务设置超时时间为1秒
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(3));
// 发送 DICOM 请求
var sendTask = client.SendAsync();
// 等待任务完成,若超时任务先完成则抛出超时异常
if (await Task.WhenAny(sendTask, timeoutTask) == timeoutTask)
var request = new DicomCEchoRequest
{
throw new TimeoutException("DICOM 请求超时。");
}
OnResponseReceived = (req, response) =>
{
Console.WriteLine($"C-ECHO Response: {response.Status}");
if (response.Status == DicomStatus.Success)
{
find.IsTestOK = true;
}
else
{
find.IsTestOK = false;
}
}
};
await client.AddRequestAsync(request);
await client.SendAsync();
find.IsTestOK = true;
await _dicomAERepository.SaveChangesAsync();
return true;
return find.IsTestOK;
}
catch (Exception ex)
{

View File

@ -47,6 +47,7 @@ using Microsoft.Extensions.Logging;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
using DocumentFormat.OpenXml.Vml.Office;
namespace IRaCIS.Application.Services
@ -62,7 +63,7 @@ namespace IRaCIS.Application.Services
IRepository<SubejctVisitDownload> _subejctVisitDownloadRepository,
IRepository<SCPImageUpload> _SCPImageUploadRepository,
IRepository<User> _userRepository,
ILogger<PatientService> _logger,
IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IWebHostEnvironment _hostEnvironment, IStringLocalizer _localizer
@ -2976,9 +2977,9 @@ namespace IRaCIS.Application.Services
TimeOnly timePart = TimeOnly.FromDateTime(studyTime);
var canParce = DateTime.TryParseExact(response.Dataset?.GetSingleValueOrDefault<string>(DicomTag.PatientBirthDate, ""), "yyyyMMdd", null, System.Globalization.DateTimeStyles.None, out DateTime birthDate);
// 格式化为你需要的日期格式例如yyyy-MM-dd
string formattedBirthDate = canParce? birthDate.ToString("yyyy-MM-dd"):string.Empty;
string formattedBirthDate = canParce ? birthDate.ToString("yyyy-MM-dd") : string.Empty;
result.Add(new SCUStudyView()
@ -3102,6 +3103,14 @@ namespace IRaCIS.Application.Services
if (find != null)
{
DicomCMoveRequest.ResponseDelegate responseDelegate = (req, response) =>
{
if(response.Status.State == DicomState.Failure)
{
_logger.LogError($" {response.SOPClassUID.ToJsonNotIgnoreNull()}");
}
};
var task = Task.Run(async () =>
{
@ -3112,13 +3121,21 @@ namespace IRaCIS.Application.Services
foreach (var item in inCommand.StudyInstanceUIDList)
{
cmoveRequestList.Add(new DicomCMoveRequest(hirServer.CalledAE, item));
var cmoveRequest = new DicomCMoveRequest(hirServer.CalledAE, item);
cmoveRequest.OnResponseReceived += responseDelegate;
cmoveRequestList.Add(cmoveRequest);
}
await client.AddRequestsAsync(cmoveRequestList);
await client.SendAsync();
});
//await task;
}
return ResponseOutput.Ok();