diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 5b8491bc..f4f905a3 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -9109,479 +9109,488 @@ namespace BMA.EHR.Application.Repositories.Commands var profiles = await _dbContext.Set() .Include(x => x.Prefix) .Include(x => x.Gender) - .Include(x => x.PositionLevel) - .Include(x => x.PositionType) - .Include(x => x.ChangeNames) - .Include(x => x.FatherHistory) - .Include(x => x.MotherHistory) - .Include(x => x.CoupleHistory) - .Include(x => x.Childrens) - .Include(x => x.Educations) - .Include(x => x.Abilitys) - .Include(x => x.Disciplines) - .Include(x => x.Leaves) - .Include(x => x.Dutys) - .Include(x => x.Salaries) - .Include(x => x.Nopaids) - .Include(x => x.Certificates) - .Include(x => x.Trainings) - .Include(x => x.Insignias) - .Include(x => x.Honors) - .Include(x => x.Assessments) - .Include(x => x.Others) + // .Include(x => x.PositionLevel) + // .Include(x => x.PositionType) + // .Include(x => x.ChangeNames) + // .Include(x => x.FatherHistory) + // .Include(x => x.MotherHistory) + // .Include(x => x.CoupleHistory) + // .Include(x => x.Childrens) + // .Include(x => x.Educations) + // .Include(x => x.Abilitys) + // .Include(x => x.Disciplines) + // .Include(x => x.Leaves) + // .Include(x => x.Dutys) + // .Include(x => x.Salaries) + // .Include(x => x.Nopaids) + // .Include(x => x.Certificates) + // .Include(x => x.Trainings) + // .Include(x => x.Insignias) + // .Include(x => x.Honors) + // .Include(x => x.Assessments) + // .Include(x => x.Others) + // .Take(10) .ToListAsync(); - //var _baseAPI = _configuration["API"]; - var _baseAPI = "http://localhost:13001/api/v1"; + var _baseAPI = _configuration["API"]; + // var _baseAPI = "http://localhost:13001/api/v1"; // create new profile foreach (var profile in profiles) { - var apiUrl = $"{_baseAPI}/org/profile/all/dump-db"; - 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 = profile.Prefix != null ? profile.Prefix.Name.ToString() : string.Empty, - firstName = profile.FirstName, - lastName = profile.LastName, - citizenId = profile.CitizenId, - position = profile.Position, - posLevelId = profile.PositionLevel != null ? profile.PositionLevel.Name.ToString() : string.Empty, - posTypeId = profile.PositionType != null ? profile.PositionType.Name.ToString() : string.Empty, - email = string.Empty, - phone = string.Empty, - keycloak = profile.KeycloakId, - isProbation = profile.IsProbation, - isLeave = profile.IsLeave, - dateRetire = profile.DateRetire, - dateAppoint = profile.DateAppoint, - dateStart = profile.DateStart, - govAgeAbsent = profile.GovAgeAbsent, - govAgePlus = profile.GovAgePlus, - birthDate = profile.BirthDate, - reasonSameDate = profile.ReasonSameDate, - ethnicity = profile.Race, - telephoneNumber = profile.TelephoneNumber, - nationality = profile.Nationality == null ? string.Empty : profile.Nationality, - gender = profile.Gender != null ? profile.Gender.Name.ToString() : null, - relationship = profile.RelationshipId != null - ? await _dbContext.Set().Where(r => r.Id == profile.RelationshipId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - religion = profile.ReligionId != null - ? await _dbContext.Set().Where(r => r.Id == profile.ReligionId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - bloodGroup = profile.BloodGroupId != null - ? await _dbContext.Set().Where(r => r.Id == profile.BloodGroupId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - registrationAddress = profile.RegistrationAddress, - registrationProvinceId = profile.RegistrationProvinceId != null - ? await _dbContext.Set().Where(r => r.Id == profile.RegistrationProvinceId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - registrationDistrictId = profile.RegistrationDistrictId != null - ? await _dbContext.Set().Where(r => r.Id == profile.RegistrationDistrictId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - registrationSubDistrictId = profile.RegistrationSubDistrictId != null - ? await _dbContext.Set().Where(r => r.Id == profile.RegistrationSubDistrictId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - registrationZipCode = profile.RegistrationZipCode, - currentAddress = profile.CurrentAddress, - currentProvinceId = profile.CurrentProvinceId != null - ? await _dbContext.Set().Where(r => r.Id == profile.CurrentProvinceId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - currentDistrictId = profile.CurrentDistrictId != null - ? await _dbContext.Set().Where(r => r.Id == profile.CurrentDistrictId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - currentSubDistrictId = profile.CurrentSubDistrictId != null - ? await _dbContext.Set().Where(r => r.Id == profile.CurrentSubDistrictId).Select(r => r.Name).FirstOrDefaultAsync() - : null, - currentZipCode = profile.CurrentZipCode, + // var apiUrl = $"{_baseAPI}/org/profile/all/dump-db"; + // 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 + // { + // id = profile.Id, + // rank = string.Empty, + // prefix = profile.Prefix != null ? profile.Prefix.Name.ToString() : string.Empty, + // firstName = profile.FirstName, + // lastName = profile.LastName, + // citizenId = profile.CitizenId, + // position = "", + // posLevelId = "", + // posTypeId = "", + // email = string.Empty, + // phone = string.Empty, + // keycloak = profile.KeycloakId, + // isProbation = profile.IsProbation, + // isLeave = profile.IsLeave, + // dateRetire = profile.DateRetire, + // dateAppoint = profile.DateAppoint, + // dateStart = profile.DateStart, + // govAgeAbsent = profile.GovAgeAbsent, + // govAgePlus = profile.GovAgePlus, + // birthDate = profile.BirthDate, + // reasonSameDate = profile.ReasonSameDate, + // ethnicity = profile.Race, + // telephoneNumber = profile.TelephoneNumber, + // nationality = profile.Nationality == null ? string.Empty : profile.Nationality, + // gender = profile.Gender != null ? profile.Gender.Name.ToString() : null, + // relationship = profile.RelationshipId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.RelationshipId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // religion = profile.ReligionId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.ReligionId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // bloodGroup = profile.BloodGroupId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.BloodGroupId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // registrationAddress = profile.RegistrationAddress, + // registrationProvinceId = profile.RegistrationProvinceId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.RegistrationProvinceId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // registrationDistrictId = profile.RegistrationDistrictId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.RegistrationDistrictId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // registrationSubDistrictId = profile.RegistrationSubDistrictId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.RegistrationSubDistrictId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // registrationZipCode = profile.RegistrationZipCode, + // currentAddress = profile.CurrentAddress, + // currentProvinceId = profile.CurrentProvinceId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.CurrentProvinceId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // currentDistrictId = profile.CurrentDistrictId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.CurrentDistrictId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // currentSubDistrictId = profile.CurrentSubDistrictId != null + // ? await _dbContext.Set().Where(r => r.Id == profile.CurrentSubDistrictId).Select(r => r.Name).FirstOrDefaultAsync() + // : null, + // currentZipCode = profile.CurrentZipCode, - }); - var _result = await _res.Content.ReadAsStringAsync(); - //ยังไม่ SAVE จริง - //profileId = JsonConvert.DeserializeObject(_result).result; /*แบบเก่า*/ - //profileId = JsonConvert.DeserializeAnonymousType(_result, new { result = "" }).result; /*แบบใหม่*/ - } + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // //ยังไม่ SAVE จริง + // //profileId = JsonConvert.DeserializeObject(_result).result; /*แบบเก่า*/ + // //profileId = JsonConvert.DeserializeAnonymousType(_result, new { result = "" }).result; /*แบบใหม่*/ + // } #region profileData - if (profile.ChangeNames.Count > 0) + // if (profile.ChangeNames.Count > 0) + // { + // var apiUrlChgName = $"{_baseAPI}/org/profile/changeName"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var chg in profile.ChangeNames) + // { + // var _res = await client.PostAsJsonAsync(apiUrlChgName, new + // { + // profileId = profileId, + // prefixId = string.Empty, //where in node + // prefix = chg.Prefix, + // firstName = chg.FirstName, + // lastName = chg.LastName, + // status = chg.Status, + // documentId = chg.Document, + + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.FatherHistory.Count > 0) + // { + // var apiUrlFather = $"{_baseAPI}/org/profile/family/father"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var father in profile.FatherHistory) + // { + // var _res = await client.PostAsJsonAsync(apiUrlFather, new + // { + // profileId = profileId, + // fatherPrefix = father.Prefix, + // fatherFirstName = father.FirstName, + // fatherLastName = father.LastName, + // fatherCareer = father.Career, + // fatherCitizenId = string.Empty, + // fatherLive = true, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.MotherHistory.Count > 0) + // { + // var apiUrlMother = $"{_baseAPI}/org/profile/family/mother"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var mother in profile.MotherHistory) + // { + // var _res = await client.PostAsJsonAsync(apiUrlMother, new + // { + // profileId = profileId, + // motherPrefix = mother.Prefix, + // motherFirstName = mother.FirstName, + // motherLastName = mother.LastName, + // motherCareer = mother.Career, + // motherCitizenId = string.Empty, + // motherLive = true, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.CoupleHistory.Count > 0) + // { + // var apiUrlCouple = $"{_baseAPI}/org/profile/family/couple"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var couple in profile.CoupleHistory) + // { + // var _res = await client.PostAsJsonAsync(apiUrlCouple, new + // { + // profileId = profileId, + // couplePrefix = couple.Prefix, + // coupleFirstName = couple.FirstName, + // coupleLastName = couple.LastName, + // coupleLastNameOld = string.Empty, + // coupleCareer = couple.Career, + // coupleCitizenId = string.Empty, + // coupleLive = true, + // relationship = string.Empty, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Childrens.Count > 0) + // { + // var apiUrlChild = $"{_baseAPI}/org/profile/children"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var children in profile.Childrens) + // { + // var _res = await client.PostAsJsonAsync(apiUrlChild, new + // { + // profileId = profileId, + // childrenCareer = children.ChildrenCareer, + // childrenFirstName = children.ChildrenFirstName, + // childrenLastName = children.ChildrenLastName, + // childrenPrefix = children.ChildrenPrefix, + // childrenLive = true, + // childrenCitizenId = string.Empty, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Educations.Count > 0) + // { + // var apiUrlEdu = $"{_baseAPI}/org/profile/educations"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var edu in profile.Educations) + // { + // var _res = await client.PostAsJsonAsync(apiUrlEdu, new + // { + // profileId = profileId, + // country = edu.Country, + // degree = edu.Degree, + // duration = edu.Duration, + // durationYear = edu.DurationYear, + // field = edu.Field, + // finishDate = edu.FinishDate, + // fundName = edu.FundName, + // gpa = edu.Gpa, + // institute = edu.Institute, + // other = edu.Other, + // startDate = edu.StartDate, + // endDate = edu.EndDate, + // educationLevel = edu.EducationLevel, + // educationLevelId = string.Empty, //where in node + // positionPath = edu.PositionPath, + // positionPathId = string.Empty, //where in node + // isDate = false, + // isEducation = false, + // note = edu.Note, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Abilitys.Count > 0) + // { + // var apiUrlAbility = $"{_baseAPI}/org/profile/ability"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var ability in profile.Abilitys) + // { + // var _res = await client.PostAsJsonAsync(apiUrlAbility, new + // { + // profileId = profileId, + // remark = ability.Remark, + // detail = ability.Detail, + // reference = ability.Reference, + // dateStart = ability.DateStart, + // dateEnd = ability.DateEnd, + // field = ability.Field, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Disciplines.Count > 0) + // { + // var apiUrlDisc = $"{_baseAPI}/org/profile/discipline"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var discipline in profile.Disciplines) + // { + // var _res = await client.PostAsJsonAsync(apiUrlDisc, new + // { + // profileId = profileId, + // date = discipline.Date, + // level = discipline.Level, + // detail = discipline.Detail, + // refCommandDate = discipline.RefCommandDate, + // refCommandNo = discipline.RefCommandNo, + // unStigma = string.Empty, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Leaves.Count > 0) + // { + // var apiUrlLeave = $"{_baseAPI}/org/profile/leave/dump-db"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var leave in profile.Leaves) + // { + // var TypeLeaveName = await _dbContext.Set() + // .Include(x => x.TypeLeave).Where(x => x.Id == leave.Id).Select(x => x.TypeLeave.Name).FirstOrDefaultAsync(); + + // var _res = await client.PostAsJsonAsync(apiUrlLeave, new + // { + // profileId = profileId, + // leaveTypeId = TypeLeaveName == null ? string.Empty : TypeLeaveName, //where in node + // dateLeaveStart = leave.DateStartLeave, + // dateLeaveEnd = leave.DateEndLeave, + // leaveDays = leave.SumLeave, + // leaveCount = leave.NumLeave, + // totalLeave = leave.TotalLeave, + // status = leave.Status, + // reason = leave.Reason, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Dutys.Count > 0) + // { + // var apiUrlDuty = $"{_baseAPI}/org/profile/duty"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var duty in profile.Dutys) + // { + // var _res = await client.PostAsJsonAsync(apiUrlDuty, new + // { + // profileId = profileId, + // dateStart = duty.DateStart, + // dateEnd = duty.DateEnd, + // detail = duty.Detail, + // reference = duty.Reference, + // refCommandDate = string.Empty, + // refCommandNo = string.Empty, + + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // var Salaries = await _dbContext.Set() + // .Where(x => x.Profile.Id == profile.Id) + // .ToListAsync(); + // if (Salaries.Count > 0) + // { + // var apiUrlSalary = $"{_baseAPI}/org/profile/salary"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var salary in Salaries) + // { + // var _res = await client.PostAsJsonAsync(apiUrlSalary, new + // { + // profileId = profile.Id, + // date = salary.Date, + // amount = salary.Amount, + // positionSalaryAmount = salary.PositionSalaryAmount, + // mouthSalaryAmount = salary.MouthSalaryAmount, + // posNo = salary.PosNoName, + // position = salary.PositionName, + // positionLine = salary.PositionLineName, + // positionPathSide = salary.PositionPathSideName, + // positionExecutive = salary.PositionExecutiveName, + // positionType = salary.PositionTypeName, + // positionLevel = salary.PositionLevelName, + // refCommandNo = salary.RefCommandNo, + // templateDoc = salary.SalaryRef, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Nopaids.Count > 0) + // { + // var apiUrlNopaid = $"{_baseAPI}/org/profile/nopaid"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var nopaid in profile.Nopaids) + // { + // var _res = await client.PostAsJsonAsync(apiUrlNopaid, new + // { + // profileId = profileId, + // date = nopaid.Date, + // detail = nopaid.Detail, + // reference = nopaid.Reference, + // refCommandDate = (DateTime?)null, + // refCommandNo = string.Empty, + + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Certificates.Count > 0) + // { + // var apiUrlCer = $"{_baseAPI}/org/profile/certificate"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var cer in profile.Certificates) + // { + // var _res = await client.PostAsJsonAsync(apiUrlCer, new + // { + // profileId = profileId, + // expireDate = cer.ExpireDate, + // issueDate = cer.IssueDate, + // certificateNo = cer.CertificateNo, + // certificateType = cer.CertificateType, + // issuer = cer.Issuer, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + // if (profile.Trainings.Count > 0) + // { + // var apiUrlTrain = $"{_baseAPI}/org/profile/training"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var train in profile.Trainings) + // { + // var _res = await client.PostAsJsonAsync(apiUrlTrain, new + // { + // profileId = profileId, + // startDate = train.StartDate, + // endDate = train.EndDate, + // numberOrder = train.NumberOrder, + // topic = train.Topic, + // place = train.Place, + // dateOrder = train.DateOrder, + // department = train.StartDate, + // duration = train.Duration, + // name = train.Name, + // yearly = train.Yearly, + // isDate = train.IsDate, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } + + var Insignias = await _dbContext.Set() + .Include(x => x.Insignia) + .Where(x => x.Profile.Id == profile.Id) + .ToListAsync(); + if (Insignias.Count > 0) { - var apiUrlChgName = $"{_baseAPI}/org/profile/changeName"; + var apiUrlInsig = $"{_baseAPI}/org/dotnet/insignia/Dumb"; using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var chg in profile.ChangeNames) - { - var _res = await client.PostAsJsonAsync(apiUrlChgName, new - { - profileId = profileId, - prefixId = string.Empty, //where in node - prefix = chg.Prefix, - firstName = chg.FirstName, - lastName = chg.LastName, - status = chg.Status, - documentId = chg.Document, - - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.FatherHistory.Count > 0) - { - var apiUrlFather = $"{_baseAPI}/org/profile/family/father"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var father in profile.FatherHistory) - { - var _res = await client.PostAsJsonAsync(apiUrlFather, new - { - profileId = profileId, - fatherPrefix = father.Prefix, - fatherFirstName = father.FirstName, - fatherLastName = father.LastName, - fatherCareer = father.Career, - fatherCitizenId = string.Empty, - fatherLive = true, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.MotherHistory.Count > 0) - { - var apiUrlMother = $"{_baseAPI}/org/profile/family/mother"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var mother in profile.MotherHistory) - { - var _res = await client.PostAsJsonAsync(apiUrlMother, new - { - profileId = profileId, - motherPrefix = mother.Prefix, - motherFirstName = mother.FirstName, - motherLastName = mother.LastName, - motherCareer = mother.Career, - motherCitizenId = string.Empty, - motherLive = true, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.CoupleHistory.Count > 0) - { - var apiUrlCouple = $"{_baseAPI}/org/profile/family/couple"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var couple in profile.CoupleHistory) - { - var _res = await client.PostAsJsonAsync(apiUrlCouple, new - { - profileId = profileId, - couplePrefix = couple.Prefix, - coupleFirstName = couple.FirstName, - coupleLastName = couple.LastName, - coupleLastNameOld = string.Empty, - coupleCareer = couple.Career, - coupleCitizenId = string.Empty, - coupleLive = true, - relationship = string.Empty, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Childrens.Count > 0) - { - var apiUrlChild = $"{_baseAPI}/org/profile/children"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var children in profile.Childrens) - { - var _res = await client.PostAsJsonAsync(apiUrlChild, new - { - profileId = profileId, - childrenCareer = children.ChildrenCareer, - childrenFirstName = children.ChildrenFirstName, - childrenLastName = children.ChildrenLastName, - childrenPrefix = children.ChildrenPrefix, - childrenLive = true, - childrenCitizenId = string.Empty, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Educations.Count > 0) - { - var apiUrlEdu = $"{_baseAPI}/org/profile/educations"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var edu in profile.Educations) - { - var _res = await client.PostAsJsonAsync(apiUrlEdu, new - { - profileId = profileId, - country = edu.Country, - degree = edu.Degree, - duration = edu.Duration, - durationYear = edu.DurationYear, - field = edu.Field, - finishDate = edu.FinishDate, - fundName = edu.FundName, - gpa = edu.Gpa, - institute = edu.Institute, - other = edu.Other, - startDate = edu.StartDate, - endDate = edu.EndDate, - educationLevel = edu.EducationLevel, - educationLevelId = string.Empty, //where in node - positionPath = edu.PositionPath, - positionPathId = string.Empty, //where in node - isDate = false, - isEducation = false, - note = edu.Note, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Abilitys.Count > 0) - { - var apiUrlAbility = $"{_baseAPI}/org/profile/ability"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var ability in profile.Abilitys) - { - var _res = await client.PostAsJsonAsync(apiUrlAbility, new - { - profileId = profileId, - remark = ability.Remark, - detail = ability.Detail, - reference = ability.Reference, - dateStart = ability.DateStart, - dateEnd = ability.DateEnd, - field = ability.Field, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Disciplines.Count > 0) - { - var apiUrlDisc = $"{_baseAPI}/org/profile/discipline"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var discipline in profile.Disciplines) - { - var _res = await client.PostAsJsonAsync(apiUrlDisc, new - { - profileId = profileId, - date = discipline.Date, - level = discipline.Level, - detail = discipline.Detail, - refCommandDate = discipline.RefCommandDate, - refCommandNo = discipline.RefCommandNo, - unStigma = string.Empty, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Leaves.Count > 0) - { - var apiUrlLeave = $"{_baseAPI}/org/profile/leave/dump-db"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var leave in profile.Leaves) - { - var TypeLeaveName = await _dbContext.Set() - .Include(x => x.TypeLeave).Where(x => x.Id == leave.Id).Select(x => x.TypeLeave.Name).FirstOrDefaultAsync(); - - var _res = await client.PostAsJsonAsync(apiUrlLeave, new - { - profileId = profileId, - leaveTypeId = TypeLeaveName == null ? string.Empty : TypeLeaveName, //where in node - dateLeaveStart = leave.DateStartLeave, - dateLeaveEnd = leave.DateEndLeave, - leaveDays = leave.SumLeave, - leaveCount = leave.NumLeave, - totalLeave = leave.TotalLeave, - status = leave.Status, - reason = leave.Reason, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Dutys.Count > 0) - { - var apiUrlDuty = $"{_baseAPI}/org/profile/duty"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var duty in profile.Dutys) - { - var _res = await client.PostAsJsonAsync(apiUrlDuty, new - { - profileId = profileId, - dateStart = duty.DateStart, - dateEnd = duty.DateEnd, - detail = duty.Detail, - reference = duty.Reference, - refCommandDate = string.Empty, - refCommandNo = string.Empty, - - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Salaries.Count > 0) - { - var apiUrlSalary = $"{_baseAPI}/org/profile/salary"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var salary in profile.Salaries) - { - var _res = await client.PostAsJsonAsync(apiUrlSalary, new - { - profileId = profileId, - date = salary.Date, - amount = salary.Amount, - positionSalaryAmount = salary.PositionSalaryAmount, - mouthSalaryAmount = salary.MouthSalaryAmount, - posNo = salary.PosNoName, - position = salary.PositionName, - positionLine = salary.PositionLineName, - positionPathSide = salary.PositionPathSideName, - positionExecutive = salary.PositionExecutiveName, - positionType = salary.PositionTypeName, - positionLevel = salary.PositionLevelName, - refCommandNo = salary.RefCommandNo, - templateDoc = salary.SalaryRef, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Nopaids.Count > 0) - { - var apiUrlNopaid = $"{_baseAPI}/org/profile/nopaid"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var nopaid in profile.Nopaids) - { - var _res = await client.PostAsJsonAsync(apiUrlNopaid, new - { - profileId = profileId, - date = nopaid.Date, - detail = nopaid.Detail, - reference = nopaid.Reference, - refCommandDate = (DateTime?)null, - refCommandNo = string.Empty, - - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Certificates.Count > 0) - { - var apiUrlCer = $"{_baseAPI}/org/profile/certificate"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var cer in profile.Certificates) - { - var _res = await client.PostAsJsonAsync(apiUrlCer, new - { - profileId = profileId, - expireDate = cer.ExpireDate, - issueDate = cer.IssueDate, - certificateNo = cer.CertificateNo, - certificateType = cer.CertificateType, - issuer = cer.Issuer, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Trainings.Count > 0) - { - var apiUrlTrain = $"{_baseAPI}/org/profile/training"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var train in profile.Trainings) - { - var _res = await client.PostAsJsonAsync(apiUrlTrain, new - { - profileId = profileId, - startDate = train.StartDate, - endDate = train.EndDate, - numberOrder = train.NumberOrder, - topic = train.Topic, - place = train.Place, - dateOrder = train.DateOrder, - department = train.StartDate, - duration = train.Duration, - name = train.Name, - yearly = train.Yearly, - isDate = train.IsDate, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } - - if (profile.Insignias.Count > 0) - { - var apiUrlInsig = $"{_baseAPI}/org/profile/insignia/dump-db"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var insignia in profile.Insignias) + foreach (var insignia in Insignias) { var _res = await client.PostAsJsonAsync(apiUrlInsig, new { - profileId = profileId, + profileId = profile.Id, year = insignia.Year, no = insignia.No, volume = insignia.Volume, section = insignia.Section, page = insignia.Page, receiveDate = insignia.ReceiveDate, - insigniaId = insignia.InsigniaType, //where in node + insigniaId = insignia.Insignia.Id, //where in node dateAnnounce = insignia.DateAnnounce, issue = insignia.Issue, volumeNo = insignia.VolumeNo, @@ -9594,72 +9603,72 @@ namespace BMA.EHR.Application.Repositories.Commands } } - if (profile.Honors.Count > 0) - { - var apiUrlHonor = $"{_baseAPI}/org/profile/honor"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var honor in profile.Honors) - { - var _res = await client.PostAsJsonAsync(apiUrlHonor, new - { - profileId = profileId, - detail = honor.Detail, - issueDate = honor.IssueDate, - issuer = honor.Issuer, - refCommandDate = (DateTime?)null, - refCommandNo = string.Empty, - isDate = honor.IsDate, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } + // if (profile.Honors.Count > 0) + // { + // var apiUrlHonor = $"{_baseAPI}/org/profile/honor"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var honor in profile.Honors) + // { + // var _res = await client.PostAsJsonAsync(apiUrlHonor, new + // { + // profileId = profileId, + // detail = honor.Detail, + // issueDate = honor.IssueDate, + // issuer = honor.Issuer, + // refCommandDate = (DateTime?)null, + // refCommandNo = string.Empty, + // isDate = honor.IsDate, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } - if (profile.Assessments.Count > 0) - { - var apiUrlAssess = $"{_baseAPI}/org/profile/assessments"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var assess in profile.Assessments) - { - var _res = await client.PostAsJsonAsync(apiUrlAssess, new - { - profileId = profileId, - name = assess.Name, - date = assess.Date, - point1 = assess.Point1, - point1Total = assess.Point1Total, - point2 = assess.Point2, - point2Total = assess.Point2Total, - pointSum = assess.PointSum, - pointSumTotal = assess.PointSumTotal, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } + // if (profile.Assessments.Count > 0) + // { + // var apiUrlAssess = $"{_baseAPI}/org/profile/assessments"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var assess in profile.Assessments) + // { + // var _res = await client.PostAsJsonAsync(apiUrlAssess, new + // { + // profileId = profileId, + // name = assess.Name, + // date = assess.Date, + // point1 = assess.Point1, + // point1Total = assess.Point1Total, + // point2 = assess.Point2, + // point2Total = assess.Point2Total, + // pointSum = assess.PointSum, + // pointSumTotal = assess.PointSumTotal, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } - if (profile.Others.Count > 0) - { - var apiUrlOther = $"{_baseAPI}/org/profile/other"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var other in profile.Others) - { - var _res = await client.PostAsJsonAsync(apiUrlOther, new - { - profileId = profileId, - detail = other.Detail, - date = other.Date, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } + // if (profile.Others.Count > 0) + // { + // var apiUrlOther = $"{_baseAPI}/org/profile/other"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var other in profile.Others) + // { + // var _res = await client.PostAsJsonAsync(apiUrlOther, new + // { + // profileId = profileId, + // detail = other.Detail, + // date = other.Date, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } //profile.PlacementStatus = "CONTAIN"; //await _dbContext.SaveChangesAsync(); diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 81ee3184..414073ef 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Swashbuckle.AspNetCore.Annotations; +using System.Net; using System.Net.Http.Headers; using System.Security.Claims; @@ -5500,6 +5501,44 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// แสดงประวัติการออกคำสั่ง + /// + /// ประเภทระบบคำสั่ง + /// Id ผู้ใช้งาน + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("historanfaskfa")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> DumpDB([FromHeader] string authorization) + { + try + { + var token = string.Empty; + if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue)) + { + // we have a valid AuthenticationHeaderValue that has the following details: + + var scheme = headerValue.Scheme; + token = headerValue.Parameter; + + // scheme will be "Bearer" + // parmameter will be the token itself. + } + await _repository.DumpDB(token); + + return Success(); + } + catch + { + throw; + } + } + #endregion } } diff --git a/BMA.EHR.Command.Service/appsettings.json b/BMA.EHR.Command.Service/appsettings.json index 8b9b0f23..026c49c5 100644 --- a/BMA.EHR.Command.Service/appsettings.json +++ b/BMA.EHR.Command.Service/appsettings.json @@ -14,7 +14,7 @@ "AllowedHosts": "*", "ConnectionStrings": { //"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB", - "DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + "DefaultConnection": "server=192.168.1.61;user=root;password=adminVM123;port=4061;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" }, "Jwt": { "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index 51d32283..c0f700de 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs @@ -887,71 +887,143 @@ namespace BMA.EHR.Retirement.Service.Controllers // if (old_retire != null) // num = old_retire.Order + 1; - var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.ProfileId}"; - using (var client = new HttpClient()) + if (retire.Type == "OFFICER") { - var data = new RetirementProfile + var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.ProfileId}"; + using (var client = new HttpClient()) { - Order = num, - Remove = "ADD", - RetirementPeriod = retire, - CreatedFullName = FullName ?? "System Administrator", - CreatedUserId = UserId ?? "", - CreatedAt = DateTime.Now, - LastUpdateFullName = FullName ?? "System Administrator", - LastUpdateUserId = UserId ?? "", - LastUpdatedAt = DateTime.Now, - }; + var data = new RetirementProfile + { + Order = num, + Remove = "ADD", + RetirementPeriod = retire, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); - var _res = await client.SendAsync(_req); - var _result = await _res.Content.ReadAsStringAsync(); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); - var org = JsonConvert.DeserializeObject(_result); + var org = JsonConvert.DeserializeObject(_result); - if (org == null || org.result == null) - return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); + if (org == null || org.result == null) + return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); - data.profileId = org.result.profileId; - data.prefix = org.result.prefix; - data.firstName = org.result.firstName; - data.lastName = org.result.lastName; - data.citizenId = org.result.citizenId; - data.root = org.result.root; - data.rootId = org.result.rootId; - data.rootShortName = org.result.rootShortName; - data.child1 = org.result.child1; - data.child1Id = org.result.child1Id; - data.child1ShortName = org.result.child1ShortName; - data.child2 = org.result.child2; - data.child2Id = org.result.child2Id; - data.child2ShortName = org.result.child2ShortName; - data.child3 = org.result.child3; - data.child3Id = org.result.child3Id; - data.child3ShortName = org.result.child3ShortName; - data.child4 = org.result.child4; - data.child4Id = org.result.child4Id; - data.child4ShortName = org.result.child4ShortName; - data.posMasterNo = org.result.posMasterNo; - data.position = org.result.position; - data.posTypeId = org.result.posTypeId; - data.posTypeName = org.result.posTypeName; - data.posTypeRank = org.result.posTypeRank; - data.posLevelId = org.result.posLevelId; - data.posLevelName = org.result.posLevelName; - data.posLevelRank = org.result.posLevelRank; - data.posExecutiveId = org.result.posExecutiveId; - data.posExecutiveName = org.result.posExecutiveName; - data.posNo = org.result.posNo; + data.profileId = org.result.profileId; + data.prefix = org.result.prefix; + data.firstName = org.result.firstName; + data.lastName = org.result.lastName; + data.citizenId = org.result.citizenId; + data.root = org.result.root; + data.rootId = org.result.rootId; + data.rootShortName = org.result.rootShortName; + data.child1 = org.result.child1; + data.child1Id = org.result.child1Id; + data.child1ShortName = org.result.child1ShortName; + data.child2 = org.result.child2; + data.child2Id = org.result.child2Id; + data.child2ShortName = org.result.child2ShortName; + data.child3 = org.result.child3; + data.child3Id = org.result.child3Id; + data.child3ShortName = org.result.child3ShortName; + data.child4 = org.result.child4; + data.child4Id = org.result.child4Id; + data.child4ShortName = org.result.child4ShortName; + data.posMasterNo = org.result.posMasterNo; + data.position = org.result.position; + data.posTypeId = org.result.posTypeId; + data.posTypeName = org.result.posTypeName; + data.posTypeRank = org.result.posTypeRank; + data.posLevelId = org.result.posLevelId; + data.posLevelName = org.result.posLevelName; + data.posLevelRank = org.result.posLevelRank; + data.posExecutiveId = org.result.posExecutiveId; + data.posExecutiveName = org.result.posExecutiveName; + data.posNo = org.result.posNo; - _context.RetirementProfiles.Add(data); - await _context.SaveChangesAsync(); - if (retire.RetirementPeriodHistorys.Count() == 0) - { - await GenOrderByYear(retire.Id); + _context.RetirementProfiles.Add(data); + await _context.SaveChangesAsync(); + if (retire.RetirementPeriodHistorys.Count() == 0) + { + await GenOrderByYear(retire.Id); + } + return Success(); + } + } + else + { + var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.ProfileId}"; + using (var client = new HttpClient()) + { + var data = new RetirementProfile + { + Order = num, + Remove = "ADD", + RetirementPeriod = retire, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + CreatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + }; + + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404); + + data.profileId = org.result.profileId; + data.prefix = org.result.prefix; + data.firstName = org.result.firstName; + data.lastName = org.result.lastName; + data.citizenId = org.result.citizenId; + data.root = org.result.root; + data.rootId = org.result.rootId; + data.rootShortName = org.result.rootShortName; + data.child1 = org.result.child1; + data.child1Id = org.result.child1Id; + data.child1ShortName = org.result.child1ShortName; + data.child2 = org.result.child2; + data.child2Id = org.result.child2Id; + data.child2ShortName = org.result.child2ShortName; + data.child3 = org.result.child3; + data.child3Id = org.result.child3Id; + data.child3ShortName = org.result.child3ShortName; + data.child4 = org.result.child4; + data.child4Id = org.result.child4Id; + data.child4ShortName = org.result.child4ShortName; + data.posMasterNo = org.result.posMasterNo; + data.position = org.result.position; + data.posTypeId = org.result.posTypeId; + data.posTypeName = org.result.posTypeName; + data.posTypeRank = org.result.posTypeRank; + data.posLevelId = org.result.posLevelId; + data.posLevelName = org.result.posLevelName; + data.posLevelRank = org.result.posLevelRank; + data.posExecutiveId = org.result.posExecutiveId; + data.posExecutiveName = org.result.posExecutiveName; + data.posNo = org.result.posNo; + + _context.RetirementProfiles.Add(data); + await _context.SaveChangesAsync(); + if (retire.RetirementPeriodHistorys.Count() == 0) + { + await GenOrderByYear(retire.Id); + } + return Success(); } - return Success(); } }