From cef9036ecc6b140ff00c3891f1e1bb0d6422d3c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E4=BF=8A=E6=9D=B0?= Date: Sun, 9 Mar 2025 09:49:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=82=E5=B8=B8=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E3=80=81=E6=B6=88=E6=81=AF=E6=97=A5=E5=BF=97=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=97=A5=E5=BF=97=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.NET/Admin.NET.Core/EventBus/AppEventSubscriber.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/EventBus/AppEventSubscriber.cs b/Admin.NET/Admin.NET.Core/EventBus/AppEventSubscriber.cs index 9c14ff87..ed38eb2a 100644 --- a/Admin.NET/Admin.NET.Core/EventBus/AppEventSubscriber.cs +++ b/Admin.NET/Admin.NET.Core/EventBus/AppEventSubscriber.cs @@ -26,7 +26,9 @@ public class AppEventSubscriber : IEventSubscriber, ISingleton, IDisposable [EventSubscribe(CommonConst.AddExLog)] public async Task CreateExLog(EventHandlerExecutingContext context) { - var db = _serviceScope.ServiceProvider.GetRequiredService(); + var db = SqlSugarSetup.ITenant.IsAnyConnection(SqlSugarConst.LogConfigId) + ? SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.LogConfigId) + : SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); await db.CopyNew().Insertable(context.GetPayload()).ExecuteCommandAsync(); } @@ -38,7 +40,9 @@ public class AppEventSubscriber : IEventSubscriber, ISingleton, IDisposable [EventSubscribe(CommonConst.AddMsgLog)] public async Task CreateMsgLog(EventHandlerExecutingContext context) { - var db = _serviceScope.ServiceProvider.GetRequiredService(); + var db = SqlSugarSetup.ITenant.IsAnyConnection(SqlSugarConst.LogConfigId) + ? SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.LogConfigId) + : SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); await db.CopyNew().Insertable(context.GetPayload()).ExecuteCommandAsync(); }