恢复数据测试
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
87e70447f3
commit
7ec76f6ce3
|
@ -1124,7 +1124,7 @@
|
||||||
<param name="trialId"></param>
|
<param name="trialId"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:IRaCIS.Core.Application.Service.TrialImageDownloadService.ReadExcelReStorreOSSDeleteDataAndDBData(IRaCIS.Core.Application.Helper.IOSSService,Microsoft.AspNetCore.Hosting.IWebHostEnvironment)">
|
<member name="M:IRaCIS.Core.Application.Service.TrialImageDownloadService.ReadExcelReStorreOSSDeleteDataAndDBData(IRaCIS.Core.Application.Helper.IOSSService,Microsoft.AspNetCore.Hosting.IWebHostEnvironment,System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
读取excel 恢复oss 数据,读取dicom 恢复序列和Instance
|
读取excel 恢复oss 数据,读取dicom 恢复序列和Instance
|
||||||
</summary>
|
</summary>
|
||||||
|
|
|
@ -1528,15 +1528,22 @@ namespace IRaCIS.Core.Application.Service
|
||||||
/// <param name="_oSSService"></param>
|
/// <param name="_oSSService"></param>
|
||||||
/// <param name="_hostEnvironment"></param>
|
/// <param name="_hostEnvironment"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IResponseOutput> ReadExcelReStorreOSSDeleteDataAndDBData([FromServices] IOSSService _oSSService, [FromServices] IWebHostEnvironment _hostEnvironment)
|
[AllowAnonymous]
|
||||||
|
public async Task<IResponseOutput> ReadExcelReStorreOSSDeleteDataAndDBData([FromServices] IOSSService _oSSService, [FromServices] IWebHostEnvironment _hostEnvironment, string subjectCode)
|
||||||
{
|
{
|
||||||
var folder = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
|
var folder = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
|
||||||
|
|
||||||
var trialId = Guid.Parse("01000000-ac13-0242-6397-08dcd2d2a091");
|
var trialId = Guid.Parse("01000000-ac13-0242-6397-08dcd2d2a091");
|
||||||
|
|
||||||
var rows = await MiniExcel.QueryAsync<RestoreOSSDeleteDataDTO>(@"C:\Users\hang\Desktop\删除恢复.xlsx");
|
var rows = await MiniExcel.QueryAsync<RestoreOSSDeleteDataDTO>(Path.Combine(folder, "删除恢复.xlsx"));
|
||||||
|
|
||||||
rows = rows.Where(t => !string.IsNullOrEmpty(t.FileName.ToString())).ToList();
|
var restoreRows = await MiniExcel.QueryAsync<RestoreInstanceInfo>(Path.Combine(folder, "删除需要恢复的数据.xlsx"));
|
||||||
|
|
||||||
|
rows = rows.Where(t => t.Key.IsNotNullOrEmpty()).WhereIf(subjectCode.IsNotNullOrEmpty(), t => t.SubjectCode == subjectCode.TrimStart('0')).ToList();
|
||||||
|
|
||||||
|
restoreRows = restoreRows.Where(t => t.SOPInstanceUID.IsNotNullOrEmpty()).WhereIf(subjectCode.IsNotNullOrEmpty(), t => t.SubjectCode == subjectCode).ToList();
|
||||||
|
|
||||||
|
Console.WriteLine($"恢复数量: {restoreRows.Count()}");
|
||||||
|
|
||||||
int total = rows.Count();
|
int total = rows.Count();
|
||||||
int processed = 0;
|
int processed = 0;
|
||||||
|
@ -1554,39 +1561,21 @@ namespace IRaCIS.Core.Application.Service
|
||||||
tempToken.AliyunOSS.SecurityToken);
|
tempToken.AliyunOSS.SecurityToken);
|
||||||
|
|
||||||
|
|
||||||
|
var restoreCount = 0;
|
||||||
foreach (var item in rows)
|
foreach (var item in rows)
|
||||||
{
|
{
|
||||||
#region 防止阿里云过期
|
//不包含该subject的忽略
|
||||||
if (tempToken.AliyunOSS.Expiration.AddSeconds(10) <= DateTime.Now)
|
if (!restoreRows.Any(t => t.SubjectCode.TrimStart('0') == item.SubjectCode))
|
||||||
{
|
{
|
||||||
tempToken = _oSSService.GetObjectStoreTempToken();
|
continue;
|
||||||
|
|
||||||
_ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint,
|
|
||||||
tempToken.AliyunOSS.AccessKeyId,
|
|
||||||
tempToken.AliyunOSS.AccessKeySecret,
|
|
||||||
tempToken.AliyunOSS.SecurityToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
// 创建 CopyObject 请求
|
|
||||||
// 先用构造函数指定源和目标
|
|
||||||
var copyReq = new CopyObjectRequest(
|
|
||||||
sourceBucketName: tempToken.AliyunOSS.BucketName,
|
|
||||||
sourceKey: item.Key,
|
|
||||||
destinationBucketName: tempToken.AliyunOSS.BucketName,
|
|
||||||
destinationKey: item.Key // 覆盖到同名 Key,达到“恢复”的效果
|
|
||||||
);
|
|
||||||
|
|
||||||
// 再设置版本号
|
|
||||||
copyReq.SourceVersionId = item.VersionId;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var copyResult = _ossClient.CopyObject(copyReq);
|
|
||||||
|
//根据本地文件匹配studyInstanceUid 不匹配忽略
|
||||||
|
|
||||||
|
var localPath = Path.Combine(folder, item.RelativePath);
|
||||||
|
|
||||||
|
|
||||||
#region 读取本地dicom ,判断数据库是否存在该序列
|
#region 读取本地dicom ,判断数据库是否存在该序列
|
||||||
|
@ -1596,11 +1585,51 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
var dicomFile = await DicomFile.OpenAsync(dicomFilePath);
|
var dicomFile = await DicomFile.OpenAsync(dicomFilePath);
|
||||||
|
|
||||||
|
string sopInstanceUid = dicomFile.Dataset.GetSingleValueOrDefault(DicomTag.SOPInstanceUID, string.Empty);
|
||||||
|
|
||||||
|
|
||||||
|
if (!restoreRows.Any(t => t.SOPInstanceUID == sopInstanceUid))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
restoreCount++;
|
||||||
|
|
||||||
|
Console.WriteLine($"恢复SOPInstanceUID{sopInstanceUid},当前数量{restoreCount}");
|
||||||
|
|
||||||
await ArchiveDicomFileAsync(dicomFile.Dataset, trialId, item.SubjectId, item.SubjectVisitId);
|
await ArchiveDicomFileAsync(dicomFile.Dataset, trialId, item.SubjectId, item.SubjectVisitId);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 防止阿里云过期
|
||||||
|
if (tempToken.AliyunOSS.Expiration.AddSeconds(10) <= DateTime.Now)
|
||||||
|
{
|
||||||
|
tempToken = _oSSService.GetObjectStoreTempToken();
|
||||||
|
|
||||||
|
_ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint,
|
||||||
|
tempToken.AliyunOSS.AccessKeyId,
|
||||||
|
tempToken.AliyunOSS.AccessKeySecret,
|
||||||
|
tempToken.AliyunOSS.SecurityToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
// 创建 CopyObject 请求
|
||||||
|
// 先用构造函数指定源和目标
|
||||||
|
var copyReq = new CopyObjectRequest(
|
||||||
|
sourceBucketName: tempToken.AliyunOSS.BucketName,
|
||||||
|
sourceKey: item.Key,
|
||||||
|
destinationBucketName: tempToken.AliyunOSS.BucketName,
|
||||||
|
destinationKey: item.Key // 覆盖到同名 Key,达到“恢复”的效果
|
||||||
|
);
|
||||||
|
|
||||||
|
// 再设置版本号
|
||||||
|
copyReq.SourceVersionId = item.VersionId;
|
||||||
|
|
||||||
|
var copyResult = _ossClient.CopyObject(copyReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1643,12 +1672,21 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
public string RelativePath { get; set; }
|
public string RelativePath { get; set; }
|
||||||
|
|
||||||
|
public string SubjectCode { get; set; }
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RestoreInstanceInfo
|
||||||
|
{
|
||||||
|
public string SubjectCode { get; set; }
|
||||||
|
|
||||||
|
public string VisitName { get; set; }
|
||||||
|
|
||||||
|
public string SOPInstanceUID { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单个文件接收 归档
|
/// 单个文件接收 归档
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue