Просмотр исходного кода

升级Furionv3.5.0 优化事件总线

zuohuaijun 3 лет назад
Родитель
Сommit
5e4519cd93

+ 4 - 4
Admin.NET/Admin.NET.Core/Admin.NET.Core.csproj

@@ -20,10 +20,10 @@
 
   <ItemGroup>
     <PackageReference Include="Caching.CSRedis" Version="3.8.2" />
-    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="3.4.2" />
-    <PackageReference Include="Furion.Extras.Logging.Serilog" Version="3.4.2" />
-    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="3.4.2" />
-    <PackageReference Include="Furion.Pure" Version="3.4.2" />
+    <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="3.5.0" />
+    <PackageReference Include="Furion.Extras.Logging.Serilog" Version="3.5.0" />
+    <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="3.5.0" />
+    <PackageReference Include="Furion.Pure" Version="3.5.0" />
     <PackageReference Include="Magicodes.IE.Excel" Version="2.6.4" />
     <PackageReference Include="MySql.Data" Version="8.0.29" />
     <PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.1.5" />

+ 23 - 0
Admin.NET/Admin.NET.Core/Admin.NET.Core.xml

@@ -2686,6 +2686,29 @@
             <param name="entity"></param>
             <returns></returns>
         </member>
+        <member name="M:Admin.NET.Core.RepositoryExtension.AS``1(SqlSugar.ISugarQueryable{``0})">
+            <summary>
+            多库查询扩展
+            </summary>
+            <param name="queryable"></param>
+            <returns> </returns>
+        </member>
+        <member name="M:Admin.NET.Core.RepositoryExtension.AS``2(SqlSugar.ISugarQueryable{``0,``1})">
+            <summary>
+            多库查询扩展
+            </summary>
+            <typeparam name="T"></typeparam>
+            <typeparam name="T2"></typeparam>
+            <param name="queryable"></param>
+            <returns></returns>
+        </member>
+        <member name="M:Admin.NET.Core.RepositoryExtension.GetTableInfo``1">
+            <summary>
+            根据实体类型获取表信息
+            </summary>
+            <typeparam name="T"></typeparam>
+            <returns></returns>
+        </member>
         <member name="T:Admin.NET.Core.LogExceptionHandler">
             <summary>
             全局异常处理

+ 12 - 13
Admin.NET/Admin.NET.Core/Filter/LogExceptionHandler.cs

@@ -16,19 +16,18 @@ public class LogExceptionHandler : IGlobalExceptionHandler, ISingleton
 
     public async Task OnExceptionAsync(ExceptionContext context)
     {
-        await _eventPublisher.PublishAsync(new ChannelEventSource("Add:ExLog",
-            new SysLogEx
-            {
-                ClassName = context.Exception.TargetSite.DeclaringType?.FullName,
-                MethodName = context.Exception.TargetSite.Name,
-                ExceptionName = context.Exception.Message,
-                ExceptionMsg = context.Exception.Message,
-                ExceptionSource = context.Exception.Source,
-                StackTrace = context.Exception.StackTrace,
-                ParamsObj = context.Exception.TargetSite.GetParameters().ToString(),
-                UserName = context.HttpContext.User?.FindFirst(ClaimConst.UserName)?.Value,
-                RealName = context.HttpContext.User?.FindFirst(ClaimConst.RealName)?.Value
-            }));
+        await _eventPublisher.PublishAsync("Add:ExLog", new SysLogEx
+        {
+            ClassName = context.Exception.TargetSite.DeclaringType?.FullName,
+            MethodName = context.Exception.TargetSite.Name,
+            ExceptionName = context.Exception.Message,
+            ExceptionMsg = context.Exception.Message,
+            ExceptionSource = context.Exception.Source,
+            StackTrace = context.Exception.StackTrace,
+            ParamsObj = context.Exception.TargetSite.GetParameters().ToString(),
+            UserName = context.HttpContext.User?.FindFirst(ClaimConst.UserName)?.Value,
+            RealName = context.HttpContext.User?.FindFirst(ClaimConst.RealName)?.Value
+        });
 
         // 写日志文件
         Log.Error(context.Exception.ToString());

+ 17 - 18
Admin.NET/Admin.NET.Core/Filter/RequestActionFilter.cs

@@ -43,23 +43,22 @@ public class RequestActionFilter : IAsyncActionFilter
         var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
         var ip = httpContext.GetRemoteIpAddressToIPv4();
 
-        await _eventPublisher.PublishAsync(new ChannelEventSource("Add:OpLog",
-            new SysLogOp
-            {
-                Success = isRequestSucceed ? YesNoEnum.Y : YesNoEnum.N,
-                Ip = ip,
-                Location = httpRequest.GetRequestUrlAddress(),
-                Browser = clientInfo?.UA.Family + clientInfo?.UA.Major,
-                Os = clientInfo?.OS.Family + clientInfo?.OS.Major,
-                Url = httpRequest.Path,
-                ClassName = context.Controller.ToString(),
-                MethodName = actionDescriptor?.ActionName,
-                ReqMethod = httpRequest.Method,
-                Param = context.ActionArguments.Count < 1 ? string.Empty : JSON.Serialize(context.ActionArguments),
-                Result = actionContext.Result?.GetType() == typeof(JsonResult) ? JSON.Serialize(actionContext.Result) : string.Empty,
-                ElapsedTime = sw.ElapsedMilliseconds,
-                UserName = httpContext.User?.FindFirstValue(ClaimConst.UserName),
-                RealName = httpContext.User?.FindFirstValue(ClaimConst.RealName)
-            }));
+        await _eventPublisher.PublishAsync("Add:OpLog", new SysLogOp
+        {
+            Success = isRequestSucceed ? YesNoEnum.Y : YesNoEnum.N,
+            Ip = ip,
+            Location = httpRequest.GetRequestUrlAddress(),
+            Browser = clientInfo?.UA.Family + clientInfo?.UA.Major,
+            Os = clientInfo?.OS.Family + clientInfo?.OS.Major,
+            Url = httpRequest.Path,
+            ClassName = context.Controller.ToString(),
+            MethodName = actionDescriptor?.ActionName,
+            ReqMethod = httpRequest.Method,
+            Param = context.ActionArguments.Count < 1 ? string.Empty : JSON.Serialize(context.ActionArguments),
+            Result = actionContext.Result?.GetType() == typeof(JsonResult) ? JSON.Serialize(actionContext.Result) : string.Empty,
+            ElapsedTime = sw.ElapsedMilliseconds,
+            UserName = httpContext.User?.FindFirstValue(ClaimConst.UserName),
+            RealName = httpContext.User?.FindFirstValue(ClaimConst.RealName)
+        });
     }
 }

+ 20 - 22
Admin.NET/Admin.NET.Core/Service/Auth/AuthService.cs

@@ -99,18 +99,17 @@ public class AuthService : IDynamicApiController, ITransient
 
         // 增加登录日志
         var client = Parser.GetDefault().Parse(_httpContextAccessor.HttpContext.Request.Headers["User-Agent"]);
-        await _eventPublisher.PublishAsync(new ChannelEventSource("Add:VisLog",
-            new SysLogVis
-            {
-                Success = YesNoEnum.Y,
-                Message = "登录",
-                Ip = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(),
-                Browser = client.UA.Family + client.UA.Major,
-                Os = client.OS.Family + client.OS.Major,
-                VisType = LoginTypeEnum.Login,
-                UserName = user.UserName,
-                RealName = user.RealName
-            }));
+        await _eventPublisher.PublishAsync("Add:VisLog", new SysLogVis
+        {
+            Success = YesNoEnum.Y,
+            Message = "登录",
+            Ip = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(),
+            Browser = client.UA.Family + client.UA.Major,
+            Os = client.OS.Family + client.OS.Major,
+            VisType = LoginTypeEnum.Login,
+            UserName = user.UserName,
+            RealName = user.RealName
+        });
 
         return new LoginUserInfoOutput
         {
@@ -153,15 +152,14 @@ public class AuthService : IDynamicApiController, ITransient
         //_httpContextAccessor.HttpContext.Response.Headers["access-token"] = "invalid token";
 
         // 增加退出日志
-        await _eventPublisher.PublishAsync(new ChannelEventSource("Add:VisLog",
-            new SysLogVis
-            {
-                Success = YesNoEnum.Y,
-                Message = "退出",
-                VisType = LoginTypeEnum.Logout,
-                Ip = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(),
-                UserName = user.UserName,
-                RealName = user.RealName
-            }));
+        await _eventPublisher.PublishAsync("Add:VisLog", new SysLogVis
+        {
+            Success = YesNoEnum.Y,
+            Message = "退出",
+            VisType = LoginTypeEnum.Logout,
+            Ip = _httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(),
+            UserName = user.UserName,
+            RealName = user.RealName
+        });
     }
 }