โหลดใบรับรอง
This commit is contained in:
parent
9284a89cb4
commit
e44a255b53
4 changed files with 81 additions and 16 deletions
|
|
@ -11,6 +11,8 @@ using BMA.EHR.Organization.Service.Extensions;
|
|||
// using BMA.EHR.Core;
|
||||
using System.Text;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BMA.EHR.Report.Service.Controllers
|
||||
{
|
||||
|
|
@ -28,6 +30,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string space = "ㅤ";
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -35,13 +38,16 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
public ExamReportController(ExamDbContext context,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
this._httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
|
@ -108,6 +114,34 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var _data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
.Where(x => x.ExamId == examId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (_data == null)
|
||||
return Error("ไม่พบข้อมูลในระบบ");
|
||||
|
||||
if (_data.AuthName == null || _data.AuthName == "")
|
||||
{
|
||||
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
_data.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
_data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
|
|
@ -453,7 +487,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
SumScore = sr == null
|
||||
? "๐"
|
||||
//: (((sr.SumA > 0 ? sr.SumA : 0) + /*sr.SumB +*/ (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
||||
: (((sr.SumA > 0 ? sr.SumA : 0) + (sr.SumB > 0 ? sr.SumB : 0 ) + (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
||||
: (((sr.SumA > 0 ? sr.SumA : 0) + (sr.SumB > 0 ? sr.SumB : 0) + (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
||||
})
|
||||
.OrderBy(x => x.Number)
|
||||
.Where(x => x.Id == id)
|
||||
|
|
|
|||
|
|
@ -75,23 +75,34 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var name = "";
|
||||
var position = "";
|
||||
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||
using (var client = new HttpClient())
|
||||
var _data = await _context.Recruits.AsQueryable()
|
||||
.Include(x => x.RecruitImport)
|
||||
.Where(x => x.RecruitImport.Id == id)
|
||||
.Where(x => x.ExamId == examId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (_data == null)
|
||||
return Error("ไม่พบข้อมูลในระบบ");
|
||||
|
||||
if (_data.AuthName == null || _data.AuthName == "")
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
name = org.result.rootId == null ? "" : org.result.rootId;
|
||||
position = org.result.rootId == null ? "" : org.result.rootId;
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
_data.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
_data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var data = await _context.Recruits.AsQueryable()
|
||||
.Include(x => x.RecruitImport)
|
||||
.Where(x => x.RecruitImport.Id == id)
|
||||
|
|
@ -109,8 +120,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
EndDate = p.RecruitImport.RegisterEndDate == null ? "-" : p.RecruitImport.RegisterEndDate.Value.ToThaiFullDate3(),
|
||||
AuthName = name,
|
||||
AuthPosition = position
|
||||
AuthName = p.AuthName,
|
||||
AuthPosition = p.AuthPosition
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
|
|
|
|||
|
|
@ -78,5 +78,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
|
|||
public DateTime ApplyDate { get; set; }
|
||||
|
||||
public string? PositionName { get; set; }
|
||||
public string? PositionType { get; set; }
|
||||
public string? PositionLevel { get; set; }
|
||||
public string? AuthName { get; set; }
|
||||
public string? AuthPosition { get; set; }
|
||||
|
||||
[Comment("บัญชีสอบ")]
|
||||
public string? HddPosition { get; set; } = string.Empty;
|
||||
|
||||
[Comment("ประเภทการสอบภาค ก.")]
|
||||
public string? typeTest { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,5 +78,15 @@ namespace BMA.EHR.Recruit.Service.Models.Recruits
|
|||
public DateTime ApplyDate { get; set; }
|
||||
|
||||
public string? PositionName { get; set; }
|
||||
public string? PositionType { get; set; }
|
||||
public string? PositionLevel { get; set; }
|
||||
public string? AuthName { get; set; }
|
||||
public string? AuthPosition { get; set; }
|
||||
|
||||
[Comment("บัญชีสอบ")]
|
||||
public string? HddPosition { get; set; } = string.Empty;
|
||||
|
||||
[Comment("ประเภทการสอบภาค ก.")]
|
||||
public string? typeTest { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue