diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index ef25fb5f..aba484f9 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1,7 +1,6 @@ using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Requests.Commands; using BMA.EHR.Application.Responses; -using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Commands.Core; using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Organizations; @@ -48,7 +47,7 @@ namespace BMA.EHR.Application.Repositories.Commands case "C-PM-01": case "C-PM-02": case "C-PM-03": - result = await GetReceiver01(command); + result = await GetReceiver01Async(command); break; default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement); } @@ -61,7 +60,7 @@ namespace BMA.EHR.Application.Repositories.Commands /// /// /// - private async Task> GetReceiver01(Command command) + private async Task> GetReceiver01Async(Command command) { try { @@ -120,6 +119,32 @@ namespace BMA.EHR.Application.Repositories.Commands #region " Execute and Deploy " + private async Task ExecuteCommandByTypeAsync(Command command) + { + switch (command.CommandType.CommandCode.Trim().ToUpper()) + { + case "C-PM-01": + case "C-PM-02": + case "C-PM-03": + await ExecuteCommand01Async(command); + break; + default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement); + } + + } + + private async Task ExecuteCommand01Async(Command command) + { + try + { + + } + catch + { + throw; + } + } + #endregion @@ -579,17 +604,21 @@ namespace BMA.EHR.Application.Repositories.Commands { try { - var command = await _dbContext.Set().Include(x => x.Documents).FirstOrDefaultAsync(c => c.Id == id); + var command = await _dbContext.Set() + .Include(x => x.Documents) + //.ThenInclude(x =>x.Document) + .FirstOrDefaultAsync(c => c.Id == id); + if (command == null) throw new Exception(GlobalMessages.CommandNotFound); // insert new record to comand Document - var exist = command.Documents.Where(x => x.Category == category).ToList(); - if (exist.Any()) - { - _dbContext.Set().RemoveRange(exist); - await _dbContext.SaveChangesAsync(); - } + //var exist = command.Documents.Where(x => x.Category == category).ToList(); + //if (exist.Any()) + //{ + // _dbContext.Set().RemoveRange(exist); + // await _dbContext.SaveChangesAsync(); + //} // insert new Record command.Documents.Add(document); diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 4ef88b96..d79f015c 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -601,7 +601,7 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> SaveCommandSelectReceiverAsync(Guid orderId,[FromBody] List selected) + public async Task> SaveCommandSelectReceiverAsync(Guid orderId, [FromBody] List selected) { try { @@ -853,8 +853,8 @@ namespace BMA.EHR.Command.Service.Controllers orderNo = command.CommandNo, orderYear = command.CommandYear, signDate = command.CommandExcecuteDate, - orderFileUrl = cover == null ? null : _documentService.ImagesPath(cover.Document.ObjectRefId), - attachmentFileUrl = attach == null ? null : _documentService.ImagesPath(attach.Document.ObjectRefId), + orderFileUrl = cover == null ? null : await _documentService.ImagesPath(cover.Document.Id), + attachmentFileUrl = attach == null ? null : await _documentService.ImagesPath(attach.Document.Id), }; return Success(result); @@ -875,6 +875,16 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("attachment/order-file/{orderId}"), DisableRequestSizeLimit] + [Consumes("multipart/form-data")] + [SwaggerOperation( + Summary = "Upload a file", + Description = "Upload a file using multipart/form-data", + OperationId = "UploadCommandCoverAsync" + //Tags = new[] { "File" } + )] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> UploadCommandCoverAsync(Guid orderId) { try @@ -893,7 +903,7 @@ namespace BMA.EHR.Command.Service.Controllers // delete exist document from s3 foreach (var doc in docs) { - await _documentService.DeleteFileAsync(doc.Document.ObjectRefId); + await _documentService.DeleteFileAsync(doc.Document.Id); } // upload new document to s3 @@ -926,6 +936,16 @@ namespace BMA.EHR.Command.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpPost("attachment/file/{orderId}"), DisableRequestSizeLimit] + [Consumes("multipart/form-data")] + [SwaggerOperation( + Summary = "Upload a file", + Description = "Upload a file using multipart/form-data", + OperationId = "UploadCommandAttachmentAsync" + //Tags = new[] { "File" } + )] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> UploadCommandAttachmentAsync(Guid orderId) { try @@ -942,9 +962,10 @@ namespace BMA.EHR.Command.Service.Controllers var docs = await _repository.GetExistDocument(orderId, GlobalConstants.TYPE_ATTACHMENT); // delete exist document from s3 + foreach (var doc in docs) { - await _documentService.DeleteFileAsync(doc.Document.ObjectRefId); + await _documentService.DeleteFileAsync(doc.Document.Id); } // upload new document to s3 diff --git a/BMA.EHR.Command.Service/appsettings.json b/BMA.EHR.Command.Service/appsettings.json index 254ef302..c8cd1ab9 100644 --- a/BMA.EHR.Command.Service/appsettings.json +++ b/BMA.EHR.Command.Service/appsettings.json @@ -26,10 +26,10 @@ } }, "MinIO": { - "Endpoint": "https://s3.frappet.com/", + "Endpoint": "https://s3cluster.frappet.com/", "AccessKey": "frappet", - "SecretKey": "P@ssw0rd", - "BucketName": "bma-recruit" + "SecretKey": "FPTadmin2357", + "BucketName": "bma-ehr-fpt" }, "Protocol": "HTTPS" } \ No newline at end of file