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.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(); saasService = _serviceProvider.GetRequiredService(); } /// /// 主库初始化单表 /// [Fact] public void MasterInitTableTest() { StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 db.CodeFirst.InitTables(typeof(CodeCarrier)); Assert.True(true); } /// /// 初始化单表 多表 /// 注意 海运出口 SeaExport 得手动数据库更新 /// [Fact] public void InitSaasTableTestByCjy() { var tenantList = db.Queryable().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(BusinessSequence));//指定更新特定实体 } Assert.True(true); } /// /// 初始化单表 /// [Fact] public void InitTableTestZXF() { var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 var ass = Assembly.Load("DS.WMS.Core"); var types = ass.GetTypes().Where(it => it.FullName?.Contains("DS.WMS.Core.TaskPlat.Entity") == true).ToArray(); tenantDb.CodeFirst.InitTables(types); //tenantDb.CodeFirst.InitTables(typeof(TaskFlowLog)); //tenantDb.CodeFirst.InitTables(typeof(TaskFlowLogDetail)); Assert.True(true); } }