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; } diff --git a/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs b/IRaCIS.Core.Application/Service/Common/CommonDocumentService.cs index bc7db9531..0171c67c2 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, true, true, 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(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index 3533fb164..6e0e3fe84 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,6 +118,7 @@ namespace IRaCIS.Application.Contracts public class ExcelExportInfo : TrialSelectDTO { + public string CurrentTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); public bool IsEn_US { get; set; }