add nuget aws s3
This commit is contained in:
parent
1c74945f4e
commit
f83a59733f
5 changed files with 115 additions and 70 deletions
|
|
@ -269,24 +269,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Where(x => x.RetirementPeriod == retire)
|
||||
.Select(x => new
|
||||
{
|
||||
Order = x.Order,
|
||||
Id = x.Id,
|
||||
Reason = x.Reason,
|
||||
Remove = x.Remove,
|
||||
ProfileId = x.Profile.Id,
|
||||
CitizenId = x.Profile.CitizenId,
|
||||
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
FullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
OrganizationOrganization = x.Profile.OrganizationOrganization,
|
||||
Oc = x.Profile.Oc,
|
||||
Position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
PositionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
PositionExecutive = x.Profile.PositionExecutive,
|
||||
PosNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
PositionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
PositionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
PositionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
PosNoEmployee = x.Profile.PosNoEmployee,
|
||||
order = x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
profileId = x.Profile.Id,
|
||||
citizenId = x.Profile.CitizenId,
|
||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
||||
oc = x.Profile.Oc,
|
||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
positionExecutive = x.Profile.PositionExecutive,
|
||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
posNoEmployee = x.Profile.PosNoEmployee,
|
||||
})
|
||||
.ToListAsync();
|
||||
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
|
||||
|
|
@ -321,32 +321,47 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
var profileHistorys = await _context.RetirementPeriodHistorys.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == req.RetireHistoryId);
|
||||
if (profileHistorys == null)
|
||||
return Error(GlobalMessages.InvalidRetirementHistoryRequest, 404);
|
||||
using (var client = new HttpClient())
|
||||
|
||||
var profileOlds = new List<RetirementProfile>();
|
||||
if (profileHistorys != null)
|
||||
{
|
||||
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/retire/{profileHistorys.ProfileFile}";
|
||||
var responseTask = client.GetAsync(url);
|
||||
var results = responseTask.Result;
|
||||
var profileOlds = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RetirementProfile>>(results.Content.ReadAsStringAsync().Result);
|
||||
if (profileOlds != null)
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
foreach (var profileOld in profileOlds)
|
||||
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/retire/{profileHistorys.ProfileFile}";
|
||||
var responseTask = client.GetAsync(url);
|
||||
var results = responseTask.Result;
|
||||
profileOlds = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RetirementProfile>>(results.Content.ReadAsStringAsync().Result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var retireOld = await _context.RetirementPeriods
|
||||
.FirstOrDefaultAsync(x => x.Id == req.RetireHistoryId);
|
||||
if (retireOld == null)
|
||||
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
||||
profileOlds = await _context.RetirementProfiles.AsQueryable()
|
||||
.Where(x => x.RetirementPeriod == retireOld)
|
||||
.ToListAsync();
|
||||
}
|
||||
if (profileOlds != null)
|
||||
{
|
||||
profileOlds = profileOlds.Where(x => !x.Remove.Trim().ToUpper().Contains("REMOVE")).ToList();
|
||||
foreach (var profileOld in profileOlds)
|
||||
{
|
||||
var data = new RetirementProfile
|
||||
{
|
||||
var data = new RetirementProfile
|
||||
{
|
||||
Order = profileOld.Order,
|
||||
Remove = "PENDING",
|
||||
RetirementPeriod = retire,
|
||||
Profile = profileOld.Profile,
|
||||
CreatedUserId = profileOld.CreatedUserId,
|
||||
CreatedFullName = profileOld.CreatedFullName,
|
||||
CreatedAt = profileOld.CreatedAt,
|
||||
LastUpdateFullName = profileOld.LastUpdateFullName,
|
||||
LastUpdateUserId = profileOld.LastUpdateUserId,
|
||||
LastUpdatedAt = profileOld.LastUpdatedAt,
|
||||
};
|
||||
}
|
||||
Order = profileOld.Order,
|
||||
Remove = "PENDING",
|
||||
RetirementPeriod = retire,
|
||||
Profile = profileOld.Profile,
|
||||
CreatedUserId = profileOld.CreatedUserId,
|
||||
CreatedFullName = profileOld.CreatedFullName,
|
||||
CreatedAt = profileOld.CreatedAt,
|
||||
LastUpdateFullName = profileOld.LastUpdateFullName,
|
||||
LastUpdateUserId = profileOld.LastUpdateUserId,
|
||||
LastUpdatedAt = profileOld.LastUpdatedAt,
|
||||
};
|
||||
retire.RetirementProfiles.Add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -358,24 +373,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Where(x => x.RetirementPeriod == retire)
|
||||
.Select(x => new
|
||||
{
|
||||
Order = x.Order,
|
||||
Id = x.Id,
|
||||
Reason = x.Reason,
|
||||
Remove = x.Remove,
|
||||
ProfileId = x.Profile.Id,
|
||||
CitizenId = x.Profile.CitizenId,
|
||||
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
FullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
OrganizationOrganization = x.Profile.OrganizationOrganization,
|
||||
Oc = x.Profile.Oc,
|
||||
Position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
PositionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
PositionExecutive = x.Profile.PositionExecutive,
|
||||
PosNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
PositionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
PositionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
PositionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
PosNoEmployee = x.Profile.PosNoEmployee,
|
||||
order = x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
profileId = x.Profile.Id,
|
||||
citizenId = x.Profile.CitizenId,
|
||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
||||
oc = x.Profile.Oc,
|
||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
positionExecutive = x.Profile.PositionExecutive,
|
||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
posNoEmployee = x.Profile.PosNoEmployee,
|
||||
})
|
||||
.ToListAsync();
|
||||
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, profile = profile_new });
|
||||
|
|
@ -404,15 +419,39 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error(GlobalMessages.InvalidRetirementHistoryRequest, 404);
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/retire/{profileHistorys.ProfileFile}";
|
||||
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/retire/{profileHistorys.ProfileFile}.json";
|
||||
var responseTask = client.GetAsync(url);
|
||||
var results = responseTask.Result;
|
||||
// Console.WriteLine(results.Content.ReadAsStringAsync().Result);
|
||||
return Success(new { Json = true, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RetirementProfile>>(results.Content.ReadAsStringAsync().Result) });
|
||||
return Success(new { Json = true, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(results.Content.ReadAsStringAsync().Result) });
|
||||
}
|
||||
}
|
||||
var profile_new = await _context.RetirementProfiles
|
||||
.Where(x => x.RetirementPeriod == retire)
|
||||
.Select(x => new
|
||||
{
|
||||
order = x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
profileId = x.Profile.Id,
|
||||
citizenId = x.Profile.CitizenId,
|
||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
||||
oc = x.Profile.Oc,
|
||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
||||
positionExecutive = x.Profile.PositionExecutive,
|
||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||
posNoEmployee = x.Profile.PosNoEmployee,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Success(new { Json = false, profile = retire.RetirementProfiles });
|
||||
return Success(new { Json = false, profile = profile_new });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue