test dumb
This commit is contained in:
parent
8e967a1fa8
commit
27fd503d9e
8 changed files with 342 additions and 77 deletions
|
|
@ -12125,5 +12125,157 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task DumpDB(string token = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
var profiles = await _dbContext.Set<Profile>().ToListAsync();
|
||||
|
||||
// create new profile
|
||||
foreach (var recv in profiles)
|
||||
{
|
||||
/*ข้อมูล Profile ใหม่*/
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/all";
|
||||
var profileId = string.Empty;
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
rank = string.Empty,
|
||||
prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix,
|
||||
firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname,
|
||||
lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname,
|
||||
citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId,
|
||||
position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
|
||||
posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId,
|
||||
posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId,
|
||||
email = placementProfile.Email == null ? string.Empty : placementProfile.Email,
|
||||
phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone,
|
||||
keycloak = string.Empty,
|
||||
isProbation = false,
|
||||
isLeave = false,
|
||||
dateRetire = (DateTime?)null,
|
||||
dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate,
|
||||
dateStart = (DateTime?)null,
|
||||
govAgeAbsent = 0,
|
||||
govAgePlus = 0,
|
||||
birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth,
|
||||
reasonSameDate = (DateTime?)null,
|
||||
ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race,
|
||||
telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone,
|
||||
nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality,
|
||||
gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender,
|
||||
relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship,
|
||||
religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion,
|
||||
bloodGroup = string.Empty,
|
||||
registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress,
|
||||
registrationProvinceId = (String?)null,
|
||||
registrationDistrictId = (String?)null,
|
||||
registrationSubDistrictId = (String?)null,
|
||||
registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode,
|
||||
currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress,
|
||||
currentProvinceId = (String?)null,
|
||||
currentDistrictId = (String?)null,
|
||||
currentSubDistrictId = (String?)null,
|
||||
currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
profileId = JsonConvert.DeserializeObject<PlacementProfileId>(_result).result;
|
||||
}
|
||||
if (recv.Educations != null)
|
||||
{
|
||||
var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var edu in recv.Educations)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlEdu, new
|
||||
{
|
||||
profileId = profileId,
|
||||
country = edu.Country == null ? string.Empty : edu.Country,
|
||||
degree = edu.Degree == null ? string.Empty : edu.Degree,
|
||||
duration = edu.Duration == null ? string.Empty : edu.Duration,
|
||||
durationYear = edu.DurationYear == null ? 0 : edu.DurationYear,
|
||||
field = edu.Field == null ? string.Empty : edu.Field,
|
||||
finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate,
|
||||
fundName = edu.FundName == null ? string.Empty : edu.FundName,
|
||||
gpa = edu.Gpa == null ? string.Empty : edu.Gpa,
|
||||
institute = edu.Institute == null ? string.Empty : edu.Institute,
|
||||
other = edu.Other == null ? string.Empty : edu.Other,
|
||||
startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate,
|
||||
endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate,
|
||||
educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name,
|
||||
educationLevelId = string.Empty,
|
||||
positionPath = edu.PositionPath == null ? null : edu.PositionPath,
|
||||
positionPathId = string.Empty,
|
||||
isDate = edu.IsDate,
|
||||
isEducation = edu.IsEducation,
|
||||
note = string.Empty,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (placementProfile.PlacementCertificates != null)
|
||||
{
|
||||
var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var cer in placementProfile.PlacementCertificates)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlCer, new
|
||||
{
|
||||
profileId = profileId,
|
||||
expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate,
|
||||
issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate,
|
||||
certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo,
|
||||
certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType,
|
||||
issuer = cer.Issuer == null ? string.Empty : cer.Issuer,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileId = profileId,
|
||||
date = command.CommandAffectDate == null ? (DateTime?)null : command.CommandAffectDate,
|
||||
amount = recv.Amount == null ? null : recv.Amount,
|
||||
positionSalaryAmount = placementProfile.PositionSalaryAmount == null ? null : placementProfile.PositionSalaryAmount,
|
||||
mouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? null : placementProfile.MouthSalaryAmount,
|
||||
posNo = placementProfile.PosNumber == null ? string.Empty : placementProfile.PosNumber.ToString(),
|
||||
position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
|
||||
positionLine = string.Empty,
|
||||
positionPathSide = string.Empty,
|
||||
positionExecutive = string.Empty,
|
||||
positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName,
|
||||
positionLevel = placementProfile.PositionLevel == null ? string.Empty : placementProfile.PositionLevel.Name,
|
||||
refCommandNo = string.Empty,
|
||||
templateDoc = string.Empty,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
placementProfile.PlacementStatus = "CONTAIN";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue