diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs
index 7a472d690..261594914 100644
--- a/IRaCIS.Core.Application/Helper/OSSService.cs
+++ b/IRaCIS.Core.Application/Helper/OSSService.cs
@@ -345,7 +345,7 @@ namespace IRaCIS.Core.Application.Helper
public async Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath)
{
-
+
ossRelativePath = ossRelativePath.TrimStart('/');
try
{
@@ -406,7 +406,7 @@ namespace IRaCIS.Core.Application.Helper
};
- await (await amazonS3Client.GetObjectAsync(getObjectArgs)).WriteResponseStreamToFileAsync(localFilePath, true, CancellationToken.None);
+ await (await amazonS3Client.GetObjectAsync(getObjectArgs)).WriteResponseStreamToFileAsync(localFilePath, true, CancellationToken.None);
}
@@ -478,18 +478,26 @@ namespace IRaCIS.Core.Application.Helper
}
else if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS")
{
- var minIOConfig = ObjectStoreServiceOptions.AWS;
+ var awsConfig = ObjectStoreServiceOptions.AWS;
- var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
- .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
- .Build();
- var args = new PresignedGetObjectArgs()
- .WithBucket(minIOConfig.BucketName)
- .WithObject(ossRelativePath)
- .WithExpiry(3600);
+ // 提供awsAccessKeyId和awsSecretAccessKey构造凭证
+ var credentials = new BasicAWSCredentials(awsConfig.AccessKeyId, awsConfig.SecretAccessKey);
- var presignedUrl = await minioClient.PresignedGetObjectAsync(args);
+ //提供awsEndPoint(域名)进行访问配置
+ var clientConfig = new AmazonS3Config
+ {
+ ServiceURL = awsConfig.EndPoint
+ };
+
+ var amazonS3Client = new AmazonS3Client(credentials, clientConfig);
+
+ var presignedUrl = await amazonS3Client.GetPreSignedURLAsync(new GetPreSignedUrlRequest()
+ {
+ BucketName = awsConfig.BucketName,
+ Key = ossRelativePath,
+ Expires = DateTime.UtcNow.AddMinutes(120)
+ });
Uri uri = new Uri(presignedUrl);
@@ -643,7 +651,7 @@ namespace IRaCIS.Core.Application.Helper
var deleteObjectsResponse = await amazonS3Client.DeleteObjectsAsync(deleteObjectsRequest);
}
-
+
}
else
diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
index 512ce8727..5d8890377 100644
--- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
+++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
@@ -20,6 +20,9 @@
Always
+
+ Always
+
Always
diff --git a/IRaCIS.Core.Test/Program.cs b/IRaCIS.Core.Test/Program.cs
index 41a6fe3cd..688860674 100644
--- a/IRaCIS.Core.Test/Program.cs
+++ b/IRaCIS.Core.Test/Program.cs
@@ -1,7 +1,6 @@
using Fluid;
using IRaCIS.Core.Infra.EFCore;
-using IRaCIS.Core.Test.Template;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System;
@@ -48,6 +47,7 @@ partial class Program
#endregion
+
#region 直接通过上下文拿到实体信息
@@ -68,11 +68,11 @@ partial class Program
string dataType = property.ClrType.Name;
bool isNullable = property.IsNullable;
- Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}");
+
}
}
- #endregion
+ #endregion
// 要生成的表名数组
var tableNames = new List { "Product"/*, "Order"*/ };
@@ -154,4 +154,39 @@ partial class Program
public DateTime DateTimeNow = DateTime.Now;
}
+
+
+ #region 核对code first 暂时屏蔽
+
+ public void CheckCodeFirst()
+ {
+ var contextOptions = new DbContextOptionsBuilder().UseSqlServer(@"Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true").Options;
+
+ using var dbContext = new IRaCISDBContext(contextOptions);
+
+ var dbModel = dbContext.Model;
+
+ foreach (var entityType in dbModel.GetEntityTypes())
+ {
+ string tableName = entityType.GetTableName();
+ Console.WriteLine($"Table: {tableName}");
+
+ foreach (var property in entityType.GetProperties())
+ {
+ string columnName = property.GetColumnName();
+ string dataType = property.ClrType.Name;
+ bool isNullable = property.IsNullable;
+ int? maxLength = property.GetMaxLength(); // 获取最大长度
+ string columnType = property.GetColumnType(); // 获取数据库中的列类型
+ bool isKey = property.IsKey(); // 判断是否为主键
+ bool isIndex = property.IsIndex(); // 判断是否是索引
+ object defaultValue = property.GetDefaultValue(); // 获取默认值
+ bool isGenerated = property.ValueGenerated != Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never; // 判断是否是自动生成的值
+
+ Console.WriteLine($" Column: {columnName}, Data Type: {dataType}, Is Nullable: {isNullable}, Max Length: {maxLength}, Column Type: {columnType}, Is Key: {isKey}, Is Index: {isIndex}, Default Value: {defaultValue}, Is Generated: {isGenerated}");
+ }
+ }
+ }
+
+ #endregion
}
diff --git a/IRaCIS.Core.Test/Template/EntityViewModel.liquid b/IRaCIS.Core.Test/Template/EntityViewModel.liquid
new file mode 100644
index 000000000..3afa57c50
--- /dev/null
+++ b/IRaCIS.Core.Test/Template/EntityViewModel.liquid
@@ -0,0 +1,20 @@
+
+//--------------------------------------------------------------------
+// 此代码由T4模板自动生成 byzhouhang 20210918
+// 生成时间 {{DateTimeNow}}
+// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
+//--------------------------------------------------------------------
+using System;
+using IRaCIS.Core.Domain.Share;
+using System.Collections.Generic;
+namespace IRaCIS.Core.Application.ViewModel
+{
+
+ public class {{ entityName }}ViewModel
+ {
+ {% for property in properties %}
+ public {{ property.type }} {{ property.name }} { get; set; }
+ {% endfor %}
+ }
+}
+
diff --git a/IRaCIS.Core.Test/YourDbContext.cs b/IRaCIS.Core.Test/YourDbContext.cs
deleted file mode 100644
index 09593fc25..000000000
--- a/IRaCIS.Core.Test/YourDbContext.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace IRaCIS.Core.Test.Template
-{
- class YourDbContext : DbContext
- {
-
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- optionsBuilder.UseSqlServer("Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true");
- }
-
- }
-}