|
@@ -13,6 +13,7 @@ using UAParser;
|
|
|
using System.Collections.Generic;
|
|
|
using XAct;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
+using QuzrtzJob.Factory;
|
|
|
|
|
|
namespace OASystem.API.Middlewares
|
|
|
{
|
|
@@ -25,8 +26,9 @@ namespace OASystem.API.Middlewares
|
|
|
private readonly HttpClient _httpClient;
|
|
|
private readonly IConfiguration _config;
|
|
|
private readonly SqlSugarClient _sqlSugar;
|
|
|
+ private readonly ILogger<RecordAPIOperationMiddleware> _logger;
|
|
|
|
|
|
- public RecordAPIOperationMiddleware(RequestDelegate next, IConfiguration config, HttpClient httpClient, SqlSugarClient sqlSugar)
|
|
|
+ public RecordAPIOperationMiddleware(RequestDelegate next, IConfiguration config, ILogger<RecordAPIOperationMiddleware> logger, HttpClient httpClient, SqlSugarClient sqlSugar)
|
|
|
{
|
|
|
_next = next;
|
|
|
_httpClient = httpClient;
|
|
@@ -71,7 +73,6 @@ namespace OASystem.API.Middlewares
|
|
|
//用户Id处理
|
|
|
if (userId < 1)
|
|
|
{
|
|
|
-
|
|
|
if (apiLogAttribute.OperationEnum == OperationEnum.Login)
|
|
|
{
|
|
|
var number = requestBodyJson?["number"].ToString();
|
|
@@ -136,16 +137,21 @@ namespace OASystem.API.Middlewares
|
|
|
// id > 0 修改
|
|
|
if (id > 0) updateBefData = await TableInfoToJson(apiLogAttribute.TableName, id);
|
|
|
}
|
|
|
- string remoteIp = context.Connection.RemoteIpAddress?.ToString(),
|
|
|
+ string remoteIp = string.Empty,
|
|
|
location = string.Empty;
|
|
|
|
|
|
// 检查请求头中的X-Forwarded-For,以获取真实的客户端IP地址
|
|
|
if (context.Request.Headers.ContainsKey("X-Forwarded-For"))
|
|
|
{
|
|
|
remoteIp = context.Request.Headers["X-Forwarded-For"].ToString().Split(',', StringSplitOptions.RemoveEmptyEntries)[0];
|
|
|
+ _logger.LogInformation($"IP:{remoteIp}");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ remoteIp = context.Connection.RemoteIpAddress?.ToString();
|
|
|
}
|
|
|
|
|
|
- (remoteIp, location) = await GetIpInfo();
|
|
|
+ //(remoteIp, location) = await GetIpInfo();
|
|
|
//remoteIp = await GetExternalIp();
|
|
|
//location = await GetIpLocation(remoteIp);
|
|
|
|