From 1ad4c16d23fc0465b35d0d3fc37914f3b15551d3 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 20 Dec 2023 14:00:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E6=B8=85=E7=90=86=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E6=96=87=E6=A1=A3,=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/CommonDocumentService.cs | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs index bc7db9531..185e1f6eb 100644 --- a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.Helper; +using IRaCIS.Application.Contracts; namespace IRaCIS.Core.Application.Service { @@ -99,14 +100,36 @@ namespace IRaCIS.Core.Application.Service //---读取模板内容失败, 请将文件另存为docx格式尝试! return ResponseOutput.NotOk(_localizer["Document_ TemplateRead"]); } - - } } - var entity = await _commonDocumentRepository.InsertOrUpdateAsync(addOrEditCommonDocument, true, verifyExp1, verifyExp2); + + if (addOrEditCommonDocument.Id == null) //insert + { - return ResponseOutput.Ok(entity.Id.ToString()); + + var entity = await _commonDocumentRepository.InsertFromDTOAsync(addOrEditCommonDocument, true, verifyExp1, verifyExp2); + + return ResponseOutput.Ok(entity.Id.ToString()); + } + else //update + { + + var dbbeforeEntity = await _commonDocumentRepository.UpdateFromDTOAsync(addOrEditCommonDocument, false, false, verifyExp1, verifyExp2); + + var filePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, dbbeforeEntity.Path); + + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + + return ResponseOutput.Ok(); + + } + + + } @@ -114,7 +137,20 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{commonDocumentId:guid}")] public async Task DeleteCommonDocument(Guid commonDocumentId) { + var find= await _commonDocumentRepository.FirstOrDefaultNoTrackingAsync(t=>t.Id== commonDocumentId); + var success = await _commonDocumentRepository.DeleteFromQueryAsync(t => t.Id == commonDocumentId, true,true); + + if (find != null) + { + var filePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, find.Path); + + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + } + return ResponseOutput.Ok(); } From 2a205a963433358deac72476773e1ca631384166 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 20 Dec 2023 14:17:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E8=A1=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/DTO/UserTrialViewModel.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index 3533fb164..aa5307d71 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs @@ -22,14 +22,14 @@ namespace IRaCIS.Application.Contracts [DictionaryTranslateAttribute("IsUserExitTrial")] public bool IsDeleted { get; set; } - [ExcelFormat("yyyy-MM-dd hh:mm:ss")] + [ExcelFormat("yyyy-MM-dd HH:mm:ss")] public DateTime? DeletedTime { get; set; } public Guid? SiteId { get; set; } public string Phone { get; set; } = String.Empty; public DateTime UpdateTime { get; set; } - [ExcelFormat("yyyy-MM-dd hh:mm:ss")] + [ExcelFormat("yyyy-MM-dd HH:mm:ss")] public DateTime CreateTime { get; set; } @@ -84,7 +84,7 @@ namespace IRaCIS.Application.Contracts [ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")] - [ExcelFormat("yyyy-MM-dd hh:mm:ss")] + [ExcelFormat("yyyy-MM-dd HH:mm:ss")] public DateTime CreateTime { get; set; } @@ -118,7 +118,8 @@ namespace IRaCIS.Application.Contracts public class ExcelExportInfo : TrialSelectDTO { - public string CurrentTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + [ExcelFormat("yyyy-MM-dd HH:mm:ss")] + public DateTime CurrentTime { get; set; } = DateTime.Now; public bool IsEn_US { get; set; } From 7110844c7ccc8ea0d7b719e40546f9118179475a Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 20 Dec 2023 14:32:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=88=A0=E9=99=A42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/CommonDocumentService.cs | 2 +- .../Service/TrialSiteUser/DTO/UserTrialViewModel.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs index 185e1f6eb..0171c67c2 100644 --- a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs @@ -115,7 +115,7 @@ namespace IRaCIS.Core.Application.Service else //update { - var dbbeforeEntity = await _commonDocumentRepository.UpdateFromDTOAsync(addOrEditCommonDocument, false, false, verifyExp1, verifyExp2); + var dbbeforeEntity = await _commonDocumentRepository.UpdateFromDTOAsync(addOrEditCommonDocument, true, true, verifyExp1, verifyExp2); var filePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, dbbeforeEntity.Path); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index aa5307d71..6e0e3fe84 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs @@ -118,8 +118,8 @@ namespace IRaCIS.Application.Contracts public class ExcelExportInfo : TrialSelectDTO { - [ExcelFormat("yyyy-MM-dd HH:mm:ss")] - public DateTime CurrentTime { get; set; } = DateTime.Now; + + public string CurrentTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); public bool IsEn_US { get; set; } From a05c3725e7e55eaf821f419cee41fd541ed4d157 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 20 Dec 2023 14:40:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E5=BE=84bug=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Helper/FileStoreHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs index eae219e62..0b4b541dc 100644 --- a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs @@ -78,7 +78,7 @@ public static class FileStoreHelper { var rootPath = GetIRaCISRootPath(_hostEnvironment); - var physicalFilePath = Path.Combine(rootPath, relativePath.Trim('/')); + var physicalFilePath = Path.Combine(rootPath, relativePath); return physicalFilePath; }