You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.1 KiB
C#
90 lines
3.1 KiB
C#
using System.Reflection;
|
|
using DS.Module.Core;
|
|
using DS.Module.Core.Extensions;
|
|
using DS.Module.SqlSugar;
|
|
using DS.WMS.Core.Check.Entity;
|
|
using DS.WMS.Core.Code.Entity;
|
|
using DS.WMS.Core.Info.Entity;
|
|
using DS.WMS.Core.Map.Entity;
|
|
using DS.WMS.Core.Op.Entity;
|
|
using DS.WMS.Core.Op.Entity.BookingSlot;
|
|
using DS.WMS.Core.Sys.Entity;
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
using Mapster;
|
|
using Masuit.Tools.Strings;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Owin.BuilderProperties;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using SqlSugar;
|
|
using SqlSugar.IOC;
|
|
using Xunit;
|
|
|
|
namespace Ds.WMS.Test;
|
|
|
|
public class SaasDBUpdateTest
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly SqlSugarScope db;
|
|
private readonly ISaasDbService saasService;
|
|
public SaasDBUpdateTest(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 主库初始化单表
|
|
/// </summary>
|
|
[Fact]
|
|
public void MasterInitTableTest()
|
|
{
|
|
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
|
|
db.CodeFirst.InitTables(typeof(CodeCarrier));
|
|
Assert.True(true);
|
|
}
|
|
/// <summary>
|
|
/// 初始化单表 多表
|
|
/// 注意 海运出口 SeaExport 得手动数据库更新
|
|
/// </summary>
|
|
[Fact]
|
|
public void InitSaasTableTestByCjy()
|
|
{
|
|
var tenantList = db.Queryable<DS.Module.SqlSugar.SysTenantLink>().ToList();
|
|
var ass = Assembly.Load("DS.WMS.Core");
|
|
var types = ass.GetTypes().Where(it => it.FullName?.Contains("DS.WMS.Core.Map.Entity") == true).ToArray();
|
|
foreach (var item in tenantList)
|
|
{
|
|
var tenantDb = saasService.GetBizDbScopeById(item.TenantId).CopyNew();
|
|
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci"; //较高版本支持
|
|
//tenantDb.CodeFirst.InitTables(types); //指定表空间下的实体
|
|
tenantDb.CodeFirst.InitTables(typeof(BusinessYard));//指定更新特定实体
|
|
}
|
|
|
|
Assert.True(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化单表 多表
|
|
/// 注意 海运出口 SeaExport 得手动数据库更新
|
|
/// </summary>
|
|
[Fact]
|
|
public void InitSaasTableTestByZxf()
|
|
{
|
|
var tenantList = db.Queryable<DS.Module.SqlSugar.SysTenantLink>().ToList();
|
|
var ass = Assembly.Load("DS.WMS.Core");
|
|
//var types = ass.GetTypes().Where(it => it.FullName?.Contains("DS.WMS.Core.TaskPlat.Entity") == true).ToArray();
|
|
foreach (var item in tenantList)
|
|
{
|
|
var tenantDb = saasService.GetBizDbScopeById(item.TenantId).CopyNew();
|
|
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci"; //较高版本支持
|
|
//tenantDb.CodeFirst.InitTables(types); //指定表空间下的实体
|
|
tenantDb.CodeFirst.InitTables(typeof(BookingContractNoManageLane));//指定更新特定实体
|
|
}
|
|
|
|
Assert.True(true);
|
|
}
|
|
} |