using System.Reflection; using DS.Module.Core; using DS.Module.Core.Extensions; using DS.Module.SqlSugar; using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Sys.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 SaasTest { private readonly IServiceProvider _serviceProvider; private readonly SqlSugarScope db; private readonly ISaasDbService saasService; public SaasTest(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = (SqlSugarScope)_serviceProvider.GetRequiredService(); saasService = _serviceProvider.GetRequiredService(); } [Fact] public void SaasTest1() { //Type[] types = Assembly // .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe // .GetTypes().Where(it => it.FullName.Contains("DS.WMS.Core.Code.Entity.") || it.FullName.Contains("DS.WMS.Core.Info.Entity.") || it.FullName.Contains("DS.WMS.Core.Op.Entity.") // || it.FullName.Contains("DS.WMS.Core.Fee.Entity.") || it.FullName.Contains("DS.WMS.Core.Map.Entity."))//命名空间过滤,当然你也可以写其他条件过滤 // .ToArray(); Type[] types = Assembly .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe .GetTypes().Where(it => it.FullName.Contains("DS.WMS.Core.Map.Entity.")|| it.FullName.Contains("DS.WMS.Core.Code.Entity."))//命名空间过滤,当然你也可以写其他条件过滤 .ToArray(); var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); // var temp = tenantDb.CodeFirst.GetDifferenceTables(types); // var diffString= tenantDb.CodeFirst.GetDifferenceTables(types).ToDiffString(); StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 types = types.Where(it => it.Name!="BusinessFeeStatus").ToArray(); tenantDb.CodeFirst.InitTables(types); // //初始化数库 // tenantDb.DbMaintenance.CreateDatabase(); // // tenantDb.CodeFirst.InitTables(typeof(CodeCountry)); Assert.True(true); } /// /// 初始化单表 /// [Fact] public void InitTableTest() { var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 tenantDb.CodeFirst.InitTables(typeof(SeaExport)); Assert.True(true); } ///// ///// 初始化海运出口视图 ///// //[Fact] //public void InitSeaExportViewTest() //{ // var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); // StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 // tenantDb.CodeFirst.InitTables(typeof(SeaExport)); // Assert.True(true); //} [Fact] public void SaasFeeTest() { Type[] types = Assembly .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe .GetTypes().Where(it => it.FullName.Contains("DS.WMS.Core.Check.Entity"))//命名空间过滤,当然你也可以写其他条件过滤 .ToArray(); var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持 tenantDb.CodeFirst.InitTables(types); Assert.True(true); } [Fact] public void ClientBatchEdit() { var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); var info = tenantDb.Queryable().Filter(null, true).Where(x => x.Id == 1772138307266940928).First(); var temp = new ClientTemp { Address = "4", Name = "4", }; var dic = temp.GetPropertiesArray(); info = temp.Adapt(info); tenantDb.Updateable(info).UpdateColumns(dic).ExecuteCommand(); Assert.True(true); } [Fact] public void CopyColumnTest() { var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); var columns = "noBill,enName,copyNoBill"; var list = columns.Split(","); var list1 = new List(); foreach (var item in list) { list1.Add(item.ToUpperCamelCase()); } Console.WriteLine(list1[0]); Assert.True(true); } public class ClientTemp { /// /// Desc:客户中文名称或描述信息 /// public string Description { get; set; } /// /// Desc:客户英文简称 /// public string Name { get; set; } /// /// Desc:客户英文全称 /// public string EnFullName { get; set; } /// /// Desc:通讯地址 /// public string Address { get; set; } } }