代码修改

IRC_NewDev
he 2023-08-17 10:36:08 +08:00
parent a2c35ba83d
commit 6b6ab9e406
4 changed files with 51 additions and 0 deletions

View File

@ -227,6 +227,8 @@ namespace IRaCIS.Core.API.Controllers
_repository = repository;
}
[HttpPost, Route("Study/PreArchiveStudy")]
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
public async Task<IResponseOutput> PreArchiveStudy(PreArchiveStudyCommand preArchiveStudyCommand,
@ -262,6 +264,12 @@ namespace IRaCIS.Core.API.Controllers
}
//public string UploadOOSTest(string filePath, string route)
//{
//}
/// <summary>Dicom 归档</summary>
[HttpPost, Route("Study/ArchiveStudy")]
[DisableFormValueModelBinding]

View File

@ -11,6 +11,13 @@
"Hangfire": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Hangfire_IRaCIS;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
},
"AliyunOSS": {
"endpoint": "https://zyypacs-code.oss-cn-shanghai.aliyuncs.com",
"accessKeyId": "mpXG7Nu6zTpsDrI1",
"accessKeySecret": "yNINcEb099SkNfF6vYKaoP8TZNI3xZ",
"bucketName": "zyypacs-code"
},
"BasicSystemConfig": {
"OpenUserComplexPassword": false,

View File

@ -1,10 +1,12 @@

using Aliyun.OSS;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json.Linq;
using System.Configuration;
using System.Text.RegularExpressions;
namespace IRaCIS.Core.Application.Helper;
@ -12,6 +14,39 @@ namespace IRaCIS.Core.Application.Helper;
public static class FileStoreHelper
{
public static string UploadOOS(string filePath,string route)
{
var endpoint = ConfigurationManager.AppSettings["AliyunOSS:endpoint"];
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1杭州为例Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
// 阿里云账号AccessKey拥有所有API的访问权限风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维请登录RAM控制台创建RAM用户。
var accessKeyId = ConfigurationManager.AppSettings["AliyunOSS:accessKeyId"];
var accessKeySecret = ConfigurationManager.AppSettings["AliyunOSS:accessKeySecret"];
// 填写Bucket名称例如examplebucket。
var bucketName = ConfigurationManager.AppSettings["AliyunOSS:bucketName"];
// 填写Object完整路径完整路径中不能包含Bucket名称例如exampledir/exampleobject.txt。
var fileNameList = filePath.Split(',').ToList();
var fileName = fileNameList[fileNameList.Count() - 1];
var objectName = route+ fileName;
// 填写本地文件完整路径例如D:\\localpath\\examplefile.txt。如果未指定本地路径则默认从示例程序所属项目对应本地路径中上传文件。
var localFilename = filePath;
// 创建OSSClient实例。
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try
{
// 上传文件。
var result = client.PutObject(bucketName, objectName, localFilename);
return result.ETag;
}
catch (Exception ex)
{
throw new BusinessValidationFailedException("上传异常!");
}
}
//处理文件名 压缩包,或者目录类的 会带上相对路径
public static (string TrustedFileNameForFileStorage, string RealName) GetStoreFileName(string fileName,bool isChangeToPdfFormat=false)

View File

@ -63,6 +63,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
<PackageReference Include="AutoMapper.Collection.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="BeetleX.BNR" Version="1.0.1" />
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.1.0" />