@@ -24,39 +24,7 @@ using IRaCIS.Core.Infrastructure;
|
||||
|
||||
namespace IRaCIS.Core.SCP.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 后台托管服务的方式运行
|
||||
/// </summary>
|
||||
//public class CStoreSCPHostedService : IHostedService
|
||||
//{
|
||||
// private readonly ILogger<CStoreSCPHostedService> _logger;
|
||||
// private readonly IDicomServerFactory _dicomServerFactory;
|
||||
// private IDicomServer? _server;
|
||||
|
||||
// public CStoreSCPHostedService(ILogger<CStoreSCPHostedService> logger, IDicomServerFactory dicomServerFactory)
|
||||
// {
|
||||
// _logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
// _dicomServerFactory = dicomServerFactory ?? throw new ArgumentNullException(nameof(dicomServerFactory));
|
||||
// }
|
||||
|
||||
// public async Task StartAsync(CancellationToken cancellationToken)
|
||||
// {
|
||||
// _logger.LogInformation("Starting DICOM server");
|
||||
// _server = _dicomServerFactory.Create<CStoreSCPService>(104);
|
||||
// _logger.LogInformation("DICOM server is running");
|
||||
// }
|
||||
|
||||
// public Task StopAsync(CancellationToken cancellationToken)
|
||||
// {
|
||||
// if (_server != null)
|
||||
// {
|
||||
// _server.Stop();
|
||||
// _server.Dispose();
|
||||
// _server = null;
|
||||
// }
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//}
|
||||
public class DicomSCPServiceOption
|
||||
{
|
||||
public List<string> CalledAEList { get; set; }
|
||||
@@ -75,6 +43,11 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
private SCPImageUpload _upload { get; set; }
|
||||
|
||||
private Guid _trialId { get; set; }
|
||||
|
||||
private Guid _trialSiteId { get; set; }
|
||||
|
||||
|
||||
|
||||
private static readonly DicomTransferSyntax[] _acceptedTransferSyntaxes = new DicomTransferSyntax[]
|
||||
{
|
||||
@@ -121,15 +94,37 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
_serviceProvider = (IServiceProvider)this.UserState;
|
||||
|
||||
var option = _serviceProvider.GetService<IOptionsMonitor<DicomSCPServiceOption>>().CurrentValue;
|
||||
|
||||
|
||||
var _trialDicomAERepository = _serviceProvider.GetService<IRepository<TrialDicomAE>>();
|
||||
|
||||
var calledAEList = option.CalledAEList;
|
||||
|
||||
if (!calledAEList.Contains(association.CalledAE))
|
||||
var trialDicomAEList = _trialDicomAERepository.Select(t => new { t.CalledAE, t.TrialId }).ToList();
|
||||
var trialCalledAEList = trialDicomAEList.Select(t => t.CalledAE).ToList();
|
||||
|
||||
//if (association.CalledAE != "STORESCP")
|
||||
var findCalledAE = trialDicomAEList.Where(t => t.CalledAE == association.CalledAE).FirstOrDefault();
|
||||
|
||||
var isCanReceiveIamge = false;
|
||||
|
||||
if (findCalledAE!=null)
|
||||
{
|
||||
_trialId = findCalledAE.TrialId;
|
||||
|
||||
var _trialSiteDicomAERepository = _serviceProvider.GetService<IRepository<TrialSiteDicomAE>>();
|
||||
|
||||
|
||||
var findTrialSiteAE = _trialSiteDicomAERepository.Where(t=>t.CallingAE==association.CallingAE ).FirstOrDefault();
|
||||
|
||||
if (findTrialSiteAE!=null)
|
||||
{
|
||||
_trialSiteId= findTrialSiteAE.TrialSiteId;
|
||||
|
||||
isCanReceiveIamge = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!trialCalledAEList.Contains(association.CalledAE) || isCanReceiveIamge==false)
|
||||
{
|
||||
|
||||
Log.Logger.Warning($"拒绝CalledAE:{association.CalledAE}的连接");
|
||||
@@ -152,6 +147,8 @@ namespace IRaCIS.Core.SCP.Service
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return SendAssociationAcceptAsync(association);
|
||||
}
|
||||
|
||||
@@ -167,7 +164,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
_upload.EndTime = DateTime.Now;
|
||||
_upload.StudyCount = _SCPStudyIdList.Count;
|
||||
|
||||
await _SCPImageUploadRepository.AddAsync(_upload,true);
|
||||
await _SCPImageUploadRepository.AddAsync(_upload, true);
|
||||
|
||||
await SendAssociationReleaseResponseAsync();
|
||||
}
|
||||
@@ -175,11 +172,9 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
private async Task DataMaintenanceAsaync()
|
||||
{
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE}传输结束:开始维护数据,处理检查Modality 以及自动创建访视,绑定检查");
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE}传输结束:开始维护数据,处理检查Modality");
|
||||
|
||||
//var patientStudyService = _serviceProvider.GetService<IPatientStudyService>();
|
||||
|
||||
//await patientStudyService.AutoBindingPatientStudyVisitAsync(_SCPStudyIdList);
|
||||
|
||||
//处理检查Modality
|
||||
var _dictionaryRepository = _serviceProvider.GetService<IRepository<Dictionary>>();
|
||||
@@ -262,7 +257,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
var _distributedLockProvider = _serviceProvider.GetService<IDistributedLockProvider>();
|
||||
|
||||
var storeRelativePath = string.Empty;
|
||||
var ossFolderPath = $"Dicom/{studyInstanceUid}";
|
||||
var ossFolderPath = $"{_trialId}/Image/PACS/{_trialSiteId}{studyInstanceUid}";
|
||||
|
||||
|
||||
long fileSize = 0;
|
||||
@@ -295,7 +290,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
{
|
||||
try
|
||||
{
|
||||
var scpStudyId = await dicomArchiveService.ArchiveDicomFileAsync(request.Dataset, storeRelativePath, Association.CallingAE, Association.CalledAE);
|
||||
var scpStudyId = await dicomArchiveService.ArchiveDicomFileAsync(request.Dataset,_trialId,_trialSiteId, storeRelativePath, Association.CallingAE, Association.CalledAE);
|
||||
|
||||
if (!_SCPStudyIdList.Contains(scpStudyId))
|
||||
{
|
||||
@@ -324,11 +319,6 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
series.ImageResizePath = seriesPath;
|
||||
|
||||
|
||||
|
||||
//await _seriesRepository.BatchUpdateNoTrackingAsync(t => t.Id == seriesId, u => new SCPSeries() { ImageResizePath = seriesPath });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +337,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||
|
||||
//监控信息设置
|
||||
_upload.FileCount++;
|
||||
_upload.FileSize= _upload.FileSize+ fileSize;
|
||||
_upload.FileSize = _upload.FileSize + fileSize;
|
||||
return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user