fix ccode
This commit is contained in:
parent
496917c34c
commit
4cc57322c0
4 changed files with 47 additions and 8 deletions
|
|
@ -1,15 +1,16 @@
|
||||||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
using Amazon.Runtime.Internal.Endpoints.StandardLibrary;
|
||||||
|
using Amazon.S3.Model.Internal.MarshallTransformations;
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
using BMA.EHR.Domain.Models.Base;
|
using BMA.EHR.Domain.Models.Base;
|
||||||
using BMA.EHR.Domain.Models.HR;
|
using BMA.EHR.Domain.Models.HR;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json.Linq;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories
|
namespace BMA.EHR.Application.Repositories
|
||||||
{
|
{
|
||||||
|
|
@ -76,13 +77,45 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async Task<string> SendExternalAPIAsync(HttpMethod method, string apiPath, string accessToken, object? body, string apiKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// สร้าง request message
|
||||||
|
var request = new HttpRequestMessage(method, apiPath);
|
||||||
|
|
||||||
|
|
||||||
|
var json = JsonConvert.SerializeObject(body);
|
||||||
|
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
|
||||||
|
client.DefaultRequestHeaders.Add("api_key", apiKey);
|
||||||
|
var _res = await client.SendAsync(request);
|
||||||
|
if (_res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
return _result;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected async Task<string> PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey)
|
protected async Task<string> PostExternalAPIAsync(string apiPath, string accessToken, object? body, string apiKey)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(body);
|
var json = JsonConvert.SerializeObject(body);
|
||||||
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
|
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
//stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||||
|
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7728,7 +7728,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
if (period != null && period.InsigniaEmployees != null)
|
if (period != null && period.InsigniaEmployees != null)
|
||||||
{
|
{
|
||||||
allEmployeeProfileByRoot =
|
allEmployeeProfileByRoot =
|
||||||
(await _userProfileRepository.GetEmployeeProfileByPositionAsync(ocId, period.InsigniaEmployees.Select(x => x.RefId), AccessToken));
|
(await _userProfileRepository.GetEmployeeProfileByPositionAsync(ocId, period.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), AccessToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List<InsigniaResultSet>();
|
var type_coin = allOfficerProfilesByRoot.Count() > 0 ? await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot) : new List<InsigniaResultSet>();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories
|
namespace BMA.EHR.Application.Repositories
|
||||||
{
|
{
|
||||||
|
|
@ -130,7 +131,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByPositionAsync(Guid rootId, dynamic empPosId, string? accessToken)
|
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByPositionAsync(Guid rootId, string[] empPosId, string? accessToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -143,6 +144,11 @@ namespace BMA.EHR.Application.Repositories
|
||||||
empPosId
|
empPosId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//var bodyJson = JsonConvert.SerializeObject(bodyRaw);
|
||||||
|
|
||||||
|
// สร้าง HTTP content
|
||||||
|
//var body = new StringContent(bodyJson, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||||
|
|
||||||
if (apiResult != null)
|
if (apiResult != null)
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
if (selectPeriod != null && selectPeriod.InsigniaEmployees != null)
|
if (selectPeriod != null && selectPeriod.InsigniaEmployees != null)
|
||||||
{
|
{
|
||||||
var emp =
|
var emp =
|
||||||
await _userProfileRepository.GetEmployeeProfileByPositionAsync(organization.Id, selectPeriod.InsigniaEmployees.Select(x => x.RefId), AccessToken);
|
await _userProfileRepository.GetEmployeeProfileByPositionAsync(organization.Id, selectPeriod.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), AccessToken);
|
||||||
if (emp != null)
|
if (emp != null)
|
||||||
allEmployeeProfileByRoot.AddRange(emp);
|
allEmployeeProfileByRoot.AddRange(emp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue