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
|
@ -156,7 +156,9 @@ public interface IOSSService
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -700,7 +702,7 @@ public class OSSService : IOSSService
|
|||
};
|
||||
await amazonS3Client.DeleteObjectAsync(deleteRequest);
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (AmazonS3Exception ex)
|
||||
{
|
||||
|
@ -711,9 +713,9 @@ public class OSSService : IOSSService
|
|||
break;
|
||||
default:
|
||||
throw new BusinessValidationFailedException("ERROR");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -1041,7 +1115,7 @@ public class OSSService : IOSSService
|
|||
BucketName = ossOptions.BucketName,
|
||||
EndPoint = ossOptions.EndPoint,
|
||||
ViewEndpoint = ossOptions.ViewEndpoint,
|
||||
PreviewEndpoint=ossOptions.PreviewEndpoint
|
||||
PreviewEndpoint = ossOptions.PreviewEndpoint
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -205,6 +205,41 @@ namespace IRaCIS.Core.Application.Service
|
|||
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]
|
||||
|
|
Loading…
Reference in New Issue