add nuget aws s3
This commit is contained in:
parent
1c74945f4e
commit
f83a59733f
5 changed files with 115 additions and 70 deletions
|
|
@ -7,6 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.201.7" />
|
||||
<PackageReference Include="EPPlus" Version="6.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||
|
|
|
|||
|
|
@ -268,6 +268,11 @@ namespace BMA.EHR.Application.Repositories
|
|||
var fileExt = Path.GetExtension(fileName);
|
||||
var fileType = MimeTypeMap.GetMimeType(fileExt);
|
||||
var file_name = Path.GetFileName(fileName);
|
||||
Console.WriteLine($"{_bucketName}{subFolder}");
|
||||
Console.WriteLine(fileName);
|
||||
Console.WriteLine(file_name);
|
||||
Console.WriteLine(filestream);
|
||||
Console.WriteLine(fileType);
|
||||
|
||||
var request = new PutObjectRequest
|
||||
{
|
||||
|
|
@ -288,17 +293,15 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
public async Task GenerateJsonFile(string json, string path, string fileName)
|
||||
{
|
||||
var tmpFile = "";
|
||||
var tmpDir = Path.Combine("tmp");
|
||||
if (!Directory.Exists(tmpDir))
|
||||
Directory.CreateDirectory(tmpDir);
|
||||
|
||||
var tmpFile = Path.Combine(tmpDir, $"tmp_{DateTime.Now.ToString("ddMMyyyyHHmmss")}{fileName}.json");
|
||||
|
||||
try
|
||||
{
|
||||
var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
|
||||
if (!Directory.Exists(tmpDir))
|
||||
Directory.CreateDirectory(tmpDir);
|
||||
|
||||
fileName = $"{fileName}.json";
|
||||
tmpFile = Path.Combine(tmpDir, fileName);
|
||||
SaveToJsonFile(tmpFile, json);
|
||||
|
||||
await UploadFileAsyncTemp(tmpFile, path);
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.S3" Version="3.7.201.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
1
BMA.EHR.Retirement.Service/tmp/20230803T211254.json
Normal file
1
BMA.EHR.Retirement.Service/tmp/20230803T211254.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[{"order":2,"id":"08db93d9-a26b-4a93-8ecc-01f6bc4425b7","reason":"","remove":"PENDING","profileId":"08db721d-b171-45f1-845e-d78809081cfa","citizenId":"0000000000053","prefix":"นาย","fullName":"บล ตง","organizationOrganization":"กองพัฒนาระบบราชการกรุงเทพมหานคร","oc":"ปลัดกรุงเทพมหานคร/สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร/กองพัฒนาระบบราชการกรุงเทพมหานคร","position":"ผู้อำนวยการ","positionType":"อำนวยการ","positionExecutive":"ผู้อำนวยการกอง","posNo":"กพร.1","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null},{"order":1,"id":"08db93d9-a26f-4d4e-885e-c996514222f2","reason":"","remove":"PENDING","profileId":"08db721d-b438-414e-861a-bd74b2cc8b03","citizenId":"0000000000088","prefix":"นาง","fullName":"สจ สว","organizationOrganization":"ส่วนโครงสร้างและอัตรากำลัง","oc":"ปลัดกรุงเทพมหานคร/สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร/กองอัตรากำลัง/ส่วนโครงสร้างและอัตรากำลัง","position":"ผู้อำนวยการ","positionType":"อำนวยการ","positionExecutive":"ผู้อำนวยการส่วน","posNo":"กคอ.70","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null},{"order":4,"id":"08db93d9-a26f-4dbb-8afb-4bed0ac1c147","reason":"","remove":"PENDING","profileId":"08db721d-bb39-4902-8dab-dc582de20ab7","citizenId":"0000000000209","prefix":"นางสาว","fullName":"วณ มจ","organizationOrganization":"ฝ่ายบริหารงานทั่วไป","oc":"ปลัดกรุงเทพมหานคร/สำนักปลัดกรุงเทพมหานคร/สถาบันพัฒนาข้าราชการกรุงเทพมหานคร/ฝ่ายบริหารงานทั่วไป","position":"เจ้าพนักงานธุรการ","positionType":"ทั่วไป","positionExecutive":null,"posNo":"สพข.15","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null},{"order":3,"id":"08db93d9-a26f-4ddf-8c67-3ce67296b477","reason":"","remove":"PENDING","profileId":"08db721d-c0f0-4a43-820e-0d505da95a20","citizenId":"0000000000301","prefix":"นางสาว","fullName":"มร พจ","organizationOrganization":"ศูนย์การเรียนรู้มหานคร","oc":"ปลัดกรุงเทพมหานคร/สำนักปลัดกรุงเทพมหานคร/สถาบันพัฒนาข้าราชการกรุงเทพมหานคร/ศูนย์การเรียนรู้มหานคร","position":"นักจัดการงานทั่วไป","positionType":"วิชาการ","positionExecutive":"ผู้อำนวยการศูนย์","posNo":"สพข.107","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null}]
|
||||
Loading…
Add table
Add a link
Reference in a new issue