Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
81ecd9ff7f
|
@ -157,6 +157,8 @@ public interface IOSSService
|
||||||
public ObjectStoreDTO GetObjectStoreTempToken();
|
public ObjectStoreDTO GetObjectStoreTempToken();
|
||||||
|
|
||||||
public Task MoveObject(string sourcePath, string destPath, bool overwrite = true);
|
public Task MoveObject(string sourcePath, string destPath, bool overwrite = true);
|
||||||
|
|
||||||
|
public Task<long> GetObjectSizeAsync(string sourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -998,6 +1000,78 @@ public class OSSService : IOSSService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<long> GetObjectSizeAsync(string sourcePath)
|
||||||
|
{
|
||||||
|
GetObjectStoreTempToken();
|
||||||
|
|
||||||
|
var objectkey = sourcePath.Trim('/');
|
||||||
|
|
||||||
|
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
|
||||||
|
{
|
||||||
|
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
|
||||||
|
|
||||||
|
var _ossClient = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
|
||||||
|
|
||||||
|
var metadata = _ossClient.GetObjectMetadata(aliConfig.BucketName, objectkey);
|
||||||
|
|
||||||
|
long fileSize = metadata.ContentLength; // 文件大小(字节)
|
||||||
|
|
||||||
|
return fileSize;
|
||||||
|
}
|
||||||
|
else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO")
|
||||||
|
{
|
||||||
|
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||||
|
|
||||||
|
|
||||||
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
|
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
var stat = await minioClient.StatObjectAsync(new Minio.DataModel.Args.StatObjectArgs()
|
||||||
|
.WithBucket(minIOConfig.BucketName)
|
||||||
|
.WithObject(objectkey));
|
||||||
|
|
||||||
|
return stat.Size; // 文件大小(字节)
|
||||||
|
}
|
||||||
|
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
|
||||||
|
{
|
||||||
|
|
||||||
|
var awsConfig = ObjectStoreServiceOptions.AWS;
|
||||||
|
|
||||||
|
|
||||||
|
// 提供awsAccessKeyId和awsSecretAccessKey构造凭证
|
||||||
|
var credentials = new SessionAWSCredentials(AWSTempToken.AccessKeyId, AWSTempToken.SecretAccessKey, AWSTempToken.SessionToken);
|
||||||
|
|
||||||
|
//提供awsEndPoint(域名)进行访问配置
|
||||||
|
var clientConfig = new AmazonS3Config
|
||||||
|
{
|
||||||
|
RegionEndpoint = RegionEndpoint.USEast1,
|
||||||
|
UseHttp = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
var request = new Amazon.S3.Model.GetObjectMetadataRequest
|
||||||
|
{
|
||||||
|
BucketName = awsConfig.BucketName,
|
||||||
|
Key = objectkey
|
||||||
|
};
|
||||||
|
|
||||||
|
var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
|
||||||
|
|
||||||
|
var response = await amazonS3Client.GetObjectMetadataAsync(request);
|
||||||
|
|
||||||
|
long fileSize = response.ContentLength; // 文件大小(字节)
|
||||||
|
|
||||||
|
return fileSize;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException("未定义的存储介质类型");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ObjectStoreDTO GetObjectStoreTempToken()
|
public ObjectStoreDTO GetObjectStoreTempToken()
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,6 +205,41 @@ namespace IRaCIS.Core.Application.Service
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 非dicom 临床数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_identityUserRepository"></param>
|
||||||
|
/// <param name="_trialUserRoleRepository"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<IResponseOutput> DealTialFileSie([FromServices] IOSSService _oSSService,
|
||||||
|
[FromServices] IRepository<NoneDicomStudyFile> _noneDicomStudyFileRepository,
|
||||||
|
[FromServices] IRepository<ReadingClinicalDataPDF> _readingClinicalDataPDFRepository)
|
||||||
|
{
|
||||||
|
var noneDicomList = _noneDicomStudyFileRepository.Where(t => t.FileSize == 0 || t.FileSize == null).Select(t => new { t.Path, t.Id }).ToList();
|
||||||
|
|
||||||
|
foreach (var item in noneDicomList)
|
||||||
|
{
|
||||||
|
var fileSize = await _oSSService.GetObjectSizeAsync(item.Path);
|
||||||
|
|
||||||
|
await _noneDicomStudyFileRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new NoneDicomStudyFile() { FileSize = fileSize });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var clinicalDataPDFList = _readingClinicalDataPDFRepository.Where(t => t.Size == 0).Select(t => new { t.Path, t.Id }).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in clinicalDataPDFList)
|
||||||
|
{
|
||||||
|
var fileSize = await _oSSService.GetObjectSizeAsync(item.Path);
|
||||||
|
|
||||||
|
await _readingClinicalDataPDFRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new ReadingClinicalDataPDF() { Size = (int)fileSize });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[LowerCamelCaseJson]
|
[LowerCamelCaseJson]
|
||||||
|
|
Loading…
Reference in New Issue