From 63e2ca07b5dac80b977ade4339acd7b7ccac78b6 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 9 Aug 2024 15:01:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9dicomAE=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrialSiteUser/DTO/DicomAEViewModel.cs | 9 +++ .../TrialSiteUser/TrialDicomAEService.cs | 76 ++++++++----------- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs index 50cc7d550..2d1020723 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs @@ -61,6 +61,15 @@ namespace IRaCIS.Core.Application.ViewModel public bool IsPACSConnect { get; set; } + + public bool IsTestOK { get; set; } + } + + public class TestAECommand + { + public string CalledAE { get; set; } = string.Empty; + public string IP { get; set; } = string.Empty; + public int Port { get; set; } } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialDicomAEService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialDicomAEService.cs index a29e92960..9c59315b4 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialDicomAEService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialDicomAEService.cs @@ -12,6 +12,7 @@ using FellowOakDicom.Network.Client; using FellowOakDicom.Network; using IRaCIS.Application.Contracts; using IRaCIS.Core.Domain.Share; +using DocumentFormat.OpenXml.InkML; namespace IRaCIS.Core.Application.Service { /// @@ -84,6 +85,14 @@ namespace IRaCIS.Core.Application.Service VerifyMsg = _localizer["TrialDicomAE_RepeatCalledAE"] }; + var verifyExp3 = new EntityVerifyExp() + { + VerifyExp = u => u.TrialId == addOrEditDicomAE.TrialId, + + //"AE名称不能与其他项目相同" + VerifyMsg = "该项目只允许添加一条dicom AE记录(前端对接有bug时出现)" + }; + //var verifyExp2 = new EntityVerifyExp() //{ // VerifyExp = u => u.TrialId == addOrEditDicomAE.TrialId, @@ -98,7 +107,7 @@ namespace IRaCIS.Core.Application.Service if (addOrEditDicomAE.IsPACSConnect) { // 在此处拷贝automapper 映射 - var entity = await _dicomAERepository.InsertOrUpdateAsync(addOrEditDicomAE, true, verifyExp1, verifyExp2); + var entity = await _dicomAERepository.InsertOrUpdateAsync(addOrEditDicomAE, true, verifyExp3, verifyExp1, verifyExp2); return ResponseOutput.Ok(entity.Id.ToString()); } @@ -123,54 +132,33 @@ namespace IRaCIS.Core.Application.Service /// 测试scp server 是否可以连接 /// /// - [HttpGet("{dicomAEId:guid}")] - public async Task TestSCPServerConnect(Guid dicomAEId) + [HttpPost] + public async Task TestSCPServerConnect(TestAECommand inCommand) { - var find = await _dicomAERepository.FirstOrDefaultAsync(t => t.Id == dicomAEId); - - if (find == null) + try { + var client = DicomClientFactory.Create(inCommand.IP, inCommand.Port, false, "test-callingAE", inCommand.CalledAE); - return false; + client.NegotiateAsyncOps(); + + await client.AddRequestAsync(new DicomCEchoRequest()); + + // 创建一个超时任务,设置超时时间为1秒 + var timeoutTask = Task.Delay(TimeSpan.FromSeconds(3)); + + // 发送 DICOM 请求 + var sendTask = client.SendAsync(); + + // 等待任务完成,若超时任务先完成则抛出超时异常 + if (await Task.WhenAny(sendTask, timeoutTask) == timeoutTask) + { + throw new TimeoutException("DICOM 请求超时。"); + } + return true; } - else + catch (Exception ex) { - find.LatestTestTime = DateTime.Now; - - try - { - var client = DicomClientFactory.Create(find.IP, find.Port, false, "test-callingAE", find.CalledAE); - - client.NegotiateAsyncOps(); - - await client.AddRequestAsync(new DicomCEchoRequest()); - - // 创建一个超时任务,设置超时时间为1秒 - var timeoutTask = Task.Delay(TimeSpan.FromSeconds(3)); - - // 发送 DICOM 请求 - var sendTask = client.SendAsync(); - - // 等待任务完成,若超时任务先完成则抛出超时异常 - if (await Task.WhenAny(sendTask, timeoutTask) == timeoutTask) - { - throw new TimeoutException("DICOM 请求超时。"); - } - - - find.IsTestOK = true; - - await _dicomAERepository.SaveChangesAsync(); - - return true; - } - catch (Exception ex) - { - find.IsTestOK = false; - await _dicomAERepository.SaveChangesAsync(); - - return false; - } + return false; } From d62562149cb95e5ecde8c7c1a5c93f99c6198e1c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 9 Aug 2024 15:24:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9dicomAE=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 2 +- .../TrialSiteUser/DTO/DicomAEViewModel.cs | 3 +-- IRaCIS.Core.Application/TestService.cs | 27 +++++++++++++++++++ IRaCIS.Core.Domain/Image/TrialDicomAE.cs | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 2b89f02a7..7f17ce6ef 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -9920,7 +9920,7 @@ - + 测试scp server 是否可以连接 diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs index 2d1020723..cd9cbd134 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/DicomAEViewModel.cs @@ -19,7 +19,6 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime? LatestTestTime { get; set; } - public bool IsTestOK { get; set; } //public bool IsPACSConnect { get; set; } @@ -62,7 +61,7 @@ namespace IRaCIS.Core.Application.ViewModel public bool IsPACSConnect { get; set; } - public bool IsTestOK { get; set; } + public bool? IsTestOK { get; set; } } public class TestAECommand diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index b0dd183e8..dd7aa1031 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -24,6 +24,7 @@ using System.Linq.Expressions; using System.Reflection.Metadata; using System.Text; using System.Text.RegularExpressions; +using Xceed.Words.NET; namespace IRaCIS.Application.Services @@ -204,6 +205,32 @@ namespace IRaCIS.Application.Services public async Task testEmail([FromServices] IWebHostEnvironment env ,string email) { + //using (DocX document = DocX.Load("C:\\Users\\hang\\Desktop\\")) + //{ + // // 查找书签对应的段落 + // var bookmark = document.Bookmarks.FirstOrDefault(b => b.Name == bookmarkName); + + // if (bookmark != null) + // { + // // 获取书签所在的段落位置 + // int paragraphIndex = document.Paragraphs.IndexOf(bookmark.Paragraph); + + // // 如果书签所在的段落在文档中 + // if (paragraphIndex >= 0) + // { + // // 删除书签所在的段落 + // document.RemoveParagraphAt(paragraphIndex); + // } + + // // 删除书签(只删除书签标记,不删除内容) + // document.Bookmarks.Remove(bookmark); + // } + + // // 保存修改 + // document.Save(); + //} + + var hiddenEmail = EmailMaskHelper.MaskEmail(email); return hiddenEmail; diff --git a/IRaCIS.Core.Domain/Image/TrialDicomAE.cs b/IRaCIS.Core.Domain/Image/TrialDicomAE.cs index 0d91a9c77..3a1f963ab 100644 --- a/IRaCIS.Core.Domain/Image/TrialDicomAE.cs +++ b/IRaCIS.Core.Domain/Image/TrialDicomAE.cs @@ -45,7 +45,7 @@ namespace IRaCIS.Core.Domain.Models public DateTime? LatestTestTime { get; set; } - public bool IsTestOK { get; set; } + public bool? IsTestOK { get; set; } }