事务测试

usertest
zhangxiaofeng 3 months ago
parent f106af5af7
commit 72d0fec2ef

@ -112,5 +112,6 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <param name="taskPKId">BC变更任务主键</param> /// <param name="taskPKId">BC变更任务主键</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<DataResult<TaskTransferMsgDto>> ManualSendEmailToCustomer(long taskPKId); Task<DataResult<TaskTransferMsgDto>> ManualSendEmailToCustomer(long taskPKId);
Task<DataResult> TestDelete(long id);
} }
} }

@ -3386,5 +3386,29 @@ namespace DS.WMS.Core.TaskPlat.Method
return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId); return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId);
} }
#endregion #endregion
public async Task<DataResult> TestDelete(long id)
{
var tenantDb2 = saasDbService.GetBizDbScopeById(user.TenantId);
try
{
await tenantDb2.Ado.BeginTranAsync();
var a = tenantDb2.ContextID;
var b = await tenantDb2.Deleteable<TaskFlowLogDetail>().Where(x => x.ModuleName == id.ToString()).ExecuteCommandAsync();
//throw new Exception("fdsfsdfdsf");
await tenantDb2.Ado.CommitTranAsync();
}
catch (Exception)
{
await tenantDb2.Ado.RollbackTranAsync();
//await tenantDb2.Ado.RollbackTranAsync();
throw;
}
return DataResult.Successed("");
}
} }
} }

@ -2750,9 +2750,35 @@ namespace DS.WMS.Core.TaskPlat.Method
public async Task<DataResult> TestTaskFlow(string taskType, long taskId, int testType) public async Task<DataResult> TestTaskFlow(string taskType, long taskId, int testType)
{ {
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
var t11 = tenantDb.ContextID;
switch (testType) switch (testType)
{ {
// 事务测试
case 5:
{
try
{
await tenantDb.Ado.BeginTranAsync();
var t1 = tenantDb.ContextID;
var t2 = await tenantDb.Queryable<TaskFlowLogDetail>().Where(x => x.Id == taskId).ToListAsync();
var m = new TaskFlowLogDetail()
{
ModuleName = taskId.ToString()
};
var t3 = await tenantDb.Insertable(m).ExecuteCommandAsync();
var service = serviceProvider.GetRequiredService<ITaskManageBCService>();
await service.TestDelete(taskId);
await tenantDb.Ado.CommitTranAsync();
}
catch (Exception)
{
await tenantDb.Ado.RollbackTranAsync();
throw;
}
break;
}
// 任务编排执行测试 // 任务编排执行测试
case 1: case 1:
{ {
@ -2810,7 +2836,6 @@ namespace DS.WMS.Core.TaskPlat.Method
// 判断条件测试 // 判断条件测试
case 4: case 4:
{ {
logger.LogInformation("fdfdfd");
var condition = await tenantDb.Queryable<TaskFlowCondition>().FirstAsync(x => x.Id == 4001); var condition = await tenantDb.Queryable<TaskFlowCondition>().FirstAsync(x => x.Id == 4001);
if (condition != null) if (condition != null)
{ {

Loading…
Cancel
Save