diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/.gitignore b/.idea/.idea.BMA.EHR.Solution/.idea/.gitignore
new file mode 100644
index 00000000..162f34a6
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/contentModel.xml
+/.idea.BMA.EHR.Solution.iml
+/modules.xml
+/projectSettingsUpdater.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/.name b/.idea/.idea.BMA.EHR.Solution/.idea/.name
new file mode 100644
index 00000000..888d8763
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/.name
@@ -0,0 +1 @@
+BMA.EHR.Solution
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml b/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml
new file mode 100644
index 00000000..df87cf95
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml b/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml
new file mode 100644
index 00000000..7b08163c
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml b/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/.idea.BMA.EHR.Solution/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj b/BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj
index 5a47e960..9bae0b2e 100644
--- a/BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj
+++ b/BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj
@@ -25,6 +25,7 @@
+
diff --git a/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs b/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs
index d83b88df..85e8a23c 100644
--- a/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs
+++ b/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs
@@ -1,5 +1,6 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Repositories;
+using BMA.EHR.Infrastructure.MessageQueue;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -9,6 +10,15 @@ namespace BMA.EHR.Infrastructure
{
public static class InfrastructureServiceRegistration
{
+ public static IServiceCollection AddMessageQueue(this IServiceCollection services)
+ {
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+
+ return services;
+ }
+
public static IServiceCollection AddLeavePersistence(this IServiceCollection services,
IConfiguration configuration)
{
diff --git a/BMA.EHR.Infrastructure/MessageQueue/RabbitMQConnection.cs b/BMA.EHR.Infrastructure/MessageQueue/RabbitMQConnection.cs
new file mode 100644
index 00000000..2c69ece5
--- /dev/null
+++ b/BMA.EHR.Infrastructure/MessageQueue/RabbitMQConnection.cs
@@ -0,0 +1,45 @@
+using Microsoft.Extensions.Configuration;
+using RabbitMQ.Client;
+
+namespace BMA.EHR.Infrastructure.MessageQueue
+{
+ public class RabbitMQConnection
+ {
+ private readonly IConnection _connection;
+ private readonly IModel _channel;
+
+ private readonly IConfiguration _configuration;
+
+ ///
+ ///
+ ///
+ ///
+ public RabbitMQConnection(IConfiguration configuration)
+ {
+ _configuration = configuration;
+ var hostName = _configuration["RabbitMQ:URL"];
+ var userName = _configuration["RabbitMQ:UserName"];
+ var password = _configuration["RabbitMQ:Password"];
+
+
+ var factory = new ConnectionFactory() { HostName = hostName, UserName = userName, Password = password };
+ _connection = factory.CreateConnection();
+ _channel = _connection.CreateModel();
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public IModel GetChannel() => _channel;
+
+ ///
+ ///
+ ///
+ public void Dispose()
+ {
+ _channel?.Close();
+ _connection?.Close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/BMA.EHR.Infrastructure/MessageQueue/RabbitMQConsumer.cs b/BMA.EHR.Infrastructure/MessageQueue/RabbitMQConsumer.cs
new file mode 100644
index 00000000..faa33258
--- /dev/null
+++ b/BMA.EHR.Infrastructure/MessageQueue/RabbitMQConsumer.cs
@@ -0,0 +1,49 @@
+using System.Text;
+using RabbitMQ.Client.Events;
+
+namespace BMA.EHR.Infrastructure.MessageQueue
+{
+ public class RabbitMQConsumer
+ {
+ private readonly RabbitMQConnection _connection;
+
+
+ ///
+ ///
+ ///
+ ///
+ public RabbitMQConsumer(RabbitMQConnection connection)
+ {
+ _connection = connection;
+ }
+
+ ///
+ ///
+ ///
+ public void StartReceiving()
+ {
+ var channel = _connection.GetChannel();
+ channel.QueueDeclare(queue: "myqueue",
+ durable: false,
+ exclusive: false,
+ autoDelete: false,
+ arguments: null);
+
+ var consumer = new EventingBasicConsumer(channel);
+ consumer.Received += (model, ea) =>
+ {
+ var body = ea.Body.ToArray();
+ var message = Encoding.UTF8.GetString(body);
+ Console.WriteLine(" [x] Received {0}", message);
+ };
+
+ channel.BasicConsume(queue: "myqueue",
+ autoAck: true,
+ consumer: consumer,
+ consumerTag: "",
+ noLocal: false,
+ exclusive: false,
+ arguments: null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BMA.EHR.Infrastructure/MessageQueue/RabbitMQProducer.cs b/BMA.EHR.Infrastructure/MessageQueue/RabbitMQProducer.cs
new file mode 100644
index 00000000..e7dde3d7
--- /dev/null
+++ b/BMA.EHR.Infrastructure/MessageQueue/RabbitMQProducer.cs
@@ -0,0 +1,40 @@
+using System.Text;
+
+namespace BMA.EHR.Infrastructure.MessageQueue
+{
+ public class RabbitMQProducer
+ {
+ private readonly RabbitMQConnection _connection;
+
+ ///
+ ///
+ ///
+ ///
+ public RabbitMQProducer(RabbitMQConnection connection)
+ {
+ _connection = connection;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public void SendMessage(string message)
+ {
+ var channel = _connection.GetChannel();
+ channel.QueueDeclare(queue: "myqueue",
+ durable: false,
+ exclusive: false,
+ autoDelete: false,
+ arguments: null);
+
+ var body = Encoding.UTF8.GetBytes(message);
+
+ channel.BasicPublish(exchange: "",
+ routingKey: "myqueue",
+ mandatory: false,
+ basicProperties: null,
+ body: body);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BMA.EHR.Insignia/BMA.EHR.Insignia.csproj b/BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
index 993e7548..0f7e4232 100644
--- a/BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
+++ b/BMA.EHR.Insignia/BMA.EHR.Insignia.csproj
@@ -13,34 +13,35 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs
index 417443b9..a2022981 100644
--- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs
+++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs
@@ -6,6 +6,7 @@ using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Shared;
+using BMA.EHR.Infrastructure.MessageQueue;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service.Requests;
using Microsoft.AspNetCore.Authorization;
@@ -36,8 +37,22 @@ namespace BMA.EHR.Insignia.Service.Controllers
private readonly string Royal_Type = "Royal";
private readonly UserProfileRepository _userProfileRepository;
+ private readonly RabbitMQProducer _producer;
+
private readonly InsigniaPeriodsRepository _insigniaPeriodRepository;
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public InsigniaRequestController(ApplicationDBContext context,
MinIOService documentService,
InsigniaPeriodsRepository repository,
@@ -45,7 +60,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
IWebHostEnvironment hostingEnvironment,
IHttpContextAccessor httpContextAccessor,
UserProfileRepository userProfileRepository,
- InsigniaPeriodsRepository insigniaPeriodRepository)
+ InsigniaPeriodsRepository insigniaPeriodRepository,
+ RabbitMQProducer producer)
{
_context = context;
_documentService = documentService;
@@ -55,6 +71,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
_hostingEnvironment = hostingEnvironment;
_userProfileRepository = userProfileRepository;
_insigniaPeriodRepository = insigniaPeriodRepository;
+ _producer = producer;
}
#region " Properties "
@@ -220,7 +237,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
-
+
profileId = irp.ProfileId,
citizenId = irp.CitizenId,
prefix = irp.Prefix,
@@ -231,7 +248,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
posno = irp.PosNo,
rank = $"{irp.PosTypeName}/{irp.PosLevelName}",
lastInsigniaName = irp.LastInsigniaName,
-
+
//profile = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken),
instituteName = "",
instituteId = -1,
@@ -284,146 +301,103 @@ namespace BMA.EHR.Insignia.Service.Controllers
return rawData;
}
- #endregion
+ #endregion
- #region " ดึงเครื่องราชฯ ล่าสุดของครู (GetInsigniaLast) "
- // private InsigniaItem GetInsigniaLast(Guid? id)
- // {
- // var insignia = _context.Insignias.AsQueryable()
- // .Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
- // {
- // Id = i.Id,
- // Name = i.Name,
- // ShortName = i.ShortName,
- // Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
- // LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
- // }).FirstOrDefault();
+ #region " ดึงเครื่องราชฯ ล่าสุดของครู (GetInsigniaLast) "
+ // private InsigniaItem GetInsigniaLast(Guid? id)
+ // {
+ // var insignia = _context.Insignias.AsQueryable()
+ // .Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
+ // {
+ // Id = i.Id,
+ // Name = i.Name,
+ // ShortName = i.ShortName,
+ // Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
+ // LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
+ // }).FirstOrDefault();
- // return insignia;
- // }
- #endregion
+ // return insignia;
+ // }
+ #endregion
- #region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
-
- ///
- /// list รายการคำขอเครื่องราช ผู้ได้รับ,คนไม่ยื่น,คนที่ถูกลบ
- ///
- /// Id รอบเครื่องราช
- /// Id สังกัด
- /// ชื่อตำแหน่งระหว่างสกจ กับ เขต (ตอนนี้ให้ส่ง officer ก่อน)
- /// pending=ผู้ได้รับ, reject=คนไม่ยื่น, delete=คนที่ถูกลบ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("{insigniaPeriodId:length(36)}/{ocId:length(36)}/{role}/{status}")]
- public async Task> GetInsignaiRequestBkk(Guid insigniaPeriodId, Guid ocId, string role, string status)
- {
- var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
- if (result != null)
+ #region " ทดสอบ RabbitMQ "
+
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("rabbit")]
+ [AllowAnonymous]
+ public ActionResult CallRabbitMQ()
{
- Guid period = result.PeriodId;
- var periodName = result.Name;
- string requestStatus = result.RequestStatus;
- string requestNote = result.RequestNote;
+ _producer.SendMessage("test send");
+ return Success();
+ }
+ #endregion
- var resend = new InsigniaResults
+ #region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
+
+ ///
+ /// list รายการคำขอเครื่องราช ผู้ได้รับ,คนไม่ยื่น,คนที่ถูกลบ
+ ///
+ /// Id รอบเครื่องราช
+ /// Id สังกัด
+ /// ชื่อตำแหน่งระหว่างสกจ กับ เขต (ตอนนี้ให้ส่ง officer ก่อน)
+ /// pending=ผู้ได้รับ, reject=คนไม่ยื่น, delete=คนที่ถูกลบ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("{insigniaPeriodId:length(36)}/{ocId:length(36)}/{role}/{status}")]
+ public async Task> GetInsignaiRequestBkk(Guid insigniaPeriodId, Guid ocId, string role, string status)
+ {
+ var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
+ if (result != null)
{
- PeriodId = result.PeriodId,
- Year = result.Year,
- Round = result.Round,
- Name = result.Name,
- RequestId = result.RequestId,
- RequestStatus = result.RequestStatus,
- RequestNote = result.RequestNote,
- IsLock = result.IsLock,
- OrganizationName = result.OrganizationName,
- Document = result.Document,
- Items = new List()
- };
- if (RoleAdmin == true && result.RequestStatus != "st6")
- return Success(resend);
- if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2"))
- return Success(resend);
+ Guid period = result.PeriodId;
+ var periodName = result.Name;
+ string requestStatus = result.RequestStatus;
+ string requestNote = result.RequestNote;
- // Jack Remark Remove เพื่อให้เรียกขข้อมูลออกมาเร็สวขึ้น
- //var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
- //// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
- //if (requestStatus == null)
- //{
- // // บันทึกรายชื่อ
- // await _repository.InsertCandidate(period, ocId, candidate);
- //}
- if (role.Trim().ToUpper() == "OFFICER")
- {
- resend.Items = await _repository.InsigniaHasProfile(result.PeriodId, ocId, status);
- return Success(resend);
- }
- else
- {
- var passData = _context.InsigniaRequests.AsQueryable()
- //.Include(x => x.Organization)
- .Include(x => x.RequestProfiles)
- .Where(x => x.OrganizationId == ocId)
- .Where(x => x.Period.Id == period)
- .Select(ir => new
- {
- requstID = ir.Id,
- requstStatus = ir.RequestStatus,
- requstStatusName = GetRequestlStatusText(ir.RequestStatus),
- fkInstituteId = -1,
- // fkDivisionId = ir.Organization.Id,
- // fkDivision = ir.Organization.Name,
- fkInstitute = "",
- fkPeriodId = ir.Period.Id,
- insigniaRequestHasProfile = FormatRequestProfiles(ir.RequestProfiles.AsQueryable()
- .Include(x => x.RequestInsignia)
- .ThenInclude(x => x.InsigniaType)
- .Where(x => x.IsApprove)
- .ToList())
- //insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
- // .Include(x => x.RequestInsignia)
- // .ThenInclude(x => x.InsigniaType)
- // .Select(irp => new
- // {
- // request_id = irp.Request.Id,
- // isApprove = irp.IsApprove,
- // statusInstitute = irp.IsApprove.ToString(),
- // request_date = irp.RequestDate,
- // profileId = irp.ProfileId,
- // prefix = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Prefix, //irp.Profile.Prefix,
- // firstname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).FirstName, //irp.Profile.FirstName,
- // lastname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).LastName, //irp.Profile.LastName,
- // posno = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.Count == 0 ||
- // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary == null ? "" :
- // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,// irp.Profile.PositionNumber.Id,
- // type = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileType, //irp.Profile.ProfileType,
- // position = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Position, // irp.Profile.Position.Name,
- // rank = $"{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosType.PosTypeName}/{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosLevel.PosLevelName}", // $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
- // instituteName = "",
- // instituteId = -1,
- // // divisionName = irp.Profile.OrganizationOrganization.Name,
- // // divisionId = irp.Profile.OrganizationOrganization.Id,
- // lastInsigniaName = "",
- // requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
- // requestInsigniaName = irp.RequestInsignia.Name,
- // requestQua = "",// irp.QualificationStatus,
- // requestDoc = "", //irp.DocumentStatus,
- // requestNote = "", // irp.Note,
- // requestSalary = irp.Salary,
- // matchingConditions = JsonConvert.DeserializeObject>(irp.MatchingConditions)
- // })
- // .Where(x => x.isApprove)
- // .OrderBy(y => y.profileId)
- // .ToList()
- })
- .ToList()
- .FirstOrDefault();
+ var resend = new InsigniaResults
+ {
+ PeriodId = result.PeriodId,
+ Year = result.Year,
+ Round = result.Round,
+ Name = result.Name,
+ RequestId = result.RequestId,
+ RequestStatus = result.RequestStatus,
+ RequestNote = result.RequestNote,
+ IsLock = result.IsLock,
+ OrganizationName = result.OrganizationName,
+ Document = result.Document,
+ Items = new List()
+ };
+ if (RoleAdmin == true && result.RequestStatus != "st6")
+ return Success(resend);
+ if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2"))
+ return Success(resend);
- var failData = _context.InsigniaRequests.AsQueryable()
+ // Jack Remark Remove เพื่อให้เรียกขข้อมูลออกมาเร็สวขึ้น
+ //var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
+
+ //// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
+ //if (requestStatus == null)
+ //{
+ // // บันทึกรายชื่อ
+ // await _repository.InsertCandidate(period, ocId, candidate);
+ //}
+ if (role.Trim().ToUpper() == "OFFICER")
+ {
+ resend.Items = await _repository.InsigniaHasProfile(result.PeriodId, ocId, status);
+ return Success(resend);
+ }
+ else
+ {
+ var passData = _context.InsigniaRequests.AsQueryable()
//.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationId == ocId)
@@ -439,18 +413,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = FormatRequestProfiles(ir.RequestProfiles.AsQueryable()
- .Include(x => x.RequestInsignia)
- .ThenInclude(x => x.InsigniaType)
- .Where(x => !x.IsApprove)
- .ToList())
- //insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
- // //.Include(x => x.Profile)
- // //.ThenInclude(x => x.Position)
- // //.Include(x => x.Profile)
- // // .ThenInclude(x => x.PositionNumber)
- // //.Include(x => x.Profile)
- // // .ThenInclude(x => x.AcademicStanding)
- // .Include(x => x.RequestInsignia)
+ .Include(x => x.RequestInsignia)
+ .ThenInclude(x => x.InsigniaType)
+ .Where(x => x.IsApprove)
+ .ToList())
+ //insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
+ // .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Select(irp => new
// {
@@ -463,8 +431,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
// firstname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).FirstName, //irp.Profile.FirstName,
// lastname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).LastName, //irp.Profile.LastName,
// posno = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.Count == 0 ||
- // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary == null ? "" :
- // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,// irp.Profile.PositionNumber.Id,
+ // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary == null ? "" :
+ // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,// irp.Profile.PositionNumber.Id,
// type = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileType, //irp.Profile.ProfileType,
// position = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Position, // irp.Profile.Position.Name,
// rank = $"{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosType.PosTypeName}/{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosLevel.PosLevelName}", // $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
@@ -475,1210 +443,1202 @@ namespace BMA.EHR.Insignia.Service.Controllers
// lastInsigniaName = "",
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
// requestInsigniaName = irp.RequestInsignia.Name,
- // requestQua = "", //irp.QualificationStatus,
+ // requestQua = "",// irp.QualificationStatus,
// requestDoc = "", //irp.DocumentStatus,
- // requestNote = "", //irp.Note,
+ // requestNote = "", // irp.Note,
// requestSalary = irp.Salary,
// matchingConditions = JsonConvert.DeserializeObject>(irp.MatchingConditions)
// })
- // .Where(x => !x.isApprove)
+ // .Where(x => x.isApprove)
// .OrderBy(y => y.profileId)
// .ToList()
})
.ToList()
.FirstOrDefault();
- var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
- where p.Id == period
- select new
- {
- periodName = p.Name,
- periodYear = p.Year,
- }).FirstOrDefault();
+ var failData = _context.InsigniaRequests.AsQueryable()
+ //.Include(x => x.Organization)
+ .Include(x => x.RequestProfiles)
+ .Where(x => x.OrganizationId == ocId)
+ .Where(x => x.Period.Id == period)
+ .Select(ir => new
+ {
+ requstID = ir.Id,
+ requstStatus = ir.RequestStatus,
+ requstStatusName = GetRequestlStatusText(ir.RequestStatus),
+ fkInstituteId = -1,
+ // fkDivisionId = ir.Organization.Id,
+ // fkDivision = ir.Organization.Name,
+ fkInstitute = "",
+ fkPeriodId = ir.Period.Id,
+ insigniaRequestHasProfile = FormatRequestProfiles(ir.RequestProfiles.AsQueryable()
+ .Include(x => x.RequestInsignia)
+ .ThenInclude(x => x.InsigniaType)
+ .Where(x => !x.IsApprove)
+ .ToList())
+ //insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
+ // //.Include(x => x.Profile)
+ // //.ThenInclude(x => x.Position)
+ // //.Include(x => x.Profile)
+ // // .ThenInclude(x => x.PositionNumber)
+ // //.Include(x => x.Profile)
+ // // .ThenInclude(x => x.AcademicStanding)
+ // .Include(x => x.RequestInsignia)
+ // .ThenInclude(x => x.InsigniaType)
+ // .Select(irp => new
+ // {
+ // request_id = irp.Request.Id,
+ // isApprove = irp.IsApprove,
+ // statusInstitute = irp.IsApprove.ToString(),
+ // request_date = irp.RequestDate,
+ // profileId = irp.ProfileId,
+ // prefix = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Prefix, //irp.Profile.Prefix,
+ // firstname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).FirstName, //irp.Profile.FirstName,
+ // lastname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).LastName, //irp.Profile.LastName,
+ // posno = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.Count == 0 ||
+ // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary == null ? "" :
+ // _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,// irp.Profile.PositionNumber.Id,
+ // type = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileType, //irp.Profile.ProfileType,
+ // position = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Position, // irp.Profile.Position.Name,
+ // rank = $"{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosType.PosTypeName}/{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosLevel.PosLevelName}", // $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
+ // instituteName = "",
+ // instituteId = -1,
+ // // divisionName = irp.Profile.OrganizationOrganization.Name,
+ // // divisionId = irp.Profile.OrganizationOrganization.Id,
+ // lastInsigniaName = "",
+ // requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
+ // requestInsigniaName = irp.RequestInsignia.Name,
+ // requestQua = "", //irp.QualificationStatus,
+ // requestDoc = "", //irp.DocumentStatus,
+ // requestNote = "", //irp.Note,
+ // requestSalary = irp.Salary,
+ // matchingConditions = JsonConvert.DeserializeObject>(irp.MatchingConditions)
+ // })
+ // .Where(x => !x.isApprove)
+ // .OrderBy(y => y.profileId)
+ // .ToList()
+ })
+ .ToList()
+ .FirstOrDefault();
- return Success(new { passData = passData, failData = failData, period = period_data });
- //return Success();
+ var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
+ where p.Id == period
+ select new
+ {
+ periodName = p.Name,
+ periodYear = p.Year,
+ }).FirstOrDefault();
+
+ return Success(new { passData = passData, failData = failData, period = period_data });
+ //return Success();
+ }
+ // select data to display
}
- // select data to display
+
+ return Success();
}
- return Success();
- }
-
- ///
- /// คำนวณราชชื่อผู้ได้รับเครื่องราช
- ///
- /// Id รอบเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("{insigniaPeriodId:length(36)}")]
- public async Task> UpdateInsigniaRequestBkk(Guid insigniaPeriodId)
- {
- // // jack add เพื่อให้ทำการรันแค่เขตพระนคร
- // // TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
- // var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
- // var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
- // if (result != null)
- // {
- // Guid period = result.PeriodId;
- // string requestStatus = result.RequestStatus;
- // var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
- // // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
- // if (requestStatus == null)
- // {
- // // บันทึกรายชื่อ
- // await _repository.InsertCandidate(period, ocId, candidate);
- // }
- // }
-
- // TODO: original code use this in production
-
- var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
-
- foreach (var organization in organizations)
+ ///
+ /// คำนวณราชชื่อผู้ได้รับเครื่องราช
+ ///
+ /// Id รอบเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("{insigniaPeriodId:length(36)}")]
+ public async Task> UpdateInsigniaRequestBkk(Guid insigniaPeriodId)
{
- if (organization == null)
- continue;
-
- //if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
+ // // jack add เพื่อให้ทำการรันแค่เขตพระนคร
+ // // TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
+ // var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
+ // var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
+ // if (result != null)
+ // {
+ // Guid period = result.PeriodId;
+ // string requestStatus = result.RequestStatus;
+ // var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
+ // // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
+ // if (requestStatus == null)
+ // {
+ // // บันทึกรายชื่อ
+ // await _repository.InsertCandidate(period, ocId, candidate);
+ // }
+ // }
- var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
- if (result != null)
+ // TODO: original code use this in production
+
+ var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
+
+ foreach (var organization in organizations)
{
- Guid period = result.PeriodId;
- string requestStatus = result.RequestStatus;
- var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
- // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
- if (requestStatus == null)
+ if (organization == null)
+ continue;
+
+ //if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
+
+ var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
+ if (result != null)
{
- // บันทึกรายชื่อ
- await _repository.InsertCandidate(period, organization.Id, candidate);
+ Guid period = result.PeriodId;
+ string requestStatus = result.RequestStatus;
+ var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
+ // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
+ if (requestStatus == null)
+ {
+ // บันทึกรายชื่อ
+ await _repository.InsertCandidate(period, organization.Id, candidate);
+ }
}
}
+ return Success();
}
- return Success();
- }
- #endregion
+ #endregion
- #region " บันทึกหมายเหตุ "
+ #region " บันทึกหมายเหตุ "
- [HttpPut("note/{profileId}")]
- public async Task> SaveNote(Guid profileId, SaveRequsetNote items)
- {
- var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
- var note = _context.InsigniaRequestProfiles.AsQueryable()
- .Where(d => d.ProfileId == profileId && d.Request.Id == id).FirstOrDefault();
- //if (note != null)
- // note.Note = items.Note;
- _context.SaveChanges();
- return Success();
- }
-
- #endregion
-
- #region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
-
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [HttpPut("approve/{ocId:length(36)}")]
- public async Task> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
- {
- var result = await _repository.GetInsigniaRequest(id, ocId);
- if (result != null)
- await _repository.SaveAprove(result.PeriodId, ocId);
- return Success();
- }
-
- #endregion
-
- ///
- /// เปลี่ยน status เป็น st3 การเจ้าหน้าที่อนุมัติ "
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("officer/approve/{id:length(36)}/{ocId:length(36)}")]
- public async Task> ApproveChangeStatusToSt3(Guid id, Guid ocId)
- {
- await _repository.SaveAprove(id, ocId);
- var requestId = await _repository.GetRequestId(id, ocId);
- var requestNew = await _context.InsigniaRequests
- //.Include(x => x.Organization)
- //.ThenInclude(x => x.OrganizationOrganization)
- .Include(x => x.Period)
- .FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
+ [HttpPut("note/{profileId}")]
+ public async Task> SaveNote(Guid profileId, SaveRequsetNote items)
{
- var org = _userProfileRepository.GetOc(ocId, 0, AccessToken);
-
- requestNew.RequestStatus = "st3";
- requestNew.RequestNote = "";
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbc953-630a-4e72-88a7-c68dbb1ba856"),
- $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- "",
- true
- );
+ var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
+ var note = _context.InsigniaRequestProfiles.AsQueryable()
+ .Where(d => d.ProfileId == profileId && d.Request.Id == id).FirstOrDefault();
+ //if (note != null)
+ // note.Note = items.Note;
_context.SaveChanges();
return Success();
}
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
- ///
- /// เปลี่ยน status เป็น st2 การเจ้าหน้าที่ไม่อนุมัติ "
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("officer/reject/{id:length(36)}/{ocId:length(36)}")]
- public async Task> RejectChangeStatusToSt2([FromBody] InsigniaReasonRequest req, Guid id, Guid ocId)
- {
- await _repository.SaveAprove(id, ocId);
- var requestId = await _repository.GetRequestId(id, ocId);
- var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
+ #endregion
+
+ #region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpPut("approve/{ocId:length(36)}")]
+ public async Task> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
{
- requestNew.RequestStatus = "st2";
- requestNew.RequestNote = req.Reason;
+ var result = await _repository.GetInsigniaRequest(id, ocId);
+ if (result != null)
+ await _repository.SaveAprove(result.PeriodId, ocId);
+ return Success();
+ }
+
+ #endregion
+
+ ///
+ /// เปลี่ยน status เป็น st3 การเจ้าหน้าที่อนุมัติ "
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("officer/approve/{id:length(36)}/{ocId:length(36)}")]
+ public async Task> ApproveChangeStatusToSt3(Guid id, Guid ocId)
+ {
+ await _repository.SaveAprove(id, ocId);
+ var requestId = await _repository.GetRequestId(id, ocId);
+ var requestNew = await _context.InsigniaRequests
+ //.Include(x => x.Organization)
+ //.ThenInclude(x => x.OrganizationOrganization)
+ .Include(x => x.Period)
+ .FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ var org = _userProfileRepository.GetOc(ocId, 0, AccessToken);
+
+ requestNew.RequestStatus = "st3";
+ requestNew.RequestNote = "";
+ await _repositoryNoti.PushNotificationAsync(
+ Guid.Parse("08dbc953-630a-4e72-88a7-c68dbb1ba856"),
+ $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ "",
+ true
+ );
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ ///
+ /// เปลี่ยน status เป็น st2 การเจ้าหน้าที่ไม่อนุมัติ "
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("officer/reject/{id:length(36)}/{ocId:length(36)}")]
+ public async Task> RejectChangeStatusToSt2([FromBody] InsigniaReasonRequest req, Guid id, Guid ocId)
+ {
+ await _repository.SaveAprove(id, ocId);
+ var requestId = await _repository.GetRequestId(id, ocId);
+ var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ requestNew.RequestStatus = "st2";
+ requestNew.RequestNote = req.Reason;
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ ///
+ /// เปลี่ยน status เป็น st6 ผอ.หน่วยอนุมัติ "
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("director/approve/{id:length(36)}/{ocId:length(36)}")]
+ public async Task> ApproveChangeStatusToSt6(Guid id, Guid ocId)
+ {
+ var requestId = await _repository.GetRequestId(id, ocId);
+ var requestNew = await _context.InsigniaRequests
+ //.Include(x => x.Organization)
+ //.ThenInclude(x => x.OrganizationOrganization)
+ .Include(x => x.Period)
+ .FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ var org = _userProfileRepository.GetOc(ocId, 0, AccessToken);
+
+ requestNew.RequestStatus = "st6";
+ requestNew.RequestNote = "";
+ await _repositoryNoti.PushNotificationAsync(
+ Guid.Parse("08dbc953-64d9-497a-87a3-0244eade622c"),
+ $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ "",
+ true
+ );
+ await _repositoryNoti.PushNotificationAsync(
+ Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
+ $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ "",
+ true
+ );
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ ///
+ /// เปลี่ยน status เป็น st4 ผอ.หน่วยไม่อนุมัติ "
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("director/reject/{id:length(36)}/{ocId:length(36)}")]
+ public async Task> RejectChangeStatusToSt4([FromBody] InsigniaReasonRequest req, Guid id, Guid ocId)
+ {
+ var requestId = await _repository.GetRequestId(id, ocId);
+ var requestNew = await _context.InsigniaRequests
+ //.Include(x => x.Organization)
+ //.ThenInclude(x => x.OrganizationOrganization)
+ .Include(x => x.Period)
+ .FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ var org = _userProfileRepository.GetOc(ocId, 0, AccessToken);
+
+ requestNew.RequestStatus = "st4";
+ requestNew.RequestNote = req.Reason;
+ await _repositoryNoti.PushNotificationAsync(
+ Guid.Parse("08dbc953-61ac-47eb-82d7-0e72df7669b5"),
+ $"{(org == null ? null : org.Root)} ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ $"{(org == null ? null : org.Root)} ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ "",
+ true
+ );
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ ///
+ /// เปลี่ยน status เป็น st5 สกจ. หน่วยไม่อนุมัติ "
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("head/reject/{id:length(36)}/{ocId:length(36)}")]
+ public async Task> RejectChangeStatusToSt5([FromBody] InsigniaReasonRequest req, Guid id, Guid ocId)
+ {
+ var requestId = await _repository.GetRequestId(id, ocId);
+ var requestNew = await _context.InsigniaRequests
+ //.Include(x => x.Organization)
+ //.ThenInclude(x => x.OrganizationOrganization)
+ .Include(x => x.Period)
+ .FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ requestNew.RequestStatus = "st5";
+ requestNew.RequestNote = req.Reason;
+ await _repositoryNoti.PushNotificationAsync(
+ Guid.Parse("08dbc953-630a-4e72-88a7-c68dbb1ba856"),
+ $"สกจ. ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ $"สกจ. ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
+ "",
+ true
+ );
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ // #endregion
+
+ #region " เปลี่ยน status สำหรับ ผอ.สำนัก "
+
+ [HttpPost("status/director/approve/{ocId:length(36)}")]
+ public async Task> ChangeStatusToSt5p(Guid id, Guid ocId)
+ {
+ var result = await _repository.GetInsigniaRequest(id, ocId);
+ if (result == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
+ if (requestId == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ requestNew.RequestStatus = "st5p";
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ [HttpPost("status/director/reject/{ocId:length(36)}")]
+ public async Task> ChangeStatusToSt1(Guid id, Guid ocId)
+ {
+ var result = await _repository.GetInsigniaRequest(id, ocId);
+ if (result == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
+ if (requestId == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
+ if (requestNew != null)
+ {
+ requestNew.RequestStatus = "st1";
+ _context.SaveChanges();
+ return Success();
+ }
+ else
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ }
+
+ #endregion
+
+ ///
+ /// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
+ ///
+ /// Id รายชื่อคนที่ยื่นของในรอบ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("status/reject/{insigniaRequestProfileId:length(36)}")]
+ public async Task> RejectProfileInsignia([FromBody] InsigniaReasonRequest req, Guid insigniaRequestProfileId)
+ {
+ var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
+ if (insigniaRequestProfile == null)
+ return Error(GlobalMessages.InsigniaRequestProfileNotFound);
+ insigniaRequestProfile.Status = "REJECT";
+ insigniaRequestProfile.ReasonReject = req.Reason;
+ insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
+ insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
- ///
- /// เปลี่ยน status เป็น st6 ผอ.หน่วยอนุมัติ "
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("director/approve/{id:length(36)}/{ocId:length(36)}")]
- public async Task> ApproveChangeStatusToSt6(Guid id, Guid ocId)
- {
- var requestId = await _repository.GetRequestId(id, ocId);
- var requestNew = await _context.InsigniaRequests
- //.Include(x => x.Organization)
- //.ThenInclude(x => x.OrganizationOrganization)
- .Include(x => x.Period)
- .FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
+ ///
+ /// ย้ายขอมูลไปเป็น คนที่ถูกลบออก
+ ///
+ /// Id รายชื่อคนที่ยื่นของในรอบ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("status/delete/{insigniaRequestProfileId:length(36)}")]
+ public async Task> DeleteProfileInsignia([FromBody] InsigniaReasonRequest req, Guid insigniaRequestProfileId)
{
- var org = _userProfileRepository.GetOc(ocId, 0, AccessToken);
-
- requestNew.RequestStatus = "st6";
- requestNew.RequestNote = "";
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbc953-64d9-497a-87a3-0244eade622c"),
- $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- "",
- true
- );
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
- $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- $"{(org == null ? null : org.Root)} ยื่นขอมูลข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- "",
- true
- );
+ var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
+ if (insigniaRequestProfile == null)
+ return Error(GlobalMessages.InsigniaRequestProfileNotFound);
+ insigniaRequestProfile.Status = "DELETE";
+ insigniaRequestProfile.ReasonReject = req.Reason;
+ insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
+ insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
- ///
- /// เปลี่ยน status เป็น st4 ผอ.หน่วยไม่อนุมัติ "
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("director/reject/{id:length(36)}/{ocId:length(36)}")]
- public async Task> RejectChangeStatusToSt4([FromBody] InsigniaReasonRequest req, Guid id, Guid ocId)
- {
- var requestId = await _repository.GetRequestId(id, ocId);
- var requestNew = await _context.InsigniaRequests
- //.Include(x => x.Organization)
- //.ThenInclude(x => x.OrganizationOrganization)
- .Include(x => x.Period)
- .FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
+ ///
+ /// สรุปจำนวนการยื่นขอในแต่ละรอบ
+ ///
+ /// Id รอบการยื่นขอ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("dashboard/{insigniaPeriodId:length(36)}")]
+ public async Task> DashboardInsigniaPeriod(Guid insigniaPeriodId)
{
- var org = _userProfileRepository.GetOc(ocId, 0, AccessToken);
+ var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var orgAllCount = await _context.InsigniaRequests
+ .Where(x => x.Period == insigniaPeriod)
+ .ToListAsync();
+ var allUserUser = await _context.InsigniaRequests
+ .Where(x => x.Period == insigniaPeriod)
+ .Where(x => RoleAdmin == true ? x.RequestStatus == "st6" : (RoleInsignia2 == true ? (x.RequestStatus != "st1" && x.RequestStatus != "st2") : x.Id != null))
+ .Select(x => x.RequestProfiles.Count(x => x.Status != "DELETE" && x.Status != "REJECT"))
+ .SumAsync();
- requestNew.RequestStatus = "st4";
- requestNew.RequestNote = req.Reason;
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbc953-61ac-47eb-82d7-0e72df7669b5"),
- $"{(org == null ? null : org.Root)} ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- $"{(org == null ? null : org.Root)} ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- "",
- true
- );
- _context.SaveChanges();
- return Success();
+ return Success(new { OrgAllCount = orgAllCount.Count(), OrgSendCount = orgAllCount.Where(x => x.RequestStatus != "st1" && x.RequestStatus != "st2").Count(), OrgNoSendCount = orgAllCount.Where(x => x.RequestStatus == "st1" || x.RequestStatus == "st2").Count(), AllUserUser = allUserUser });
}
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
- ///
- /// เปลี่ยน status เป็น st5 สกจ. หน่วยไม่อนุมัติ "
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("head/reject/{id:length(36)}/{ocId:length(36)}")]
- public async Task> RejectChangeStatusToSt5([FromBody] InsigniaReasonRequest req, Guid id, Guid ocId)
- {
- var requestId = await _repository.GetRequestId(id, ocId);
- var requestNew = await _context.InsigniaRequests
- //.Include(x => x.Organization)
- //.ThenInclude(x => x.OrganizationOrganization)
- .Include(x => x.Period)
- .FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
+ ///
+ /// หน่วยงานทียังไม่ส่งรายชื่อ
+ ///
+ /// Id รอบการยื่นขอ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("org/no-send/{insigniaPeriodId:length(36)}")]
+ public async Task> ListOrgDontSentUser(Guid insigniaPeriodId)
{
- requestNew.RequestStatus = "st5";
- requestNew.RequestNote = req.Reason;
- await _repositoryNoti.PushNotificationAsync(
- Guid.Parse("08dbc953-630a-4e72-88a7-c68dbb1ba856"),
- $"สกจ. ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- $"สกจ. ตีกลับข้อมูลผู้มีสิทธิ์ได้รับเครื่องราชฯ {requestNew.Period.Name}",
- "",
- true
- );
- _context.SaveChanges();
- return Success();
- }
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
-
- // #endregion
-
- #region " เปลี่ยน status สำหรับ ผอ.สำนัก "
-
- [HttpPost("status/director/approve/{ocId:length(36)}")]
- public async Task> ChangeStatusToSt5p(Guid id, Guid ocId)
- {
- var result = await _repository.GetInsigniaRequest(id, ocId);
- if (result == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
- if (requestId == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
- {
- requestNew.RequestStatus = "st5p";
- _context.SaveChanges();
- return Success();
- }
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
-
- [HttpPost("status/director/reject/{ocId:length(36)}")]
- public async Task> ChangeStatusToSt1(Guid id, Guid ocId)
- {
- var result = await _repository.GetInsigniaRequest(id, ocId);
- if (result == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
- if (requestId == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
- if (requestNew != null)
- {
- requestNew.RequestStatus = "st1";
- _context.SaveChanges();
- return Success();
- }
- else
- return Error(GlobalMessages.InsigniaRequestNotFound);
- }
-
- #endregion
-
- ///
- /// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
- ///
- /// Id รายชื่อคนที่ยื่นของในรอบ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("status/reject/{insigniaRequestProfileId:length(36)}")]
- public async Task> RejectProfileInsignia([FromBody] InsigniaReasonRequest req, Guid insigniaRequestProfileId)
- {
- var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
- if (insigniaRequestProfile == null)
- return Error(GlobalMessages.InsigniaRequestProfileNotFound);
- insigniaRequestProfile.Status = "REJECT";
- insigniaRequestProfile.ReasonReject = req.Reason;
- insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
- insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
- insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
- _context.SaveChanges();
- return Success();
- }
-
- ///
- /// ย้ายขอมูลไปเป็น คนที่ถูกลบออก
- ///
- /// Id รายชื่อคนที่ยื่นของในรอบ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("status/delete/{insigniaRequestProfileId:length(36)}")]
- public async Task> DeleteProfileInsignia([FromBody] InsigniaReasonRequest req, Guid insigniaRequestProfileId)
- {
- var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
- if (insigniaRequestProfile == null)
- return Error(GlobalMessages.InsigniaRequestProfileNotFound);
- insigniaRequestProfile.Status = "DELETE";
- insigniaRequestProfile.ReasonReject = req.Reason;
- insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
- insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
- insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
- _context.SaveChanges();
- return Success();
- }
-
- ///
- /// สรุปจำนวนการยื่นขอในแต่ละรอบ
- ///
- /// Id รอบการยื่นขอ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("dashboard/{insigniaPeriodId:length(36)}")]
- public async Task> DashboardInsigniaPeriod(Guid insigniaPeriodId)
- {
- var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var orgAllCount = await _context.InsigniaRequests
- .Where(x => x.Period == insigniaPeriod)
+ var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var orgIdSend = await _context.InsigniaRequests
+ .Where(x => x.Period == insigniaPeriod)
+ .Where(x => x.RequestStatus == "st1")
+ .Select(x => x.OrganizationId)
+ .ToListAsync();
+ var orgAllCount = await _context.Organizations
+ .Where(x => x.OrganizationOrganization != null)
+ .Where(x => x.OrganizationType != null)
+ .Where(x => x.OrganizationType.Name == "หน่วยงาน")
+ .Where(x => orgIdSend.Contains(x.Id))
+ .Select(x => new
+ {
+ OrgId = x.Id,
+ OrgName = x.OrganizationOrganization.Name
+ })
.ToListAsync();
- var allUserUser = await _context.InsigniaRequests
- .Where(x => x.Period == insigniaPeriod)
- .Where(x => RoleAdmin == true ? x.RequestStatus == "st6" : (RoleInsignia2 == true ? (x.RequestStatus != "st1" && x.RequestStatus != "st2") : x.Id != null))
- .Select(x => x.RequestProfiles.Count(x => x.Status != "DELETE" && x.Status != "REJECT"))
- .SumAsync();
- return Success(new { OrgAllCount = orgAllCount.Count(), OrgSendCount = orgAllCount.Where(x => x.RequestStatus != "st1" && x.RequestStatus != "st2").Count(), OrgNoSendCount = orgAllCount.Where(x => x.RequestStatus == "st1" || x.RequestStatus == "st2").Count(), AllUserUser = allUserUser });
- }
+ return Success(orgAllCount);
+ }
- ///
- /// หน่วยงานทียังไม่ส่งรายชื่อ
- ///
- /// Id รอบการยื่นขอ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("org/no-send/{insigniaPeriodId:length(36)}")]
- public async Task> ListOrgDontSentUser(Guid insigniaPeriodId)
- {
- var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var orgIdSend = await _context.InsigniaRequests
- .Where(x => x.Period == insigniaPeriod)
- .Where(x => x.RequestStatus == "st1")
- .Select(x => x.OrganizationId)
- .ToListAsync();
- var orgAllCount = await _context.Organizations
- .Where(x => x.OrganizationOrganization != null)
- .Where(x => x.OrganizationType != null)
- .Where(x => x.OrganizationType.Name == "หน่วยงาน")
- .Where(x => orgIdSend.Contains(x.Id))
- .Select(x => new
- {
- OrgId = x.Id,
- OrgName = x.OrganizationOrganization.Name
- })
- .ToListAsync();
-
- return Success(orgAllCount);
- }
-
- ///
- /// หน่วยงานที่อยู่ปัจจุบัน
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("agency")]
- public async Task> GetOrgAgency()
- {
- //var profile = await _context.Profiles.AsQueryable()
- // .FirstOrDefaultAsync(x => x.KeycloakId == (UserId != null && UserId != "" ? Guid.Parse(UserId) : Guid.Parse("00000000-0000-0000-0000-000000000000")));
- //if (profile == null)
- // return Error(GlobalMessages.DataNotFound);
- //var orgProfile = await _context.ProfilePositions
- // .Where(x => x.ProfileId == profile)
- // .Where(x => x.OrganizationPosition != null)
- // .Where(x => x.OrganizationPosition.Organization != null)
- // .Where(x => x.OrganizationPosition.Organization.OrganizationAgencyId != null)
- // .Select(x => x.OrganizationPosition.Organization.OrganizationAgencyId)
- // .FirstOrDefaultAsync();
- //if (orgProfile == null)
- //{
- // orgProfile = await _context.ProfilePositions
- // .Where(x => x.Profile == profile)
- // .Where(x => x.OrganizationPosition != null)
- // .Where(x => x.OrganizationPosition.Organization != null)
- // .Select(x => x.OrganizationPosition.Organization.Id)
- // .FirstOrDefaultAsync();
- //}
- //return Success(orgProfile);
-
- return Success();
- }
-
- ///
- /// เพิ่มรายชื่อผู้ได้รับเครื่องราช
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost()]
- public async Task> AddUserToRequestInsignia([FromBody] AddUserRequestInsigniaRequest req)
- {
- var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == req.insigniaPeriodId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
-
- //var profile = await _context.Profiles.Include(x => x.Salaries).FirstOrDefaultAsync(x => x.Id == req.ProfileId);
- var profile = _userProfileRepository.GetOfficerProfileById(req.ProfileId, AccessToken);
-
- if (profile == null)
- return Error(GlobalMessages.DataNotFound);
- var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
-
- if (insignia == null)
- return Error(GlobalMessages.InsigniaNotFound);
-
- var insigniaRequestProfile = await _context.InsigniaRequestProfiles
- .Include(x => x.Request)
- .ThenInclude(x => x.Period)
- .FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period.Id == insigniaPeriod.Id);
- if (insigniaRequestProfile != null)
- return Error(GlobalMessages.InsigniaRequestProfileDupicate);
-
- //var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod);
-
- //var _orgProfile = await _context.ProfilePositions
- // .Where(x => x.ProfileId == profile.Id)
- // .Where(x => x.OrganizationPosition != null)
- // .Where(x => x.OrganizationPosition.Organization != null)
- // .Where(x => x.OrganizationPosition.Organization.OrganizationAgencyId != null)
- // .Select(x => x.OrganizationPosition.Organization.OrganizationAgencyId)
- // .FirstOrDefaultAsync();
- //var _org = await _context.Organizations
- // .FirstOrDefaultAsync(x => x.Id == _orgProfile);
- var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Period).FirstOrDefaultAsync(x => x.Period.Id == insigniaPeriod.Id && x.OrganizationId == req.OcId);
- if (insigniaRequest == null)
+ ///
+ /// หน่วยงานที่อยู่ปัจจุบัน
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("agency")]
+ public async Task> GetOrgAgency()
{
+ //var profile = await _context.Profiles.AsQueryable()
+ // .FirstOrDefaultAsync(x => x.KeycloakId == (UserId != null && UserId != "" ? Guid.Parse(UserId) : Guid.Parse("00000000-0000-0000-0000-000000000000")));
+ //if (profile == null)
+ // return Error(GlobalMessages.DataNotFound);
//var orgProfile = await _context.ProfilePositions
- // .Where(x => x.Profile == profile)
+ // .Where(x => x.ProfileId == profile)
// .Where(x => x.OrganizationPosition != null)
// .Where(x => x.OrganizationPosition.Organization != null)
// .Where(x => x.OrganizationPosition.Organization.OrganizationAgencyId != null)
// .Select(x => x.OrganizationPosition.Organization.OrganizationAgencyId)
// .FirstOrDefaultAsync();
+ //if (orgProfile == null)
+ //{
+ // orgProfile = await _context.ProfilePositions
+ // .Where(x => x.Profile == profile)
+ // .Where(x => x.OrganizationPosition != null)
+ // .Where(x => x.OrganizationPosition.Organization != null)
+ // .Select(x => x.OrganizationPosition.Organization.Id)
+ // .FirstOrDefaultAsync();
+ //}
+ //return Success(orgProfile);
-
- //var org = await _context.Organizations
- // .FirstOrDefaultAsync(x => x.Id == orgProfile);
-
- //var org = _userProfileRepository.GetOc(insigniaRequestProfile!.Request.OrganizationId, 0, AccessToken);
-
- //if (org == null)
- // return Error(GlobalMessages.OrganizationNotFound);
- insigniaRequest = new InsigniaRequest
- {
- Period = insigniaPeriod,
- OrganizationId = req.OcId,
- RequestStatus = "st1",
- RequestNote = "",
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- CreatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- };
+ return Success();
}
-
- await _context.AddAsync(new InsigniaRequestProfile
+ ///
+ /// เพิ่มรายชื่อผู้ได้รับเครื่องราช
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost()]
+ public async Task> AddUserToRequestInsignia([FromBody] AddUserRequestInsigniaRequest req)
{
- Status = "PENDING",
- ProfileId = profile.Id,
- RequestInsignia = insignia,
- Request = insigniaRequest,
- Reason = req.Reason,
- RequestDate = DateTime.Now,
- MatchingConditions = System.Text.Json.JsonSerializer.Serialize(new List()), // serialize to string
- Salary = profile.ProfileSalary == null || profile.ProfileSalary.Count == 0 ? 0 :
- profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount, //profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- CreatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- });
+ var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == req.insigniaPeriodId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
- await _context.SaveChangesAsync();
- return Success();
- }
- ///
- /// แก้ไขรายชื่อผู้ได้รับเครื่องราช
- ///
- /// Id รายชื่อคนที่ยื่นของในรอบ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("{insigniaRequestProfileId:length(36)}")]
- public async Task> UpdateUserToRequestInsignia([FromBody] UpdateUserRequestInsigniaRequest req, Guid insigniaRequestProfileId)
- {
- var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
- if (insigniaRequestProfile == null)
- return Error(GlobalMessages.InsigniaRequestProfileNotFound);
- var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
- if (insignia == null)
- return Error(GlobalMessages.InsigniaNotFound);
+ //var profile = await _context.Profiles.Include(x => x.Salaries).FirstOrDefaultAsync(x => x.Id == req.ProfileId);
+ var profile = _userProfileRepository.GetOfficerProfileById(req.ProfileId, AccessToken);
- insigniaRequestProfile.RequestInsignia = insignia;
- insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
- insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
- insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
- await _context.SaveChangesAsync();
- return Success();
- }
+ if (profile == null)
+ return Error(GlobalMessages.DataNotFound);
+ var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
- ///
- /// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช
- ///
- /// Id รอบการยื่นขอ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("send/note/{insigniaPeriodId:length(36)}")]
- public async Task> SendPeriodToNote([FromBody] InsigniaNoteNameRequest req, Guid insigniaPeriodId)
- {
- var insigniaPeriod = await _context.InsigniaPeriods
- .Include(x => x.InsigniaRequests)
- .Include(x => x.ReliefDoc)
- .FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- insigniaPeriod.IsLock = true;
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- // .ThenInclude(x => x.Profile)
- .Include(x => x.InsigniaNoteProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .FirstOrDefaultAsync(x => x.Year == insigniaPeriod.Year);
- if (insigniaNote == null)
- {
- insigniaNote = new InsigniaNote
+ if (insignia == null)
+ return Error(GlobalMessages.InsigniaNotFound);
+
+ var insigniaRequestProfile = await _context.InsigniaRequestProfiles
+ .Include(x => x.Request)
+ .ThenInclude(x => x.Period)
+ .FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period.Id == insigniaPeriod.Id);
+ if (insigniaRequestProfile != null)
+ return Error(GlobalMessages.InsigniaRequestProfileDupicate);
+
+ //var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod);
+
+ //var _orgProfile = await _context.ProfilePositions
+ // .Where(x => x.ProfileId == profile.Id)
+ // .Where(x => x.OrganizationPosition != null)
+ // .Where(x => x.OrganizationPosition.Organization != null)
+ // .Where(x => x.OrganizationPosition.Organization.OrganizationAgencyId != null)
+ // .Select(x => x.OrganizationPosition.Organization.OrganizationAgencyId)
+ // .FirstOrDefaultAsync();
+ //var _org = await _context.Organizations
+ // .FirstOrDefaultAsync(x => x.Id == _orgProfile);
+ var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Period).FirstOrDefaultAsync(x => x.Period.Id == insigniaPeriod.Id && x.OrganizationId == req.OcId);
+ if (insigniaRequest == null)
{
- // Round = insigniaPeriod.Round,
- Name = req.Name,
- Year = insigniaPeriod.Year,
- // StartDate = insigniaPeriod.StartDate,
- // EndDate = insigniaPeriod.EndDate,
- // Amount = insigniaPeriod.Amount,
- // ReliefDoc = insigniaPeriod.ReliefDoc,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- CreatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- };
- await _context.InsigniaNotes.AddAsync(insigniaNote);
- await _context.SaveChangesAsync();
- insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .Include(x => x.InsigniaNoteProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .FirstOrDefaultAsync(x => x.Id == insigniaNote.Id);
- }
- var requestOlds = await _context.InsigniaRequests
- .Where(p => p.Period == insigniaPeriod)
- .Where(p => p.RequestStatus == "st6")
- .ToListAsync();
- foreach (var requestOld in requestOlds)
- {
- var profileOlds = await _context.InsigniaRequestProfiles
- //.Include(x => x.Profile)
- .Include(x => x.RequestInsignia)
- .Where(p => p.Request == requestOld)
- .ToListAsync();
+ //var orgProfile = await _context.ProfilePositions
+ // .Where(x => x.Profile == profile)
+ // .Where(x => x.OrganizationPosition != null)
+ // .Where(x => x.OrganizationPosition.Organization != null)
+ // .Where(x => x.OrganizationPosition.Organization.OrganizationAgencyId != null)
+ // .Select(x => x.OrganizationPosition.Organization.OrganizationAgencyId)
+ // .FirstOrDefaultAsync();
- foreach (var profileOld in profileOlds)
- {
- if (profileOld.Status == "DELETE" || profileOld.Status == "REJECT")
- continue;
- var noreProfileOld = insigniaNote.InsigniaNoteProfiles
- .Where(x => x.ProfileId == profileOld.ProfileId)
- .FirstOrDefault();
- if (noreProfileOld != null)
+
+ //var org = await _context.Organizations
+ // .FirstOrDefaultAsync(x => x.Id == orgProfile);
+
+ //var org = _userProfileRepository.GetOc(insigniaRequestProfile!.Request.OrganizationId, 0, AccessToken);
+
+ //if (org == null)
+ // return Error(GlobalMessages.OrganizationNotFound);
+ insigniaRequest = new InsigniaRequest
{
- noreProfileOld.RequestDate = profileOld.RequestDate;
- noreProfileOld.Salary = profileOld.Salary;
- noreProfileOld.IsApprove = profileOld.IsApprove;
- noreProfileOld.RequestInsignia = profileOld.RequestInsignia;
- noreProfileOld.CreatedFullName = FullName ?? "System Administrator";
- noreProfileOld.CreatedUserId = UserId ?? "";
- noreProfileOld.CreatedAt = DateTime.Now;
- noreProfileOld.LastUpdateFullName = FullName ?? "System Administrator";
- noreProfileOld.LastUpdateUserId = UserId ?? "";
- noreProfileOld.LastUpdatedAt = DateTime.Now;
- }
- else
- {
- if (profileOld.ProfileId == null)
- continue;
- await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile
- {
- RequestDate = profileOld.RequestDate,
- Salary = profileOld.Salary,
- IsApprove = profileOld.IsApprove,
- Status = "PENDING",
- ProfileId = profileOld.ProfileId,
- RequestInsignia = profileOld.RequestInsignia,
- OrganizationOrganizationSend = null,
- InsigniaNote = insigniaNote,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- CreatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- });
- }
+ Period = insigniaPeriod,
+ OrganizationId = req.OcId,
+ RequestStatus = "st1",
+ RequestNote = "",
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ CreatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ };
}
- }
- await _context.SaveChangesAsync();
- return Success();
- }
-
- ///
- /// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช(อัพเดทstatus)
- ///
- /// Id รอบการยื่นขอ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("send/note/{insigniaPeriodId:length(36)}")]
- public async Task> SendPeriodToNoteUpdateStatus(Guid insigniaPeriodId)
- {
- var insigniaPeriod = await _context.InsigniaPeriods
- .FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- insigniaPeriod.IsLock = true;
- await _context.SaveChangesAsync();
- return Success();
- }
-
- ///
- /// list รอบบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("note")]
- public async Task> GetListNote()
- {
- var insigniaNotes = await _context.InsigniaNotes.AsQueryable()
- .OrderByDescending(x => x.Year)
- // .ThenByDescending(x => x.StartDate)
- .Select(p => new
- {
- Id = p.Id,
- // Amount = p.Amount,
- Name = p.Name,
- // Round = p.Round,
- // Start = p.StartDate,
- // End = p.EndDate,
- Year = p.Year,
- // Doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
- })
- .ToListAsync();
- // var data = new List();
- // foreach (var insigniaNote in insigniaNotes)
- // {
- // var _data = new
- // {
- // Id = insigniaNote.Id,
- // Amount = insigniaNote.Amount,
- // Name = insigniaNote.Name,
- // Round = insigniaNote.Round,
- // Start = insigniaNote.Start,
- // End = insigniaNote.End,
- // Year = insigniaNote.Year,
- // Doc = insigniaNote.Doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNote.Doc),
- // };
- // data.Add(_data);
- // }
-
- return Success(insigniaNotes);
- }
-
- ///
- /// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
- ///
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPost("note/search")]
- public async Task> GetListNoteProfile([FromBody] InsigniaNoteSearchRequest req)
- {
- var insigniaNote = await _context.InsigniaNotes
- .FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var insigniaType = await _context.InsigniaTypes
- .FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId);
- if (insigniaType == null)
- return Error(GlobalMessages.InsigniaTypeNotFound);
-
- var rawNoteProfiles = await _context.InsigniaNoteProfiles
- .Where(x => x.InsigniaNote == insigniaNote)
- .Where(x => x.RequestInsignia.InsigniaType == insigniaType)
- .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
- .Select(x => new
- {
- Id = x.Id,
- Profile = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken),
- OcId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), // TODO: ต้องมาแก้ไข
- RequestInsignia = x.RequestInsignia.Name,
- RequestInsigniaId = x.RequestInsignia.Id,
- RequestInsigniaShortName = x.RequestInsignia.ShortName,
- DateReceive = x.DateReceive,
- OrganizationOrganizationSend = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
- OrganizationOrganizationReceive = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
- Status = x.Status,
- Issue = x.Issue,
- Date = x.Date,
- VolumeNo = x.VolumeNo,
- Section = x.Section,
- Page = x.Page,
- No = x.No,
- DatePayment = x.DatePayment,
- TypePayment = x.TypePayment,
- Address = x.Address,
- Number = x.Number,
- Salary = x.Salary,
- DateReceiveInsignia = x.DateReceiveInsignia,
- DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id,
- OrgReceiveInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
- DateReturnInsignia = x.DateReturnInsignia,
- DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id,
- OrgReturnInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
- })
- .ToListAsync();
-
- var insigniaNoteProfiles = rawNoteProfiles
- .Select(x => new
- {
- Id = x.Id,
- Prefix = x.Profile == null ? "" : x.Profile.Prefix,
- Position = x.Profile == null ? "" : x.Profile.Position,
- ProfileType = x.Profile == null ? "" : x.Profile.ProfileType,
- x.OcId,
- CitizenId = x.Profile == null ? "" : x.Profile.CitizenId,
- FullName = x.Profile == null ? "" : $"{x.Profile.Prefix}{x.Profile.FirstName} {x.Profile.LastName}",
- RequestInsignia = x.RequestInsignia,
- RequestInsigniaId = x.RequestInsigniaId,
- RequestInsigniaShortName = x.RequestInsigniaShortName,
- DateReceive = x.DateReceive,
- OrganizationOrganizationSend = x.OrganizationOrganizationSend,
- OrganizationOrganizationReceive = x.OrganizationOrganizationReceive,
- Status = x.Status,
- Issue = x.Issue,
- Date = x.Date,
- VolumeNo = x.VolumeNo,
- Section = x.Section,
- Page = x.Page,
- No = x.No,
- DatePayment = x.DatePayment,
- TypePayment = x.TypePayment,
- Address = x.Address,
- Number = x.Number,
- Salary = x.Salary,
- DateReceiveInsignia = x.DateReceiveInsignia,
- DocReceiveInsignia = x.DocReceiveInsignia,
- OrgReceiveInsignia = x.OrgReceiveInsignia,
- DateReturnInsignia = x.DateReturnInsignia,
- DocReturnInsignia = x.DocReturnInsignia,
- OrgReturnInsignia = x.OrgReturnInsignia,
- })
- .ToList();
-
- //var insigniaNoteProfiles = await _context.InsigniaNoteProfiles
- // .Where(x => x.InsigniaNote == insigniaNote)
- // .Where(x => x.RequestInsignia.InsigniaType == insigniaType)
- // .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
- // .Select(x => new
- // {
- // Id = x.Id,
- // Prefix = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix,
- // Position = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Position,
- // ProfileType = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).ProfileType,
- // OcId = Guid.Empty,
- // CitizenId = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).CitizenId,
- // FullName = $"{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).LastName}",
- // RequestInsignia = x.RequestInsignia.Name,
- // RequestInsigniaId = x.RequestInsignia.Id,
- // RequestInsigniaShortName = x.RequestInsignia.ShortName,
- // DateReceive = x.DateReceive,
- // OrganizationOrganizationSend = x.OrganizationOrganizationSend,
- // OrganizationOrganizationReceive = x.OrganizationOrganizationReceive,
- // Status = x.Status,
- // Issue = x.Issue,
- // Date = x.Date,
- // VolumeNo = x.VolumeNo,
- // Section = x.Section,
- // Page = x.Page,
- // No = x.No,
- // DatePayment = x.DatePayment,
- // TypePayment = x.TypePayment,
- // Address = x.Address,
- // Number = x.Number,
- // Salary = x.Salary,
- // DateReceiveInsignia = x.DateReceiveInsignia,
- // DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id,
- // OrgReceiveInsignia = x.OrgReceiveInsignia == null || x.OrgReceiveInsignia.OrganizationOrganization == null ? "-" : x.OrgReceiveInsignia.OrganizationOrganization.Name,
- // DateReturnInsignia = x.DateReturnInsignia,
- // DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id,
- // OrgReturnInsignia = x.OrgReturnInsignia == null || x.OrgReturnInsignia.OrganizationOrganization == null ? "-" : x.OrgReturnInsignia.OrganizationOrganization.Name,
- // }).ToListAsync();
-
- var _insigniaNoteProfiles = new List();
- foreach (var insigniaNoteProfile in insigniaNoteProfiles)
- {
- _insigniaNoteProfiles.Add(
- new
- {
- insigniaNoteProfile.Id,
- insigniaNoteProfile.Prefix,
- insigniaNoteProfile.Position,
- insigniaNoteProfile.CitizenId,
- insigniaNoteProfile.ProfileType,
- insigniaNoteProfile.FullName,
- insigniaNoteProfile.RequestInsignia,
- insigniaNoteProfile.RequestInsigniaId,
- insigniaNoteProfile.RequestInsigniaShortName,
- insigniaNoteProfile.DateReceive,
- insigniaNoteProfile.OrganizationOrganizationSend,
- insigniaNoteProfile.OrganizationOrganizationReceive,
- insigniaNoteProfile.Status,
- insigniaNoteProfile.Issue,
- insigniaNoteProfile.Date,
- insigniaNoteProfile.VolumeNo,
- insigniaNoteProfile.Section,
- insigniaNoteProfile.Page,
- insigniaNoteProfile.No,
- insigniaNoteProfile.DatePayment,
- insigniaNoteProfile.TypePayment,
- insigniaNoteProfile.Address,
- insigniaNoteProfile.Number,
- insigniaNoteProfile.Salary,
- insigniaNoteProfile.DateReceiveInsignia,
- DocReceiveInsignia = insigniaNoteProfile.DocReceiveInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReceiveInsignia),
- insigniaNoteProfile.OrgReceiveInsignia,
- insigniaNoteProfile.DateReturnInsignia,
- DocReturnInsignia = insigniaNoteProfile.DocReturnInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReturnInsignia),
- insigniaNoteProfile.OrgReturnInsignia,
- }
- );
- }
-
- return Success(_insigniaNoteProfiles);
- }
-
- ///
- /// Get รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
- ///
- /// Id บุคคลในบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("note/{insigniaNoteProfileId:length(36)}")]
- public async Task> GetListNoteProfile(Guid insigniaNoteProfileId)
- {
- var insigniaNoteProfile = await _context.InsigniaNoteProfiles
- .Where(x => x.Id == insigniaNoteProfileId)
- .Select(x => new
- {
- Id = x.Id,
- Prefix = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix,
- Position = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Position,
- ProfileType = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).ProfileType,
- OcId = Guid.Empty,
- CitizenId = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).CitizenId,
- FullName = $"{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).LastName}",
- RequestInsignia = x.RequestInsignia.Name,
- RequestInsigniaId = x.RequestInsignia.Id,
- RequestInsigniaShortName = x.RequestInsignia.ShortName,
- DateReceive = x.DateReceive,
- OrganizationOrganizationSend = x.OrganizationOrganizationSend,
- OrganizationOrganizationReceive = x.OrganizationOrganizationReceive,
- Status = x.Status,
- Issue = x.Issue,
- Date = x.Date,
- VolumeNo = x.VolumeNo,
- Section = x.Section,
- Page = x.Page,
- No = x.No,
- DatePayment = x.DatePayment,
- TypePayment = x.TypePayment,
- Address = x.Address,
- Number = x.Number,
- Salary = x.Salary,
- }).FirstOrDefaultAsync();
- var _insigniaNoteProfile = new
- {
- insigniaNoteProfile.Id,
- insigniaNoteProfile.Prefix,
- insigniaNoteProfile.Position,
- insigniaNoteProfile.CitizenId,
- insigniaNoteProfile.ProfileType,
- insigniaNoteProfile.FullName,
- insigniaNoteProfile.RequestInsignia,
- insigniaNoteProfile.RequestInsigniaId,
- insigniaNoteProfile.RequestInsigniaShortName,
- insigniaNoteProfile.DateReceive,
- insigniaNoteProfile.OrganizationOrganizationSend,
- OrganizationOrganizationReceive = insigniaNoteProfile.OrganizationOrganizationReceive == null ? (insigniaNoteProfile.OcId == null ? null : FindOCFullPath(insigniaNoteProfile.OcId, true)) : insigniaNoteProfile.OrganizationOrganizationReceive,
- insigniaNoteProfile.Status,
- insigniaNoteProfile.Issue,
- insigniaNoteProfile.Date,
- insigniaNoteProfile.VolumeNo,
- insigniaNoteProfile.Section,
- insigniaNoteProfile.Page,
- insigniaNoteProfile.No,
- insigniaNoteProfile.DatePayment,
- insigniaNoteProfile.TypePayment,
- insigniaNoteProfile.Address,
- insigniaNoteProfile.Number,
- insigniaNoteProfile.Salary,
- };
-
- return Success(_insigniaNoteProfile);
- }
-
- ///
- /// เพิ่ม/แก้ไขรายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("note/{insigniaNoteId:length(36)}")]
- public async Task> AddNoteProfile([FromBody] InsigniaNoteRequest req, Guid insigniaNoteId)
- {
- var profile = _userProfileRepository.GetOfficerProfileByCitizenId(req.CitizanId, AccessToken);
- if (profile == null)
- return Error(GlobalMessages.DataNotFound);
-
- var insignia = await _context.Insignias
- .Include(x => x.InsigniaType)
- .FirstOrDefaultAsync(x => x.Id == req.InsigniaId);
- if (insignia == null)
- return Error(GlobalMessages.InsigniaNotFound);
-
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
- var profileInsignia = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == profile.Id);
-
- if (profileInsignia == null)
- {
- var insigniaNoteProfile = new InsigniaNoteProfile
+ await _context.AddAsync(new InsigniaRequestProfile
{
- Salary = profile.ProfileSalary == null || profile.ProfileSalary.Count() == 0 ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
- IsApprove = true,
Status = "PENDING",
ProfileId = profile.Id,
- Issue = req.Issue,
- Number = req.Number,
- DateReceive = req.DateReceive,
- Date = req.Date,
- VolumeNo = req.VolumeNo,
- Section = req.Section,
- Page = req.Page,
- No = req.No,
- DatePayment = req.DatePayment,
- TypePayment = req.TypePayment,
- Address = req.Address,
RequestInsignia = insignia,
- OrganizationOrganizationReceive = req.OrganizationOrganizationReceive,
- OrganizationOrganizationSend = req.OrganizationOrganizationSend,
- InsigniaNote = insigniaNote,
+ Request = insigniaRequest,
+ Reason = req.Reason,
+ RequestDate = DateTime.Now,
+ MatchingConditions = System.Text.Json.JsonSerializer.Serialize(new List()), // serialize to string
+ Salary = profile.ProfileSalary == null || profile.ProfileSalary.Count == 0 ? 0 :
+ profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount, //profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
- };
- if (req.DateReceive != null && req.Date != null)
+ });
+
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// แก้ไขรายชื่อผู้ได้รับเครื่องราช
+ ///
+ /// Id รายชื่อคนที่ยื่นของในรอบ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("{insigniaRequestProfileId:length(36)}")]
+ public async Task> UpdateUserToRequestInsignia([FromBody] UpdateUserRequestInsigniaRequest req, Guid insigniaRequestProfileId)
+ {
+ var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
+ if (insigniaRequestProfile == null)
+ return Error(GlobalMessages.InsigniaRequestProfileNotFound);
+ var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
+ if (insignia == null)
+ return Error(GlobalMessages.InsigniaNotFound);
+
+ insigniaRequestProfile.RequestInsignia = insignia;
+ insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
+ insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช
+ ///
+ /// Id รอบการยื่นขอ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("send/note/{insigniaPeriodId:length(36)}")]
+ public async Task> SendPeriodToNote([FromBody] InsigniaNoteNameRequest req, Guid insigniaPeriodId)
+ {
+ var insigniaPeriod = await _context.InsigniaPeriods
+ .Include(x => x.InsigniaRequests)
+ .Include(x => x.ReliefDoc)
+ .FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ insigniaPeriod.IsLock = true;
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ // .ThenInclude(x => x.Profile)
+ .Include(x => x.InsigniaNoteProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .FirstOrDefaultAsync(x => x.Year == insigniaPeriod.Year);
+ if (insigniaNote == null)
{
- insigniaNoteProfile.Status = "DONE";
-
- var profileInsigniaBody = new PostProfileInsigniaDto
+ insigniaNote = new InsigniaNote
{
- profileId = insigniaNoteProfile.ProfileId.Value,
- year = insigniaNote.Year,
- no = insigniaNoteProfile.No,
- volumeNo = insigniaNoteProfile.VolumeNo,
- section = insigniaNoteProfile.Section,
- page = insigniaNoteProfile.Page,
- receiveDate = insigniaNoteProfile.DateReceive.Value,
- dateAnnounce = insigniaNoteProfile.Date.Value,
- insigniaId = insigniaNoteProfile.RequestInsignia.Id,
- issue = insigniaNoteProfile.Issue,
- note = "",
- refCommandDate = null,
- refCommandNo = "",
- volume = "",
-
+ // Round = insigniaPeriod.Round,
+ Name = req.Name,
+ Year = insigniaPeriod.Year,
+ // StartDate = insigniaPeriod.StartDate,
+ // EndDate = insigniaPeriod.EndDate,
+ // Amount = insigniaPeriod.Amount,
+ // ReliefDoc = insigniaPeriod.ReliefDoc,
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ CreatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
};
- await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken);
+ await _context.InsigniaNotes.AddAsync(insigniaNote);
+ await _context.SaveChangesAsync();
+ insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .Include(x => x.InsigniaNoteProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNote.Id);
+ }
+ var requestOlds = await _context.InsigniaRequests
+ .Where(p => p.Period == insigniaPeriod)
+ .Where(p => p.RequestStatus == "st6")
+ .ToListAsync();
+ foreach (var requestOld in requestOlds)
+ {
+ var profileOlds = await _context.InsigniaRequestProfiles
+ //.Include(x => x.Profile)
+ .Include(x => x.RequestInsignia)
+ .Where(p => p.Request == requestOld)
+ .ToListAsync();
+
+ foreach (var profileOld in profileOlds)
+ {
+ if (profileOld.Status == "DELETE" || profileOld.Status == "REJECT")
+ continue;
+ var noreProfileOld = insigniaNote.InsigniaNoteProfiles
+ .Where(x => x.ProfileId == profileOld.ProfileId)
+ .FirstOrDefault();
+ if (noreProfileOld != null)
+ {
+ noreProfileOld.RequestDate = profileOld.RequestDate;
+ noreProfileOld.Salary = profileOld.Salary;
+ noreProfileOld.IsApprove = profileOld.IsApprove;
+ noreProfileOld.RequestInsignia = profileOld.RequestInsignia;
+ noreProfileOld.CreatedFullName = FullName ?? "System Administrator";
+ noreProfileOld.CreatedUserId = UserId ?? "";
+ noreProfileOld.CreatedAt = DateTime.Now;
+ noreProfileOld.LastUpdateFullName = FullName ?? "System Administrator";
+ noreProfileOld.LastUpdateUserId = UserId ?? "";
+ noreProfileOld.LastUpdatedAt = DateTime.Now;
+ }
+ else
+ {
+ if (profileOld.ProfileId == null)
+ continue;
+ await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile
+ {
+ RequestDate = profileOld.RequestDate,
+ Salary = profileOld.Salary,
+ IsApprove = profileOld.IsApprove,
+ Status = "PENDING",
+ ProfileId = profileOld.ProfileId,
+ RequestInsignia = profileOld.RequestInsignia,
+ OrganizationOrganizationSend = null,
+ InsigniaNote = insigniaNote,
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ CreatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ });
+ }
+ }
+ }
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช(อัพเดทstatus)
+ ///
+ /// Id รอบการยื่นขอ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("send/note/{insigniaPeriodId:length(36)}")]
+ public async Task> SendPeriodToNoteUpdateStatus(Guid insigniaPeriodId)
+ {
+ var insigniaPeriod = await _context.InsigniaPeriods
+ .FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ insigniaPeriod.IsLock = true;
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// list รอบบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("note")]
+ public async Task> GetListNote()
+ {
+ var insigniaNotes = await _context.InsigniaNotes.AsQueryable()
+ .OrderByDescending(x => x.Year)
+ // .ThenByDescending(x => x.StartDate)
+ .Select(p => new
+ {
+ Id = p.Id,
+ // Amount = p.Amount,
+ Name = p.Name,
+ // Round = p.Round,
+ // Start = p.StartDate,
+ // End = p.EndDate,
+ Year = p.Year,
+ // Doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
+ })
+ .ToListAsync();
+ // var data = new List();
+ // foreach (var insigniaNote in insigniaNotes)
+ // {
+ // var _data = new
+ // {
+ // Id = insigniaNote.Id,
+ // Amount = insigniaNote.Amount,
+ // Name = insigniaNote.Name,
+ // Round = insigniaNote.Round,
+ // Start = insigniaNote.Start,
+ // End = insigniaNote.End,
+ // Year = insigniaNote.Year,
+ // Doc = insigniaNote.Doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNote.Doc),
+ // };
+ // data.Add(_data);
+ // }
+
+ return Success(insigniaNotes);
+ }
+
+ ///
+ /// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("note/search")]
+ public async Task> GetListNoteProfile([FromBody] InsigniaNoteSearchRequest req)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var insigniaType = await _context.InsigniaTypes
+ .FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId);
+ if (insigniaType == null)
+ return Error(GlobalMessages.InsigniaTypeNotFound);
+
+ var rawNoteProfiles = await _context.InsigniaNoteProfiles
+ .Where(x => x.InsigniaNote == insigniaNote)
+ .Where(x => x.RequestInsignia.InsigniaType == insigniaType)
+ .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
+ .Select(x => new
+ {
+ Id = x.Id,
+ Profile = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken),
+ OcId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), // TODO: ต้องมาแก้ไข
+ RequestInsignia = x.RequestInsignia.Name,
+ RequestInsigniaId = x.RequestInsignia.Id,
+ RequestInsigniaShortName = x.RequestInsignia.ShortName,
+ DateReceive = x.DateReceive,
+ OrganizationOrganizationSend = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
+ OrganizationOrganizationReceive = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
+ Status = x.Status,
+ Issue = x.Issue,
+ Date = x.Date,
+ VolumeNo = x.VolumeNo,
+ Section = x.Section,
+ Page = x.Page,
+ No = x.No,
+ DatePayment = x.DatePayment,
+ TypePayment = x.TypePayment,
+ Address = x.Address,
+ Number = x.Number,
+ Salary = x.Salary,
+ DateReceiveInsignia = x.DateReceiveInsignia,
+ DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id,
+ OrgReceiveInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
+ DateReturnInsignia = x.DateReturnInsignia,
+ DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id,
+ OrgReturnInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode
+ })
+ .ToListAsync();
+
+ var insigniaNoteProfiles = rawNoteProfiles
+ .Select(x => new
+ {
+ Id = x.Id,
+ Prefix = x.Profile == null ? "" : x.Profile.Prefix,
+ Position = x.Profile == null ? "" : x.Profile.Position,
+ ProfileType = x.Profile == null ? "" : x.Profile.ProfileType,
+ x.OcId,
+ CitizenId = x.Profile == null ? "" : x.Profile.CitizenId,
+ FullName = x.Profile == null ? "" : $"{x.Profile.Prefix}{x.Profile.FirstName} {x.Profile.LastName}",
+ RequestInsignia = x.RequestInsignia,
+ RequestInsigniaId = x.RequestInsigniaId,
+ RequestInsigniaShortName = x.RequestInsigniaShortName,
+ DateReceive = x.DateReceive,
+ OrganizationOrganizationSend = x.OrganizationOrganizationSend,
+ OrganizationOrganizationReceive = x.OrganizationOrganizationReceive,
+ Status = x.Status,
+ Issue = x.Issue,
+ Date = x.Date,
+ VolumeNo = x.VolumeNo,
+ Section = x.Section,
+ Page = x.Page,
+ No = x.No,
+ DatePayment = x.DatePayment,
+ TypePayment = x.TypePayment,
+ Address = x.Address,
+ Number = x.Number,
+ Salary = x.Salary,
+ DateReceiveInsignia = x.DateReceiveInsignia,
+ DocReceiveInsignia = x.DocReceiveInsignia,
+ OrgReceiveInsignia = x.OrgReceiveInsignia,
+ DateReturnInsignia = x.DateReturnInsignia,
+ DocReturnInsignia = x.DocReturnInsignia,
+ OrgReturnInsignia = x.OrgReturnInsignia,
+ })
+ .ToList();
+
+ //var insigniaNoteProfiles = await _context.InsigniaNoteProfiles
+ // .Where(x => x.InsigniaNote == insigniaNote)
+ // .Where(x => x.RequestInsignia.InsigniaType == insigniaType)
+ // .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
+ // .Select(x => new
+ // {
+ // Id = x.Id,
+ // Prefix = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix,
+ // Position = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Position,
+ // ProfileType = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).ProfileType,
+ // OcId = Guid.Empty,
+ // CitizenId = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).CitizenId,
+ // FullName = $"{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).LastName}",
+ // RequestInsignia = x.RequestInsignia.Name,
+ // RequestInsigniaId = x.RequestInsignia.Id,
+ // RequestInsigniaShortName = x.RequestInsignia.ShortName,
+ // DateReceive = x.DateReceive,
+ // OrganizationOrganizationSend = x.OrganizationOrganizationSend,
+ // OrganizationOrganizationReceive = x.OrganizationOrganizationReceive,
+ // Status = x.Status,
+ // Issue = x.Issue,
+ // Date = x.Date,
+ // VolumeNo = x.VolumeNo,
+ // Section = x.Section,
+ // Page = x.Page,
+ // No = x.No,
+ // DatePayment = x.DatePayment,
+ // TypePayment = x.TypePayment,
+ // Address = x.Address,
+ // Number = x.Number,
+ // Salary = x.Salary,
+ // DateReceiveInsignia = x.DateReceiveInsignia,
+ // DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id,
+ // OrgReceiveInsignia = x.OrgReceiveInsignia == null || x.OrgReceiveInsignia.OrganizationOrganization == null ? "-" : x.OrgReceiveInsignia.OrganizationOrganization.Name,
+ // DateReturnInsignia = x.DateReturnInsignia,
+ // DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id,
+ // OrgReturnInsignia = x.OrgReturnInsignia == null || x.OrgReturnInsignia.OrganizationOrganization == null ? "-" : x.OrgReturnInsignia.OrganizationOrganization.Name,
+ // }).ToListAsync();
+
+ var _insigniaNoteProfiles = new List();
+ foreach (var insigniaNoteProfile in insigniaNoteProfiles)
+ {
+ _insigniaNoteProfiles.Add(
+ new
+ {
+ insigniaNoteProfile.Id,
+ insigniaNoteProfile.Prefix,
+ insigniaNoteProfile.Position,
+ insigniaNoteProfile.CitizenId,
+ insigniaNoteProfile.ProfileType,
+ insigniaNoteProfile.FullName,
+ insigniaNoteProfile.RequestInsignia,
+ insigniaNoteProfile.RequestInsigniaId,
+ insigniaNoteProfile.RequestInsigniaShortName,
+ insigniaNoteProfile.DateReceive,
+ insigniaNoteProfile.OrganizationOrganizationSend,
+ insigniaNoteProfile.OrganizationOrganizationReceive,
+ insigniaNoteProfile.Status,
+ insigniaNoteProfile.Issue,
+ insigniaNoteProfile.Date,
+ insigniaNoteProfile.VolumeNo,
+ insigniaNoteProfile.Section,
+ insigniaNoteProfile.Page,
+ insigniaNoteProfile.No,
+ insigniaNoteProfile.DatePayment,
+ insigniaNoteProfile.TypePayment,
+ insigniaNoteProfile.Address,
+ insigniaNoteProfile.Number,
+ insigniaNoteProfile.Salary,
+ insigniaNoteProfile.DateReceiveInsignia,
+ DocReceiveInsignia = insigniaNoteProfile.DocReceiveInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReceiveInsignia),
+ insigniaNoteProfile.OrgReceiveInsignia,
+ insigniaNoteProfile.DateReturnInsignia,
+ DocReturnInsignia = insigniaNoteProfile.DocReturnInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReturnInsignia),
+ insigniaNoteProfile.OrgReturnInsignia,
+ }
+ );
}
- // await _context.ProfileInsignias.AddAsync(new ProfileInsignia
- // {
- // Year = insigniaNote.Year,
- // No = req.No,
- // Issue = req.VolumeNo,
- // VolumeNo = req.VolumeNo,
- // // Volume = req.Volume,
- // Section = req.Section,
- // Page = req.Page,
- // DateAnnounce = req.Date,
- // ReceiveDate = req.DateReceive,
- // InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
- // Insignia = insignia,
- // // RefCommandNo = req.RefCommandNo,
- // // RefCommandDate = req.RefCommandDate,
- // ProfileId = profile.Id,
- // CreatedFullName = FullName ?? "System Administrator",
- // CreatedUserId = UserId ?? "",
- // CreatedAt = DateTime.Now,
- // LastUpdateFullName = FullName ?? "System Administrator",
- // LastUpdateUserId = UserId ?? "",
- // LastUpdatedAt = DateTime.Now,
- // });
- //}
- //await _context.InsigniaNoteProfiles.AddAsync(insigniaNoteProfile);
+ return Success(_insigniaNoteProfiles);
}
- else
+
+ ///
+ /// Get รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
+ ///
+ /// Id บุคคลในบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("note/{insigniaNoteProfileId:length(36)}")]
+ public async Task> GetListNoteProfile(Guid insigniaNoteProfileId)
{
- profileInsignia.DatePayment = req.DatePayment;
- profileInsignia.TypePayment = req.TypePayment;
- profileInsignia.Address = req.Address;
- if (profileInsignia.Status != "DONE")
+ var insigniaNoteProfile = await _context.InsigniaNoteProfiles
+ .Where(x => x.Id == insigniaNoteProfileId)
+ .Select(x => new
+ {
+ Id = x.Id,
+ Prefix = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix,
+ Position = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Position,
+ ProfileType = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).ProfileType,
+ OcId = Guid.Empty,
+ CitizenId = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).CitizenId,
+ FullName = $"{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).LastName}",
+ RequestInsignia = x.RequestInsignia.Name,
+ RequestInsigniaId = x.RequestInsignia.Id,
+ RequestInsigniaShortName = x.RequestInsignia.ShortName,
+ DateReceive = x.DateReceive,
+ OrganizationOrganizationSend = x.OrganizationOrganizationSend,
+ OrganizationOrganizationReceive = x.OrganizationOrganizationReceive,
+ Status = x.Status,
+ Issue = x.Issue,
+ Date = x.Date,
+ VolumeNo = x.VolumeNo,
+ Section = x.Section,
+ Page = x.Page,
+ No = x.No,
+ DatePayment = x.DatePayment,
+ TypePayment = x.TypePayment,
+ Address = x.Address,
+ Number = x.Number,
+ Salary = x.Salary,
+ }).FirstOrDefaultAsync();
+ var _insigniaNoteProfile = new
{
- profileInsignia.Issue = req.Issue;
- profileInsignia.Number = req.Number;
- profileInsignia.DateReceive = req.DateReceive;
- profileInsignia.Date = req.Date;
- profileInsignia.VolumeNo = req.VolumeNo;
- profileInsignia.Section = req.Section;
- profileInsignia.Page = req.Page;
- profileInsignia.No = req.No;
- // profileInsignia.DatePayment = req.DatePayment;
- // profileInsignia.TypePayment = req.TypePayment;
- // profileInsignia.Address = req.Address;
- profileInsignia.RequestInsignia = insignia;
- profileInsignia.LastUpdateFullName = FullName ?? "System Administrator";
- profileInsignia.LastUpdateUserId = UserId ?? "";
- profileInsignia.LastUpdatedAt = DateTime.Now;
+ insigniaNoteProfile.Id,
+ insigniaNoteProfile.Prefix,
+ insigniaNoteProfile.Position,
+ insigniaNoteProfile.CitizenId,
+ insigniaNoteProfile.ProfileType,
+ insigniaNoteProfile.FullName,
+ insigniaNoteProfile.RequestInsignia,
+ insigniaNoteProfile.RequestInsigniaId,
+ insigniaNoteProfile.RequestInsigniaShortName,
+ insigniaNoteProfile.DateReceive,
+ insigniaNoteProfile.OrganizationOrganizationSend,
+ OrganizationOrganizationReceive = insigniaNoteProfile.OrganizationOrganizationReceive == null ? (insigniaNoteProfile.OcId == null ? null : FindOCFullPath(insigniaNoteProfile.OcId, true)) : insigniaNoteProfile.OrganizationOrganizationReceive,
+ insigniaNoteProfile.Status,
+ insigniaNoteProfile.Issue,
+ insigniaNoteProfile.Date,
+ insigniaNoteProfile.VolumeNo,
+ insigniaNoteProfile.Section,
+ insigniaNoteProfile.Page,
+ insigniaNoteProfile.No,
+ insigniaNoteProfile.DatePayment,
+ insigniaNoteProfile.TypePayment,
+ insigniaNoteProfile.Address,
+ insigniaNoteProfile.Number,
+ insigniaNoteProfile.Salary,
+ };
+
+ return Success(_insigniaNoteProfile);
+ }
+
+ ///
+ /// เพิ่ม/แก้ไขรายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("note/{insigniaNoteId:length(36)}")]
+ public async Task> AddNoteProfile([FromBody] InsigniaNoteRequest req, Guid insigniaNoteId)
+ {
+ var profile = _userProfileRepository.GetOfficerProfileByCitizenId(req.CitizanId, AccessToken);
+
+
+ if (profile == null)
+ return Error(GlobalMessages.DataNotFound);
+
+ var insignia = await _context.Insignias
+ .Include(x => x.InsigniaType)
+ .FirstOrDefaultAsync(x => x.Id == req.InsigniaId);
+ if (insignia == null)
+ return Error(GlobalMessages.InsigniaNotFound);
+
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+
+ var profileInsignia = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == profile.Id);
+
+ if (profileInsignia == null)
+ {
+ var insigniaNoteProfile = new InsigniaNoteProfile
+ {
+ Salary = profile.ProfileSalary == null || profile.ProfileSalary.Count() == 0 ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
+ IsApprove = true,
+ Status = "PENDING",
+ ProfileId = profile.Id,
+ Issue = req.Issue,
+ Number = req.Number,
+ DateReceive = req.DateReceive,
+ Date = req.Date,
+ VolumeNo = req.VolumeNo,
+ Section = req.Section,
+ Page = req.Page,
+ No = req.No,
+ DatePayment = req.DatePayment,
+ TypePayment = req.TypePayment,
+ Address = req.Address,
+ RequestInsignia = insignia,
+ OrganizationOrganizationReceive = req.OrganizationOrganizationReceive,
+ OrganizationOrganizationSend = req.OrganizationOrganizationSend,
+ InsigniaNote = insigniaNote,
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ CreatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ };
if (req.DateReceive != null && req.Date != null)
{
- profileInsignia.Status = "DONE";
+ insigniaNoteProfile.Status = "DONE";
var profileInsigniaBody = new PostProfileInsigniaDto
{
- profileId = profileInsignia.ProfileId.Value,
+ profileId = insigniaNoteProfile.ProfileId.Value,
year = insigniaNote.Year,
- no = profileInsignia.No,
- volumeNo = profileInsignia.VolumeNo,
- section = profileInsignia.Section,
- page = profileInsignia.Page,
- receiveDate = profileInsignia.DateReceive.Value,
- dateAnnounce = profileInsignia.Date.Value,
- insigniaId = profileInsignia.RequestInsignia.Id,
- issue = profileInsignia.Issue,
+ no = insigniaNoteProfile.No,
+ volumeNo = insigniaNoteProfile.VolumeNo,
+ section = insigniaNoteProfile.Section,
+ page = insigniaNoteProfile.Page,
+ receiveDate = insigniaNoteProfile.DateReceive.Value,
+ dateAnnounce = insigniaNoteProfile.Date.Value,
+ insigniaId = insigniaNoteProfile.RequestInsignia.Id,
+ issue = insigniaNoteProfile.Issue,
note = "",
refCommandDate = null,
refCommandNo = "",
@@ -1686,194 +1646,446 @@ namespace BMA.EHR.Insignia.Service.Controllers
};
await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken);
- //await _context.ProfileInsignias.AddAsync(new ProfileInsignia
- //{
- // Year = insigniaNote.Year,
- // No = req.No,
- // Issue = req.VolumeNo,
- // VolumeNo = req.VolumeNo,
- // //Volume = req.Volume,
- // Section = req.Section,
- // Page = req.Page,
- // DateAnnounce = req.Date,
- // ReceiveDate = req.DateReceive,
- // InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
- // Insignia = insignia,
- // // RefCommandNo = req.RefCommandNo,
- // // RefCommandDate = req.RefCommandDate,
- // ProfileId = profile.Id,
- // CreatedFullName = FullName ?? "System Administrator",
- // CreatedUserId = UserId ?? "",
- // CreatedAt = DateTime.Now,
- // LastUpdateFullName = FullName ?? "System Administrator",
- // LastUpdateUserId = UserId ?? "",
- // LastUpdatedAt = DateTime.Now,
- //});
}
- }
- }
- await _context.SaveChangesAsync();
- return Success();
- }
-
- ///
- /// เพิ่มเอกสารบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("note/doc/{insigniaNoteId:length(36)}")]
- public async Task> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId)
- {
- var insigniaNote = await _context.InsigniaNotes
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
- if (Request.Form.Files != null && Request.Form.Files.Count != 0)
- {
- foreach (var file in Request.Form.Files)
- {
- var fileExtension = Path.GetExtension(file.FileName);
-
- var doc = await _documentService.UploadFileAsync(file, req.Name == null ? file.FileName : req.Name);
- var _doc = await _context.Documents.AsQueryable()
- .FirstOrDefaultAsync(x => x.Id == doc.Id);
- if (_doc != null)
- {
- await _context.InsigniaNoteDocs.AddAsync(new InsigniaNoteDoc
- {
- Reason = req.Reason,
- Document = _doc,
- InsigniaNote = insigniaNote,
- CreatedFullName = FullName ?? "System Administrator",
- CreatedUserId = UserId ?? "",
- CreatedAt = DateTime.Now,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- });
- }
- }
- }
- await _context.SaveChangesAsync();
-
- return Success();
- }
-
- ///
- /// List เอกสารบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("note/doc/{insigniaNoteId:length(36)}")]
- public async Task> GetDocumentProfile(Guid insigniaNoteId)
- {
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteDocs)
- .ThenInclude(x => x.Document)
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
- var insigniaNoteDocs = new List();
- foreach (var doc in insigniaNote.InsigniaNoteDocs)
- {
- var _doc = new
- {
- Reason = doc.Reason,
- FileName = doc.Document.FileName,
- PathName = await _documentService.ImagesPath(doc.Document.Id)
- };
- insigniaNoteDocs.Add(_doc);
- }
- return Success(insigniaNoteDocs);
- }
-
- ///
- /// import บันทึกผลการได้รับเครื่องราชฯ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("import/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
- public async Task> ImportReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
- {
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .Include(x => x.InsigniaNoteProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .ThenInclude(x => x.InsigniaType)
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
- if (Request.Form.Files == null || Request.Form.Files.Count == 0)
- {
- return Error(GlobalMessages.NoFileToUpload);
- }
- var file = Request.Form.Files[0];
- if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
- {
- return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
- }
- var items = await ReadExcelImportReceive(file);
- foreach (var item in items)
- {
- if (item.DateReceive == null || item.Date == null)
- continue;
- var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
- var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
- if (profile == null)
- {
-
- //var _profile = await _context.Profiles
- // .Include(x => x.Salaries)
- // .FirstOrDefaultAsync(x => x.CitizenId == item.CitizanId);
- //if (_profile == null)
- // continue;
- var _insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
- if (_insignia == null)
- continue;
- profile = new InsigniaNoteProfile
- {
- RequestDate = DateTime.Now,
- Salary = pf.ProfileSalary == null ? 0 : pf.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
- IsApprove = true,
- Status = "PENDIND",
- Number = item.Number,
- RequestInsignia = _insignia,
- DateReceive = item.DateReceive,
- Date = item.Date,
- VolumeNo = item.VolumeNo,
- Section = item.Section,
- Page = item.Page,
- No = item.No,
- ProfileId = pf.Id,
- InsigniaNote = insigniaNote,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- };
- await _context.InsigniaNoteProfiles.AddAsync(profile);
+ // await _context.ProfileInsignias.AddAsync(new ProfileInsignia
+ // {
+ // Year = insigniaNote.Year,
+ // No = req.No,
+ // Issue = req.VolumeNo,
+ // VolumeNo = req.VolumeNo,
+ // // Volume = req.Volume,
+ // Section = req.Section,
+ // Page = req.Page,
+ // DateAnnounce = req.Date,
+ // ReceiveDate = req.DateReceive,
+ // InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
+ // Insignia = insignia,
+ // // RefCommandNo = req.RefCommandNo,
+ // // RefCommandDate = req.RefCommandDate,
+ // ProfileId = profile.Id,
+ // CreatedFullName = FullName ?? "System Administrator",
+ // CreatedUserId = UserId ?? "",
+ // CreatedAt = DateTime.Now,
+ // LastUpdateFullName = FullName ?? "System Administrator",
+ // LastUpdateUserId = UserId ?? "",
+ // LastUpdatedAt = DateTime.Now,
+ // });
+ //}
+ //await _context.InsigniaNoteProfiles.AddAsync(insigniaNoteProfile);
}
else
{
+ profileInsignia.DatePayment = req.DatePayment;
+ profileInsignia.TypePayment = req.TypePayment;
+ profileInsignia.Address = req.Address;
+ if (profileInsignia.Status != "DONE")
+ {
+ profileInsignia.Issue = req.Issue;
+ profileInsignia.Number = req.Number;
+ profileInsignia.DateReceive = req.DateReceive;
+ profileInsignia.Date = req.Date;
+ profileInsignia.VolumeNo = req.VolumeNo;
+ profileInsignia.Section = req.Section;
+ profileInsignia.Page = req.Page;
+ profileInsignia.No = req.No;
+ // profileInsignia.DatePayment = req.DatePayment;
+ // profileInsignia.TypePayment = req.TypePayment;
+ // profileInsignia.Address = req.Address;
+ profileInsignia.RequestInsignia = insignia;
+ profileInsignia.LastUpdateFullName = FullName ?? "System Administrator";
+ profileInsignia.LastUpdateUserId = UserId ?? "";
+ profileInsignia.LastUpdatedAt = DateTime.Now;
+ if (req.DateReceive != null && req.Date != null)
+ {
+ profileInsignia.Status = "DONE";
+
+ var profileInsigniaBody = new PostProfileInsigniaDto
+ {
+ profileId = profileInsignia.ProfileId.Value,
+ year = insigniaNote.Year,
+ no = profileInsignia.No,
+ volumeNo = profileInsignia.VolumeNo,
+ section = profileInsignia.Section,
+ page = profileInsignia.Page,
+ receiveDate = profileInsignia.DateReceive.Value,
+ dateAnnounce = profileInsignia.Date.Value,
+ insigniaId = profileInsignia.RequestInsignia.Id,
+ issue = profileInsignia.Issue,
+ note = "",
+ refCommandDate = null,
+ refCommandNo = "",
+ volume = "",
+
+ };
+ await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken);
+ //await _context.ProfileInsignias.AddAsync(new ProfileInsignia
+ //{
+ // Year = insigniaNote.Year,
+ // No = req.No,
+ // Issue = req.VolumeNo,
+ // VolumeNo = req.VolumeNo,
+ // //Volume = req.Volume,
+ // Section = req.Section,
+ // Page = req.Page,
+ // DateAnnounce = req.Date,
+ // ReceiveDate = req.DateReceive,
+ // InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
+ // Insignia = insignia,
+ // // RefCommandNo = req.RefCommandNo,
+ // // RefCommandDate = req.RefCommandDate,
+ // ProfileId = profile.Id,
+ // CreatedFullName = FullName ?? "System Administrator",
+ // CreatedUserId = UserId ?? "",
+ // CreatedAt = DateTime.Now,
+ // LastUpdateFullName = FullName ?? "System Administrator",
+ // LastUpdateUserId = UserId ?? "",
+ // LastUpdatedAt = DateTime.Now,
+ //});
+ }
+ }
+ }
+
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// เพิ่มเอกสารบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("note/doc/{insigniaNoteId:length(36)}")]
+ public async Task> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+
+ if (Request.Form.Files != null && Request.Form.Files.Count != 0)
+ {
+ foreach (var file in Request.Form.Files)
+ {
+ var fileExtension = Path.GetExtension(file.FileName);
+
+ var doc = await _documentService.UploadFileAsync(file, req.Name == null ? file.FileName : req.Name);
+ var _doc = await _context.Documents.AsQueryable()
+ .FirstOrDefaultAsync(x => x.Id == doc.Id);
+ if (_doc != null)
+ {
+ await _context.InsigniaNoteDocs.AddAsync(new InsigniaNoteDoc
+ {
+ Reason = req.Reason,
+ Document = _doc,
+ InsigniaNote = insigniaNote,
+ CreatedFullName = FullName ?? "System Administrator",
+ CreatedUserId = UserId ?? "",
+ CreatedAt = DateTime.Now,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ });
+ }
+ }
+ }
+ await _context.SaveChangesAsync();
+
+ return Success();
+ }
+
+ ///
+ /// List เอกสารบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("note/doc/{insigniaNoteId:length(36)}")]
+ public async Task> GetDocumentProfile(Guid insigniaNoteId)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteDocs)
+ .ThenInclude(x => x.Document)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+ var insigniaNoteDocs = new List();
+ foreach (var doc in insigniaNote.InsigniaNoteDocs)
+ {
+ var _doc = new
+ {
+ Reason = doc.Reason,
+ FileName = doc.Document.FileName,
+ PathName = await _documentService.ImagesPath(doc.Document.Id)
+ };
+ insigniaNoteDocs.Add(_doc);
+ }
+ return Success(insigniaNoteDocs);
+ }
+
+ ///
+ /// import บันทึกผลการได้รับเครื่องราชฯ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("import/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> ImportReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .Include(x => x.InsigniaNoteProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .ThenInclude(x => x.InsigniaType)
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+
+ if (Request.Form.Files == null || Request.Form.Files.Count == 0)
+ {
+ return Error(GlobalMessages.NoFileToUpload);
+ }
+ var file = Request.Form.Files[0];
+ if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
+ {
+ return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
+ }
+ var items = await ReadExcelImportReceive(file);
+ foreach (var item in items)
+ {
+ if (item.DateReceive == null || item.Date == null)
+ continue;
+ var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
+ var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
+ if (profile == null)
+ {
+
+ //var _profile = await _context.Profiles
+ // .Include(x => x.Salaries)
+ // .FirstOrDefaultAsync(x => x.CitizenId == item.CitizanId);
+ //if (_profile == null)
+ // continue;
+ var _insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
+ if (_insignia == null)
+ continue;
+ profile = new InsigniaNoteProfile
+ {
+ RequestDate = DateTime.Now,
+ Salary = pf.ProfileSalary == null ? 0 : pf.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
+ IsApprove = true,
+ Status = "PENDIND",
+ Number = item.Number,
+ RequestInsignia = _insignia,
+ DateReceive = item.DateReceive,
+ Date = item.Date,
+ VolumeNo = item.VolumeNo,
+ Section = item.Section,
+ Page = item.Page,
+ No = item.No,
+ ProfileId = pf.Id,
+ InsigniaNote = insigniaNote,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ };
+ await _context.InsigniaNoteProfiles.AddAsync(profile);
+ }
+ else
+ {
+ if (profile.Status != "DONE")
+ {
+ profile.Number = item.Number;
+ profile.RequestInsignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia) == null ? profile.RequestInsignia : await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
+ profile.DateReceive = item.DateReceive;
+ profile.Date = item.Date;
+ profile.VolumeNo = item.VolumeNo;
+ profile.Section = item.Section;
+ profile.Page = item.Page;
+ profile.No = item.No;
+ profile.LastUpdateFullName = FullName ?? "System Administrator";
+ profile.LastUpdateUserId = UserId ?? "";
+ profile.LastUpdatedAt = DateTime.Now;
+ }
+ }
+ // if (profile.DateReceive == null || profile.Date == null)
+ // continue;
if (profile.Status != "DONE")
{
+
+
+
+ profile.Status = "DONE";
+
+
+ var profileInsignia = new PostProfileInsigniaDto
+ {
+ profileId = profile.ProfileId.Value,
+ year = insigniaNote.Year,
+ no = profile.No,
+ volumeNo = profile.VolumeNo,
+ section = profile.Section,
+ page = profile.Page,
+ receiveDate = profile.DateReceive.Value,
+ dateAnnounce = profile.Date.Value,
+ insigniaId = profile.RequestInsignia.Id,
+ issue = "",
+ note = "",
+ refCommandDate = null,
+ refCommandNo = "",
+ volume = "",
+
+ };
+ await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken);
+
+
+ }
+ }
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// import บันทึกผลใบกำกับเครื่องราชฯ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("import/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> ImportInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .Include(x => x.InsigniaNoteProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+
+ if (Request.Form.Files == null || Request.Form.Files.Count == 0)
+ {
+ return Error(GlobalMessages.NoFileToUpload);
+ }
+ var file = Request.Form.Files[0];
+ if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
+ {
+ return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
+ }
+ var items = await ReadExcelImportInvoice(file);
+ foreach (var item in items)
+ {
+ if (item.CitizanId == null) continue;
+ var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
+ var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
+ if (profile == null)
+ continue;
+ profile.Number = item.Number;
+ profile.DatePayment = item.DatePayment;
+ profile.TypePayment = item.TypePayment;
+ profile.Address = item.Address;
+ profile.LastUpdateFullName = FullName ?? "System Administrator";
+ profile.LastUpdateUserId = UserId ?? "";
+ profile.LastUpdatedAt = DateTime.Now;
+ }
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// preview บันทึกผลการได้รับเครื่องราชฯ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("preview/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> PreviewReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .Include(x => x.InsigniaNoteProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .ThenInclude(x => x.InsigniaType)
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Prefix)
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Position)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+
+ if (Request.Form.Files == null || Request.Form.Files.Count == 0)
+ {
+ return Error(GlobalMessages.NoFileToUpload);
+ }
+ var file = Request.Form.Files[0];
+ if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
+ {
+ return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
+ }
+ var items = await ReadExcelImportReceive(file);
+ var _insigniaNoteProfiles = new List();
+ foreach (var item in items)
+ {
+ var _profile = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
+ var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == _profile.Id);
+ if (profile == null)
+ {
+
+
+ //var _profile = await _context.Profiles
+ // .Include(x => x.Salaries)
+ // .FirstOrDefaultAsync(x => x.CitizenId == item.CitizanId);
+ if (_profile == null)
+ continue;
+ var _insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
+ if (_insignia == null)
+ continue;
+ profile = new InsigniaNoteProfile
+ {
+ RequestDate = DateTime.Now,
+ Salary = _profile.ProfileSalary == null || _profile.ProfileSalary.Count == 0 ? null : _profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
+ IsApprove = true,
+ Status = "DONE",
+ Number = item.Number,
+ RequestInsignia = _insignia,
+ DateReceive = item.DateReceive,
+ Date = item.Date,
+ VolumeNo = item.VolumeNo,
+ Section = item.Section,
+ Page = item.Page,
+ No = item.No,
+ ProfileId = _profile.Id,
+ InsigniaNote = insigniaNote,
+ LastUpdateFullName = FullName ?? "System Administrator",
+ LastUpdateUserId = UserId ?? "",
+ LastUpdatedAt = DateTime.Now,
+ }; ;
+ }
+ else
+ {
+ profile.Status = "DONE";
profile.Number = item.Number;
profile.RequestInsignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia) == null ? profile.RequestInsignia : await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
profile.DateReceive = item.DateReceive;
@@ -1886,639 +2098,460 @@ namespace BMA.EHR.Insignia.Service.Controllers
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
}
+ _insigniaNoteProfiles.Add(
+ new
+ {
+ profile.Id,
+ Prefix = _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).Prefix,
+ Position = _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).Position,
+ _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).CitizenId,
+ _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).ProfileType,
+ FullName = $"{_userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).LastName}",
+ RequestInsignia = profile.RequestInsignia == null ? null : profile.RequestInsignia.Name,
+ RequestInsigniaId = profile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profile.RequestInsignia.Id,
+ RequestInsigniaShortName = profile.RequestInsignia == null ? null : profile.RequestInsignia.ShortName,
+ profile.DateReceive,
+ profile.OrganizationOrganizationSend,
+ profile.OrganizationOrganizationReceive,
+ profile.Status,
+ profile.Issue,
+ profile.Date,
+ profile.VolumeNo,
+ profile.Section,
+ profile.Page,
+ profile.No,
+ profile.DatePayment,
+ profile.TypePayment,
+ profile.Address,
+ profile.Number,
+ profile.Salary,
+ }
+ );
}
- // if (profile.DateReceive == null || profile.Date == null)
- // continue;
- if (profile.Status != "DONE")
+ return Success(_insigniaNoteProfiles);
+ }
+
+ ///
+ /// preview บันทึกผลใบกำกับเครื่องราชฯ
+ ///
+ /// Id รอบบันทึกผลเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("preview/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> PreviewInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
+ {
+ var insigniaNote = await _context.InsigniaNotes
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ .Include(x => x.InsigniaNoteProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .ThenInclude(x => x.InsigniaType)
+ .Include(x => x.InsigniaNoteProfiles)
+ // .ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Prefix)
+ .Include(x => x.InsigniaNoteProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Position)
+ .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
+ if (insigniaNote == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound);
+
+ if (Request.Form.Files == null || Request.Form.Files.Count == 0)
{
-
-
-
- profile.Status = "DONE";
-
-
- var profileInsignia = new PostProfileInsigniaDto
- {
- profileId = profile.ProfileId.Value,
- year = insigniaNote.Year,
- no = profile.No,
- volumeNo = profile.VolumeNo,
- section = profile.Section,
- page = profile.Page,
- receiveDate = profile.DateReceive.Value,
- dateAnnounce = profile.Date.Value,
- insigniaId = profile.RequestInsignia.Id,
- issue = "",
- note = "",
- refCommandDate = null,
- refCommandNo = "",
- volume = "",
-
- };
- await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken);
-
-
+ return Error(GlobalMessages.NoFileToUpload);
}
- }
- await _context.SaveChangesAsync();
- return Success();
- }
-
- ///
- /// import บันทึกผลใบกำกับเครื่องราชฯ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("import/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
- public async Task> ImportInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
- {
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .Include(x => x.InsigniaNoteProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
- if (Request.Form.Files == null || Request.Form.Files.Count == 0)
- {
- return Error(GlobalMessages.NoFileToUpload);
- }
- var file = Request.Form.Files[0];
- if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
- {
- return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
- }
- var items = await ReadExcelImportInvoice(file);
- foreach (var item in items)
- {
- if (item.CitizanId == null) continue;
- var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
- var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
- if (profile == null)
- continue;
- profile.Number = item.Number;
- profile.DatePayment = item.DatePayment;
- profile.TypePayment = item.TypePayment;
- profile.Address = item.Address;
- profile.LastUpdateFullName = FullName ?? "System Administrator";
- profile.LastUpdateUserId = UserId ?? "";
- profile.LastUpdatedAt = DateTime.Now;
- }
- await _context.SaveChangesAsync();
- return Success();
- }
-
- ///
- /// preview บันทึกผลการได้รับเครื่องราชฯ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("preview/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
- public async Task> PreviewReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
- {
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .Include(x => x.InsigniaNoteProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .ThenInclude(x => x.InsigniaType)
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Prefix)
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Position)
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
- if (Request.Form.Files == null || Request.Form.Files.Count == 0)
- {
- return Error(GlobalMessages.NoFileToUpload);
- }
- var file = Request.Form.Files[0];
- if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
- {
- return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
- }
- var items = await ReadExcelImportReceive(file);
- var _insigniaNoteProfiles = new List();
- foreach (var item in items)
- {
- var _profile = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
- var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == _profile.Id);
- if (profile == null)
+ var file = Request.Form.Files[0];
+ if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
{
-
-
- //var _profile = await _context.Profiles
- // .Include(x => x.Salaries)
- // .FirstOrDefaultAsync(x => x.CitizenId == item.CitizanId);
- if (_profile == null)
+ return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
+ }
+ var items = await ReadExcelImportInvoice(file);
+ foreach (var item in items)
+ {
+ if (item.CitizanId == null) continue;
+ var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
+ var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
+ if (profile == null)
continue;
- var _insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
- if (_insignia == null)
- continue;
- profile = new InsigniaNoteProfile
- {
- RequestDate = DateTime.Now,
- Salary = _profile.ProfileSalary == null || _profile.ProfileSalary.Count == 0 ? null : _profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
- IsApprove = true,
- Status = "DONE",
- Number = item.Number,
- RequestInsignia = _insignia,
- DateReceive = item.DateReceive,
- Date = item.Date,
- VolumeNo = item.VolumeNo,
- Section = item.Section,
- Page = item.Page,
- No = item.No,
- ProfileId = _profile.Id,
- InsigniaNote = insigniaNote,
- LastUpdateFullName = FullName ?? "System Administrator",
- LastUpdateUserId = UserId ?? "",
- LastUpdatedAt = DateTime.Now,
- }; ;
- }
- else
- {
- profile.Status = "DONE";
profile.Number = item.Number;
- profile.RequestInsignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia) == null ? profile.RequestInsignia : await _context.Insignias.FirstOrDefaultAsync(x => x.Name == item.RequestInsignia);
- profile.DateReceive = item.DateReceive;
- profile.Date = item.Date;
- profile.VolumeNo = item.VolumeNo;
- profile.Section = item.Section;
- profile.Page = item.Page;
- profile.No = item.No;
+ profile.DatePayment = item.DatePayment;
+ profile.TypePayment = item.TypePayment;
+ profile.Address = item.Address;
profile.LastUpdateFullName = FullName ?? "System Administrator";
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
}
- _insigniaNoteProfiles.Add(
- new
- {
- profile.Id,
- Prefix = _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).Prefix,
- Position = _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).Position,
- _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).CitizenId,
- _userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).ProfileType,
- FullName = $"{_userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(profile.ProfileId.Value, AccessToken).LastName}",
- RequestInsignia = profile.RequestInsignia == null ? null : profile.RequestInsignia.Name,
- RequestInsigniaId = profile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profile.RequestInsignia.Id,
- RequestInsigniaShortName = profile.RequestInsignia == null ? null : profile.RequestInsignia.ShortName,
- profile.DateReceive,
- profile.OrganizationOrganizationSend,
- profile.OrganizationOrganizationReceive,
- profile.Status,
- profile.Issue,
- profile.Date,
- profile.VolumeNo,
- profile.Section,
- profile.Page,
- profile.No,
- profile.DatePayment,
- profile.TypePayment,
- profile.Address,
- profile.Number,
- profile.Salary,
- }
- );
- }
- return Success(_insigniaNoteProfiles);
- }
-
- ///
- /// preview บันทึกผลใบกำกับเครื่องราชฯ
- ///
- /// Id รอบบันทึกผลเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("preview/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
- public async Task> PreviewInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
- {
- var insigniaNote = await _context.InsigniaNotes
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- .Include(x => x.InsigniaNoteProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .ThenInclude(x => x.InsigniaType)
- .Include(x => x.InsigniaNoteProfiles)
- // .ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Prefix)
- .Include(x => x.InsigniaNoteProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Position)
- .FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
- if (insigniaNote == null)
- return Error(GlobalMessages.InsigniaRequestNotFound);
-
- if (Request.Form.Files == null || Request.Form.Files.Count == 0)
- {
- return Error(GlobalMessages.NoFileToUpload);
- }
- var file = Request.Form.Files[0];
- if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
- {
- return Error("นามสกุลไฟล์ต้องเป็น .xlsx!");
- }
- var items = await ReadExcelImportInvoice(file);
- foreach (var item in items)
- {
- if (item.CitizanId == null) continue;
- var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
- var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
- if (profile == null)
- continue;
- profile.Number = item.Number;
- profile.DatePayment = item.DatePayment;
- profile.TypePayment = item.TypePayment;
- profile.Address = item.Address;
- profile.LastUpdateFullName = FullName ?? "System Administrator";
- profile.LastUpdateUserId = UserId ?? "";
- profile.LastUpdatedAt = DateTime.Now;
- }
- var _insigniaNoteProfiles = new List();
- foreach (var item in items)
- {
- if (item.CitizanId == null) continue;
- var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
-
- if (pf == null) continue;
- var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
- if (profile == null)
- continue;
- profile.Status = "DONE";
- profile.Number = item.Number;
- profile.DatePayment = item.DatePayment;
- profile.TypePayment = item.TypePayment;
- profile.Address = item.Address;
- profile.LastUpdateFullName = FullName ?? "System Administrator";
- profile.LastUpdateUserId = UserId ?? "";
- profile.LastUpdatedAt = DateTime.Now;
- _insigniaNoteProfiles.Add(
- new
- {
- profile.Id,
- Prefix = pf.Prefix,
- Position = pf.Position,
- pf.CitizenId,
- pf.ProfileType,
- FullName = $"{pf.Prefix}{pf.FirstName} {pf.LastName}",
- RequestInsignia = profile.RequestInsignia == null ? null : profile.RequestInsignia.Name,
- RequestInsigniaId = profile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profile.RequestInsignia.Id,
- RequestInsigniaShortName = profile.RequestInsignia == null ? null : profile.RequestInsignia.ShortName,
- profile.DateReceive,
- profile.OrganizationOrganizationSend,
- profile.OrganizationOrganizationReceive,
- profile.Status,
- profile.Issue,
- profile.Date,
- profile.VolumeNo,
- profile.Section,
- profile.Page,
- profile.No,
- profile.DatePayment,
- profile.TypePayment,
- profile.Address,
- profile.Number,
- profile.Salary,
- }
- );
- }
- return Success(_insigniaNoteProfiles);
- }
-
- ///
- /// Download รายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์
- ///
- /// Id รอบเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpGet("download/excel/{RequestId:length(36)}")]
- public async Task> DownloadExcalInsignia(Guid RequestId)
- {
- var insigniaPeriod = await _context.InsigniaRequests
- //.Include(x => x.Organization)
- //.ThenInclude(x => x.OrganizationOrganization)
- .Include(x => x.RequestProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Prefix)
- //.Include(x => x.RequestProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Position)
- //.Include(x => x.RequestProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.PositionLevel)
- //.Include(x => x.RequestProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Salaries)
- //.ThenInclude(x => x.PositionLevel)
- //.Include(x => x.RequestProfiles)
- //.ThenInclude(x => x.Profile)
- //.ThenInclude(x => x.Insignias)
- //.ThenInclude(x => x.Insignia)
- .FirstOrDefaultAsync(x => x.Id == RequestId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaPeriodNotFound);
-
- var template_dir = Path.Combine(_hostingEnvironment.ContentRootPath, "Templates");
- var template_file = Path.Combine(template_dir, "PersonInsignia.xlsx");
- var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
- if (!Directory.Exists(tmpDir))
- Directory.CreateDirectory(tmpDir);
-
- var exportFile = Path.Combine(tmpDir, $"InsigniaRequestList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
- try
- {
- // copy template
- System.IO.File.Copy(template_file, exportFile);
-
- using (var excel = new ExcelPackage(new FileInfo(exportFile)))
+ var _insigniaNoteProfiles = new List();
+ foreach (var item in items)
{
- var workSheet = excel.Workbook.Worksheets[0];
- var requestProfiles = insigniaPeriod.RequestProfiles.Where(x => x.Status == "PENDING").ToList();
- var row = 2;
- foreach (var item in requestProfiles)
- {
- var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken);
+ if (item.CitizanId == null) continue;
+ var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
- workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root;
- workSheet.Cells[row, 2].Value = profile.CitizenId;
- workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-");
- workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix);
- workSheet.Cells[row, 5].Value = profile.FirstName;
- workSheet.Cells[row, 6].Value = profile.LastName;
- workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender;
- workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate();
- workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate();
- // workSheet.Cells[row, 10].Value = null;
- //workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name;
- workSheet.Cells[row, 12].Value = "";
- workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName;
- workSheet.Cells[row, 14].Value = "";
- workSheet.Cells[row, 15].Value = null;
- workSheet.Cells[row, 16].Value = profile.Position ?? "";
- workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
- workSheet.Cells[row, 18].Value = null;
- workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount;
- workSheet.Cells[row, 20].Value = "";
- workSheet.Cells[row, 21].Value = "";
- workSheet.Cells[row, 22].Value = null;
- row++;
- }
- excel.Save();
- using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
- fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
- fs.Close();
- var fname = Path.GetFileName(exportFile);
- Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
- var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ if (pf == null) continue;
+ var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
+ if (profile == null)
+ continue;
+ profile.Status = "DONE";
+ profile.Number = item.Number;
+ profile.DatePayment = item.DatePayment;
+ profile.TypePayment = item.TypePayment;
+ profile.Address = item.Address;
+ profile.LastUpdateFullName = FullName ?? "System Administrator";
+ profile.LastUpdateUserId = UserId ?? "";
+ profile.LastUpdatedAt = DateTime.Now;
+ _insigniaNoteProfiles.Add(
+ new
{
- FileDownloadName = fname
- };
- return ret;
- }
+ profile.Id,
+ Prefix = pf.Prefix,
+ Position = pf.Position,
+ pf.CitizenId,
+ pf.ProfileType,
+ FullName = $"{pf.Prefix}{pf.FirstName} {pf.LastName}",
+ RequestInsignia = profile.RequestInsignia == null ? null : profile.RequestInsignia.Name,
+ RequestInsigniaId = profile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profile.RequestInsignia.Id,
+ RequestInsigniaShortName = profile.RequestInsignia == null ? null : profile.RequestInsignia.ShortName,
+ profile.DateReceive,
+ profile.OrganizationOrganizationSend,
+ profile.OrganizationOrganizationReceive,
+ profile.Status,
+ profile.Issue,
+ profile.Date,
+ profile.VolumeNo,
+ profile.Section,
+ profile.Page,
+ profile.No,
+ profile.DatePayment,
+ profile.TypePayment,
+ profile.Address,
+ profile.Number,
+ profile.Salary,
+ }
+ );
}
+ return Success(_insigniaNoteProfiles);
}
- catch (Exception ex)
+
+ ///
+ /// Download รายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์
+ ///
+ /// Id รอบเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("download/excel/{RequestId:length(36)}")]
+ public async Task> DownloadExcalInsignia(Guid RequestId)
{
- return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้มีสิทธิ์ขอพระราชทานเครื่องราชย์ได้!!");
- }
- finally
- {
- if (System.IO.File.Exists(exportFile))
- System.IO.File.Delete(exportFile);
- }
- }
+ var insigniaPeriod = await _context.InsigniaRequests
+ //.Include(x => x.Organization)
+ //.ThenInclude(x => x.OrganizationOrganization)
+ .Include(x => x.RequestProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Prefix)
+ //.Include(x => x.RequestProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Position)
+ //.Include(x => x.RequestProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.PositionLevel)
+ //.Include(x => x.RequestProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Salaries)
+ //.ThenInclude(x => x.PositionLevel)
+ //.Include(x => x.RequestProfiles)
+ //.ThenInclude(x => x.Profile)
+ //.ThenInclude(x => x.Insignias)
+ //.ThenInclude(x => x.Insignia)
+ .FirstOrDefaultAsync(x => x.Id == RequestId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaPeriodNotFound);
- ///
- /// Download รายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์
- ///
- /// Id การขอเครื่องราช (Request)
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("download/excel/{RequestId:length(36)}")]
- public async Task> DownloadExcelInsigniaByFilter([FromBody] ExportFileInsigniaRequest req, Guid RequestId)
- {
- var insigniaPeriod = await _context.InsigniaRequests
- .Include(x => x.RequestProfiles)
- .ThenInclude(x => x.RequestInsignia)
- .FirstOrDefaultAsync(x => x.Id == RequestId);
- if (insigniaPeriod == null)
- return Error(GlobalMessages.InsigniaPeriodNotFound);
+ var template_dir = Path.Combine(_hostingEnvironment.ContentRootPath, "Templates");
+ var template_file = Path.Combine(template_dir, "PersonInsignia.xlsx");
+ var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
+ if (!Directory.Exists(tmpDir))
+ Directory.CreateDirectory(tmpDir);
- var template_dir = Path.Combine(_hostingEnvironment.ContentRootPath, "Templates");
- var template_file = Path.Combine(template_dir, "PersonInsignia.xlsx");
- var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
- if (!Directory.Exists(tmpDir))
- Directory.CreateDirectory(tmpDir);
-
- var exportFile = Path.Combine(tmpDir, $"InsigniaRequestList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
- try
- {
- // copy template
- System.IO.File.Copy(template_file, exportFile);
-
- using (var excel = new ExcelPackage(new FileInfo(exportFile)))
+ var exportFile = Path.Combine(tmpDir, $"InsigniaRequestList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
+ try
{
- var workSheet = excel.Workbook.Worksheets[0];
- var requestProfiles = insigniaPeriod.RequestProfiles.Where(x => x.Status == "PENDING").ToList();
- if (req.ProfileType != null)
- requestProfiles = requestProfiles.Where(x => x.ProfileId != null)
- //.Where(x => x.Profile.ProfileType.Trim().ToUpper() == req.ProfileType.Trim().ToUpper())
- .ToList();
- if (req.InsigniaId != null)
- requestProfiles = requestProfiles.Where(x => x.RequestInsignia.Id == req.InsigniaId).ToList();
- // if (req.OrgId != null)
- // requestProfiles = requestProfiles.Where(x => x.Request.Organization.Id == req.OrgId).ToList();
- var row = 2;
- foreach (var item in requestProfiles)
+ // copy template
+ System.IO.File.Copy(template_file, exportFile);
+
+ using (var excel = new ExcelPackage(new FileInfo(exportFile)))
{
- var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken);
- workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root;
- workSheet.Cells[row, 2].Value = profile.CitizenId;
- workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-");
- workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix);
- workSheet.Cells[row, 5].Value = profile.FirstName;
- workSheet.Cells[row, 6].Value = profile.LastName;
- workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender;
- workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate();
- workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate();
- // workSheet.Cells[row, 10].Value = null;
- // workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name;
- workSheet.Cells[row, 12].Value = "";
- workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName;
- workSheet.Cells[row, 14].Value = "";
- workSheet.Cells[row, 15].Value = null;
- workSheet.Cells[row, 16].Value = profile.Position == null ? "-" : profile.Position;
- workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
- workSheet.Cells[row, 18].Value = null;
- workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount;
- workSheet.Cells[row, 20].Value = "";
- workSheet.Cells[row, 21].Value = "";
- workSheet.Cells[row, 22].Value = null;
- row++;
- }
- excel.Save();
- using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
- {
- byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
- fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
- fs.Close();
- var fname = Path.GetFileName(exportFile);
- Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
- var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ var workSheet = excel.Workbook.Worksheets[0];
+ var requestProfiles = insigniaPeriod.RequestProfiles.Where(x => x.Status == "PENDING").ToList();
+ var row = 2;
+ foreach (var item in requestProfiles)
{
- FileDownloadName = fname
- };
- return ret;
+ var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken);
+
+ workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root;
+ workSheet.Cells[row, 2].Value = profile.CitizenId;
+ workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-");
+ workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix);
+ workSheet.Cells[row, 5].Value = profile.FirstName;
+ workSheet.Cells[row, 6].Value = profile.LastName;
+ workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender;
+ workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate();
+ workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate();
+ // workSheet.Cells[row, 10].Value = null;
+ //workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name;
+ workSheet.Cells[row, 12].Value = "";
+ workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName;
+ workSheet.Cells[row, 14].Value = "";
+ workSheet.Cells[row, 15].Value = null;
+ workSheet.Cells[row, 16].Value = profile.Position ?? "";
+ workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
+ workSheet.Cells[row, 18].Value = null;
+ workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount;
+ workSheet.Cells[row, 20].Value = "";
+ workSheet.Cells[row, 21].Value = "";
+ workSheet.Cells[row, 22].Value = null;
+ row++;
+ }
+ excel.Save();
+ using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
+ {
+ byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
+ fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
+ fs.Close();
+ var fname = Path.GetFileName(exportFile);
+ Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
+ var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ {
+ FileDownloadName = fname
+ };
+ return ret;
+ }
}
}
- }
- catch (Exception ex)
- {
- return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้มีสิทธิ์ขอพระราชทานเครื่องราชย์ได้!!");
- }
- finally
- {
- if (System.IO.File.Exists(exportFile))
- System.IO.File.Delete(exportFile);
- }
- }
-
- ///
- /// Upload เอกสาร เครื่องราชฯ
- ///
- /// Id รอบเครื่องราช
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("upload/{requestId:length(36)}"), DisableRequestSizeLimit]
- public async Task> UpdatePersonDeferment([FromForm] ImportFileRequest req, Guid requestId)
- {
- var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Document).Where(x => x.Id == requestId).FirstOrDefaultAsync();
- if (insigniaRequest == null)
- return Error(GlobalMessages.InsigniaRequestNotFound, 404);
-
- if (Request.Form.Files != null && Request.Form.Files.Count != 0)
- {
- if (insigniaRequest.Document != null)
+ catch (Exception ex)
{
- await _documentService.DeleteFileAsync(insigniaRequest.Document.Id);
+ return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้มีสิทธิ์ขอพระราชทานเครื่องราชย์ได้!!");
}
- var file = Request.Form.Files[0];
- var fileExtension = Path.GetExtension(file.FileName);
-
- var doc = await _documentService.UploadFileAsync(file, file.FileName);
- insigniaRequest.Document = doc;
- }
- insigniaRequest.LastUpdateFullName = FullName ?? "System Administrator";
- insigniaRequest.LastUpdateUserId = UserId ?? "";
- insigniaRequest.LastUpdatedAt = DateTime.Now;
- await _context.SaveChangesAsync();
-
- return Success();
- }
-
- ///
- /// ยื่นรายการคืนเครื่องราชฯ
- ///
- /// Id บุคคลบันทึกผลเครื่องราชฯ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("note/return/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
- public async Task> UpdateReturnNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
- {
- var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Include(x => x.DocReturnInsignia).Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
- if (insigniaNoteProfile == null)
- return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
-
- if (Request.Form.Files != null && Request.Form.Files.Count != 0)
- {
- if (insigniaNoteProfile.DocReturnInsignia != null)
+ finally
{
- await _documentService.DeleteFileAsync(insigniaNoteProfile.DocReturnInsignia.Id);
+ if (System.IO.File.Exists(exportFile))
+ System.IO.File.Delete(exportFile);
}
- var file = Request.Form.Files[0];
- var fileExtension = Path.GetExtension(file.FileName);
-
- var doc = await _documentService.UploadFileAsync(file, file.FileName);
- insigniaNoteProfile.DocReturnInsignia = doc;
}
- insigniaNoteProfile.OrgReturnInsignia = await _context.Organizations.Where(x => x.Id == req.OrgId).FirstOrDefaultAsync();
- insigniaNoteProfile.DateReturnInsignia = req.Date;
- insigniaNoteProfile.LastUpdateFullName = FullName ?? "System Administrator";
- insigniaNoteProfile.LastUpdateUserId = UserId ?? "";
- insigniaNoteProfile.LastUpdatedAt = DateTime.Now;
- await _context.SaveChangesAsync();
- return Success();
- }
-
- ///
- /// ยื่นรายการรับเครื่องราชฯ
- ///
- /// Id บุคคลบันทึกผลเครื่องราชฯ
- ///
- ///
- /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
- /// ไม่ได้ Login เข้าระบบ
- /// เมื่อเกิดข้อผิดพลาดในการทำงาน
- [HttpPut("note/receive/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
- public async Task> UpdateReceiveNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
- {
- var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Include(x => x.DocReceiveInsignia).Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
- if (insigniaNoteProfile == null)
- return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
-
- if (Request.Form.Files != null && Request.Form.Files.Count != 0)
+ ///
+ /// Download รายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์
+ ///
+ /// Id การขอเครื่องราช (Request)
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("download/excel/{RequestId:length(36)}")]
+ public async Task> DownloadExcelInsigniaByFilter([FromBody] ExportFileInsigniaRequest req, Guid RequestId)
{
- if (insigniaNoteProfile.DocReceiveInsignia != null)
+ var insigniaPeriod = await _context.InsigniaRequests
+ .Include(x => x.RequestProfiles)
+ .ThenInclude(x => x.RequestInsignia)
+ .FirstOrDefaultAsync(x => x.Id == RequestId);
+ if (insigniaPeriod == null)
+ return Error(GlobalMessages.InsigniaPeriodNotFound);
+
+ var template_dir = Path.Combine(_hostingEnvironment.ContentRootPath, "Templates");
+ var template_file = Path.Combine(template_dir, "PersonInsignia.xlsx");
+ var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
+ if (!Directory.Exists(tmpDir))
+ Directory.CreateDirectory(tmpDir);
+
+ var exportFile = Path.Combine(tmpDir, $"InsigniaRequestList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
+ try
{
- await _documentService.DeleteFileAsync(insigniaNoteProfile.DocReceiveInsignia.Id);
+ // copy template
+ System.IO.File.Copy(template_file, exportFile);
+
+ using (var excel = new ExcelPackage(new FileInfo(exportFile)))
+ {
+ var workSheet = excel.Workbook.Worksheets[0];
+ var requestProfiles = insigniaPeriod.RequestProfiles.Where(x => x.Status == "PENDING").ToList();
+ if (req.ProfileType != null)
+ requestProfiles = requestProfiles.Where(x => x.ProfileId != null)
+ //.Where(x => x.Profile.ProfileType.Trim().ToUpper() == req.ProfileType.Trim().ToUpper())
+ .ToList();
+ if (req.InsigniaId != null)
+ requestProfiles = requestProfiles.Where(x => x.RequestInsignia.Id == req.InsigniaId).ToList();
+ // if (req.OrgId != null)
+ // requestProfiles = requestProfiles.Where(x => x.Request.Organization.Id == req.OrgId).ToList();
+ var row = 2;
+ foreach (var item in requestProfiles)
+ {
+ var profile = _userProfileRepository.GetOfficerProfileById(item.ProfileId, AccessToken);
+ workSheet.Cells[row, 1].Value = _userProfileRepository.GetOc(insigniaPeriod.OrganizationId, 0, AccessToken).Root;
+ workSheet.Cells[row, 2].Value = profile.CitizenId;
+ workSheet.Cells[row, 3].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? profile.Prefix : "-");
+ workSheet.Cells[row, 4].Value = profile.Prefix == null ? "-" : ((profile.Prefix == "นาย" || profile.Prefix == "นาง" || profile.Prefix == "นางสาว") ? "-" : profile.Prefix);
+ workSheet.Cells[row, 5].Value = profile.FirstName;
+ workSheet.Cells[row, 6].Value = profile.LastName;
+ workSheet.Cells[row, 7].Value = profile.Gender == null ? "-" : profile.Gender;
+ workSheet.Cells[row, 8].Value = profile.BirthDate.ToThaiDate();
+ workSheet.Cells[row, 9].Value = profile.DateAppoint == null ? null : profile.DateAppoint.Value.ToThaiDate();
+ // workSheet.Cells[row, 10].Value = null;
+ // workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name;
+ workSheet.Cells[row, 12].Value = "";
+ workSheet.Cells[row, 13].Value = profile.PosLevel == null ? null : profile.PosLevel.PosLevelName;
+ workSheet.Cells[row, 14].Value = "";
+ workSheet.Cells[row, 15].Value = null;
+ workSheet.Cells[row, 16].Value = profile.Position == null ? "-" : profile.Position;
+ workSheet.Cells[row, 17].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
+ workSheet.Cells[row, 18].Value = null;
+ workSheet.Cells[row, 19].Value = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount;
+ workSheet.Cells[row, 20].Value = "";
+ workSheet.Cells[row, 21].Value = "";
+ workSheet.Cells[row, 22].Value = null;
+ row++;
+ }
+ excel.Save();
+ using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
+ {
+ byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
+ fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
+ fs.Close();
+ var fname = Path.GetFileName(exportFile);
+ Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
+ var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ {
+ FileDownloadName = fname
+ };
+ return ret;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้มีสิทธิ์ขอพระราชทานเครื่องราชย์ได้!!");
+ }
+ finally
+ {
+ if (System.IO.File.Exists(exportFile))
+ System.IO.File.Delete(exportFile);
}
-
- var file = Request.Form.Files[0];
- var fileExtension = Path.GetExtension(file.FileName);
-
- var doc = await _documentService.UploadFileAsync(file, file.FileName);
- insigniaNoteProfile.DocReceiveInsignia = doc;
}
- insigniaNoteProfile.OrgReceiveInsignia = await _context.Organizations.Where(x => x.Id == req.OrgId).FirstOrDefaultAsync();
- insigniaNoteProfile.DateReceiveInsignia = req.Date;
- insigniaNoteProfile.LastUpdateFullName = FullName ?? "System Administrator";
- insigniaNoteProfile.LastUpdateUserId = UserId ?? "";
- insigniaNoteProfile.LastUpdatedAt = DateTime.Now;
- await _context.SaveChangesAsync();
- return Success();
+ ///
+ /// Upload เอกสาร เครื่องราชฯ
+ ///
+ /// Id รอบเครื่องราช
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("upload/{requestId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> UpdatePersonDeferment([FromForm] ImportFileRequest req, Guid requestId)
+ {
+ var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Document).Where(x => x.Id == requestId).FirstOrDefaultAsync();
+ if (insigniaRequest == null)
+ return Error(GlobalMessages.InsigniaRequestNotFound, 404);
+
+ if (Request.Form.Files != null && Request.Form.Files.Count != 0)
+ {
+ if (insigniaRequest.Document != null)
+ {
+ await _documentService.DeleteFileAsync(insigniaRequest.Document.Id);
+ }
+ var file = Request.Form.Files[0];
+ var fileExtension = Path.GetExtension(file.FileName);
+
+ var doc = await _documentService.UploadFileAsync(file, file.FileName);
+ insigniaRequest.Document = doc;
+ }
+ insigniaRequest.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaRequest.LastUpdateUserId = UserId ?? "";
+ insigniaRequest.LastUpdatedAt = DateTime.Now;
+ await _context.SaveChangesAsync();
+
+ return Success();
+ }
+
+ ///
+ /// ยื่นรายการคืนเครื่องราชฯ
+ ///
+ /// Id บุคคลบันทึกผลเครื่องราชฯ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("note/return/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> UpdateReturnNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
+ {
+ var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Include(x => x.DocReturnInsignia).Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
+ if (insigniaNoteProfile == null)
+ return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
+
+ if (Request.Form.Files != null && Request.Form.Files.Count != 0)
+ {
+ if (insigniaNoteProfile.DocReturnInsignia != null)
+ {
+ await _documentService.DeleteFileAsync(insigniaNoteProfile.DocReturnInsignia.Id);
+ }
+ var file = Request.Form.Files[0];
+ var fileExtension = Path.GetExtension(file.FileName);
+
+ var doc = await _documentService.UploadFileAsync(file, file.FileName);
+ insigniaNoteProfile.DocReturnInsignia = doc;
+ }
+ insigniaNoteProfile.OrgReturnInsignia = await _context.Organizations.Where(x => x.Id == req.OrgId).FirstOrDefaultAsync();
+ insigniaNoteProfile.DateReturnInsignia = req.Date;
+ insigniaNoteProfile.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaNoteProfile.LastUpdateUserId = UserId ?? "";
+ insigniaNoteProfile.LastUpdatedAt = DateTime.Now;
+ await _context.SaveChangesAsync();
+
+ return Success();
+ }
+
+ ///
+ /// ยื่นรายการรับเครื่องราชฯ
+ ///
+ /// Id บุคคลบันทึกผลเครื่องราชฯ
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPut("note/receive/{insigniaNoteProfileId:length(36)}"), DisableRequestSizeLimit]
+ public async Task> UpdateReceiveNoteInsignia([FromForm] InsigniaNoteReturnRequest req, Guid insigniaNoteProfileId)
+ {
+ var insigniaNoteProfile = await _context.InsigniaNoteProfiles.Include(x => x.DocReceiveInsignia).Where(x => x.Id == insigniaNoteProfileId).FirstOrDefaultAsync();
+ if (insigniaNoteProfile == null)
+ return Error(GlobalMessages.InsigniaRequestProfileNotFound, 404);
+
+ if (Request.Form.Files != null && Request.Form.Files.Count != 0)
+ {
+ if (insigniaNoteProfile.DocReceiveInsignia != null)
+ {
+ await _documentService.DeleteFileAsync(insigniaNoteProfile.DocReceiveInsignia.Id);
+ }
+
+ var file = Request.Form.Files[0];
+ var fileExtension = Path.GetExtension(file.FileName);
+
+ var doc = await _documentService.UploadFileAsync(file, file.FileName);
+ insigniaNoteProfile.DocReceiveInsignia = doc;
+ }
+ insigniaNoteProfile.OrgReceiveInsignia = await _context.Organizations.Where(x => x.Id == req.OrgId).FirstOrDefaultAsync();
+ insigniaNoteProfile.DateReceiveInsignia = req.Date;
+ insigniaNoteProfile.LastUpdateFullName = FullName ?? "System Administrator";
+ insigniaNoteProfile.LastUpdateUserId = UserId ?? "";
+ insigniaNoteProfile.LastUpdatedAt = DateTime.Now;
+ await _context.SaveChangesAsync();
+
+ return Success();
+ }
}
}
-}
diff --git a/BMA.EHR.Insignia/Program.cs b/BMA.EHR.Insignia/Program.cs
index 56285b68..ed6a54b9 100644
--- a/BMA.EHR.Insignia/Program.cs
+++ b/BMA.EHR.Insignia/Program.cs
@@ -2,6 +2,7 @@ using BMA.EHR.Application;
using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Domain.Middlewares;
using BMA.EHR.Infrastructure;
+using BMA.EHR.Infrastructure.MessageQueue;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service;
using BMA.EHR.Insignia.Service.Controllers;
@@ -90,6 +91,9 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLeaveApplication();
builder.Services.AddLeavePersistence(builder.Configuration);
+ // RabbitMQ
+ builder.Services.AddMessageQueue();
+
builder.Services.AddControllers(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
@@ -172,6 +176,9 @@ var app = builder.Build();
await using var db = scope.ServiceProvider.GetRequiredService();
await db.Database.MigrateAsync();
+ var rabbitMQConsumer = app.Services.GetRequiredService();
+ rabbitMQConsumer.StartReceiving();
+
app.Run();
}
diff --git a/BMA.EHR.Insignia/appsettings.json b/BMA.EHR.Insignia/appsettings.json
index a37fde2a..ec87a6e4 100644
--- a/BMA.EHR.Insignia/appsettings.json
+++ b/BMA.EHR.Insignia/appsettings.json
@@ -43,5 +43,10 @@
"Node": {
"API": "https://bma-ehr.frappet.synology.me/api/v1/probation"
},
- "API": "https://bma-ehr.frappet.synology.me/api/v1"
+ "API": "https://bma-ehr.frappet.synology.me/api/v1",
+ "RabbitMQ" :{
+ "URL": "localhost",
+ "UserName": "frappet",
+ "Password": "FPTadmin2357"
+ }
}
diff --git a/BMA.EHR.Solution.sln b/BMA.EHR.Solution.sln
index c9a8dbfc..c3f78122 100644
--- a/BMA.EHR.Solution.sln
+++ b/BMA.EHR.Solution.sln
@@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.OrganizationEmploye
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Command.Service", "BMA.EHR.Command.Service\BMA.EHR.Command.Service.csproj", "{E4E905EE-61DF-4451-B063-5C86BC7574CE}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Insignia.Service", "BMA.EHR.Insignia.Service\BMA.EHR.Insignia.Service.csproj", "{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Retirement.Service", "BMA.EHR.Retirement.Service\BMA.EHR.Retirement.Service.csproj", "{3FFE378C-387F-42EA-96E2-68E63BB295F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "BMA.EHR.Report.Service\BMA.EHR.Report.Service.csproj", "{26FE7B1C-771B-4940-9F40-326A7AD53F1C}"
@@ -31,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Leave.Service", "BM
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Discipline.Service", "BMA.EHR.Discipline.Service\BMA.EHR.Discipline.Service.csproj", "{0145A11E-7780-437B-A86F-CBDDB50BC3D1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Insignia", "BMA.EHR.Insignia\BMA.EHR.Insignia.csproj", "{03AB740F-AF31-423E-8546-198B914AF76F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -65,10 +65,6 @@ Global
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.Build.0 = Release|Any CPU
- {04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Release|Any CPU.Build.0 = Release|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -85,6 +81,10 @@ Global
{0145A11E-7780-437B-A86F-CBDDB50BC3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0145A11E-7780-437B-A86F-CBDDB50BC3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0145A11E-7780-437B-A86F-CBDDB50BC3D1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {03AB740F-AF31-423E-8546-198B914AF76F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {03AB740F-AF31-423E-8546-198B914AF76F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {03AB740F-AF31-423E-8546-198B914AF76F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {03AB740F-AF31-423E-8546-198B914AF76F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -98,11 +98,11 @@ Global
{81610EF7-AF80-44D8-9263-925C821CF45F} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{A54AA069-8B0E-4784-953B-5DA9F9C8285E} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{E4E905EE-61DF-4451-B063-5C86BC7574CE} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
- {04B37ACD-65CF-44ED-BC40-B5E7A71C374B} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{3FFE378C-387F-42EA-96E2-68E63BB295F9} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{26FE7B1C-771B-4940-9F40-326A7AD53F1C} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{0F15B902-82D7-4878-B12D-B36C14E8EDBC} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{0145A11E-7780-437B-A86F-CBDDB50BC3D1} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
+ {03AB740F-AF31-423E-8546-198B914AF76F} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}