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.
105 lines
3.5 KiB
C#
105 lines
3.5 KiB
C#
using System.Reflection;
|
|
using DotNetCore.CAP.Internal;
|
|
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 LanguageExt.ClassInstances;
|
|
using Mapster;
|
|
using Masuit.Tools.Strings;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Owin.BuilderProperties;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
using NPOI.Util;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using SqlSugar;
|
|
using SqlSugar.IOC;
|
|
using Xunit;
|
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
|
|
|
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(CodeDataRule));//指定更新特定实体
|
|
}
|
|
|
|
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(TaskBaseAllocation));
|
|
|
|
// SQL更新
|
|
string sql = @"UPDATE `task_flow_module` SET `CreatedBusinessStatusCode` = 'TIJIAO' WHERE `Id` = 30001";
|
|
tenantDb.Ado.ExecuteCommand(sql);
|
|
|
|
|
|
// DROP TRIGGER `tr_task_no`;
|
|
}
|
|
|
|
Assert.True(true);
|
|
}
|
|
} |