From ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 23:38:19 +0800
Subject: [PATCH] feat(MES): 添加MES接口相关实体和DTO JS扩展文件至JSX格式并更新配置
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs | 42 +++++++++++++++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs
index 81607a6..cea1c65 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/UnitOfWorks/UnitOfWorkManage.cs
@@ -40,15 +40,17 @@
public UnitOfWork CreateUnitOfWork()
{
- UnitOfWork uow = new UnitOfWork();
- uow.Logger = _logger;
- uow.Db = _sqlSugarClient;
- uow.Tenant = (ITenant)_sqlSugarClient;
- uow.IsTran = true;
+ UnitOfWork uow = new UnitOfWork
+ {
+ Logger = _logger,
+ Db = _sqlSugarClient,
+ Tenant = _sqlSugarClient as ITenant,
+ IsTran = true
+ };
uow.Db.Open();
- uow.Tenant.BeginTran();
-
+ uow.Tenant?.BeginTran();
+
_logger.LogDebug("UnitOfWork Begin");
return uow;
}
@@ -98,6 +100,32 @@
}
}
+ private readonly SemaphoreSlim _asyncLock = new SemaphoreSlim(1, 1);
+
+ public async Task<WebResponseContent> BeginTranAsync(Func<Task<WebResponseContent>> funcAsync)
+ {
+ await _asyncLock.WaitAsync();
+ try
+ {
+ BeginTran(); // 鍋囪杩欐槸鍚屾鏂规硶锛屽惎鍔ㄤ簨鍔�
+ WebResponseContent content = await funcAsync();
+ if (content.Status)
+ CommitTran(); // 鍚屾鎻愪氦
+ else
+ RollbackTran(); // 鍚屾鍥炴粴
+ return content;
+ }
+ catch (Exception ex)
+ {
+ RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+ _asyncLock.Release();
+ }
+ }
+
public void CommitTran()
{
lock (this)
--
Gitblit v1.9.3