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(); }