Merge branch 'develop' into work
# Conflicts: # BMA.EHR.Application/ApplicationServicesRegistration.cs # BMA.EHR.Infrastructure/Migrations/ApplicationDBContextModelSnapshot.cs # BMA.EHR.Infrastructure/Persistence/ApplicationDBContext.cs # BMA.EHR.Solution.sln
This commit is contained in:
commit
8edfbc7466
70 changed files with 21946 additions and 157 deletions
|
|
@ -7,8 +7,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
85
BMA.EHR.Domain/Middlewares/ErrorHandlerMiddleware.cs
Normal file
85
BMA.EHR.Domain/Middlewares/ErrorHandlerMiddleware.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Net;
|
||||
|
||||
namespace BMA.EHR.Domain.Middlewares
|
||||
{
|
||||
public class ErrorHandlerMiddleware
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public ErrorHandlerMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _next(context);
|
||||
|
||||
var response = context.Response;
|
||||
response.ContentType = "application/json";
|
||||
|
||||
var responseModel = new ResponseObject();
|
||||
responseModel.Status = response.StatusCode;
|
||||
|
||||
if (responseModel.Status == (int)HttpStatusCode.Unauthorized)
|
||||
{
|
||||
responseModel.Message = GlobalMessages.NotAuthorized;
|
||||
await response.WriteAsJsonAsync(responseModel);
|
||||
}
|
||||
if (responseModel.Status == (int)HttpStatusCode.Forbidden)
|
||||
{
|
||||
responseModel.Message = GlobalMessages.ForbiddenAccess;
|
||||
await response.WriteAsJsonAsync(responseModel);
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
var response = context.Response;
|
||||
response.ContentType = "application/json";
|
||||
|
||||
var responseModel = new ResponseObject();
|
||||
responseModel.Status = response.StatusCode;
|
||||
var msg = error.Message;
|
||||
var inner = error.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
msg += $" {inner.Message}\r\n";
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
responseModel.Result = msg;
|
||||
|
||||
switch (response.StatusCode)
|
||||
{
|
||||
case (int)HttpStatusCode.Unauthorized:
|
||||
responseModel.Message = GlobalMessages.NotAuthorized;
|
||||
break;
|
||||
case (int)HttpStatusCode.Forbidden:
|
||||
responseModel.Message = GlobalMessages.ForbiddenAccess;
|
||||
break;
|
||||
default:
|
||||
responseModel.Status = (int)HttpStatusCode.InternalServerError;
|
||||
responseModel.Message = GlobalMessages.ExceptionOccured;
|
||||
break;
|
||||
}
|
||||
await response.WriteAsJsonAsync(responseModel);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
39
BMA.EHR.Domain/Models/Notifications/MessageQueueEntity.cs
Normal file
39
BMA.EHR.Domain/Models/Notifications/MessageQueueEntity.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using BMA.EHR.Domain.Models.Base;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BMA.EHR.Domain.Models.Notifications
|
||||
{
|
||||
public class MessageQueueEntity : EntityBase
|
||||
{
|
||||
[Required, MaxLength(200), Comment("ส่งจากระบบงาน")]
|
||||
public string SenderSystem { get; set; }
|
||||
|
||||
[Required, MaxLength(200), Comment("หัวเรื่อง")]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[Required, Comment("รายละเอียดข้อความ")]
|
||||
public string MessageContent { get; set; } = string.Empty;
|
||||
|
||||
[Comment("สิ่งที่แนบมาด้วย")]
|
||||
public string MessagePayLoad { get; set; } = string.Empty;
|
||||
|
||||
[Required, Comment("รหัสของผู้รับข้อความ")]
|
||||
public Guid ReceiverUserId { get; set; } = Guid.Empty;
|
||||
|
||||
[MaxLength(500), Comment("อีเมล์ของผู้รับ")]
|
||||
public string ReceiverEmailAddress { get; set; } = string.Empty;
|
||||
|
||||
[Required, Comment("ส่งอีเมลล์หรือไม่?")]
|
||||
public bool IsSendEmail { get; set; } = false;
|
||||
|
||||
[Required, Comment("ส่งไปที่กล่องข้อความหรือไม่?")]
|
||||
public bool IsSendInbox { get; set; } = false;
|
||||
|
||||
[Required, Comment("ส่งการแจ้งเตือนหรือไม่?")]
|
||||
public bool IsSendNotification { get; set; } = true;
|
||||
|
||||
[Required, Comment("ทำการส่งข้อความแล้วหรือยัง?")]
|
||||
public bool IsSend { get; set; } = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue