add position
This commit is contained in:
parent
5fe786fe7b
commit
37dfac7cff
5 changed files with 1619 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ using Sentry;
|
|||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.WebSockets;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
|
@ -50,6 +51,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
private readonly PermissionRepository _permission;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ILogger<RecruitController> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
//private readonly DateTimeExtension;
|
||||
|
||||
#endregion
|
||||
|
|
@ -63,6 +65,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
RecruitService recruitService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<RecruitController> logger,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission
|
||||
//DateTimeExtension extensions
|
||||
)
|
||||
|
|
@ -73,6 +76,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
_webHostEnvironment = webHostEnvironment;
|
||||
_recruitService = recruitService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
_permission = permission;
|
||||
//_extensions = extensions;
|
||||
|
|
@ -85,6 +89,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -1308,6 +1313,26 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
|||
|
||||
imported.Scores.Add(r);
|
||||
row++;
|
||||
var recruit = await _context.Recruits.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.RecruitImport == rec_import && x.ExamId == r.ExamId);
|
||||
if (recruit != null)
|
||||
{
|
||||
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);
|
||||
recruit.AuthName = org.result.name == null ? "" : org.result.name;
|
||||
recruit.AuthPosition = org.result.position == null ? "" : org.result.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue