bug处理
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.EventBus;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.EventHandler;
|
||||
@@ -44,18 +42,7 @@ public class LogEventSubscriber : IEventSubscriber, ISingleton
|
||||
_sqlSugarClient.ChangeDatabase(log.ConnectionConfig.ConfigId);
|
||||
}
|
||||
|
||||
string pattern = @"^[0-9]*$";
|
||||
var db = _sqlSugarClient.CopyNew();
|
||||
if (!string.IsNullOrEmpty(log.Entity.ModuleId) && new Regex(pattern).IsMatch(log.Entity.ModuleId))
|
||||
{
|
||||
var module = await db.Queryable<VisualDevEntity>().Where(x => x.Id == log.Entity.ModuleId).FirstAsync();
|
||||
if (module != null)
|
||||
{
|
||||
log.Entity.ModuleName = module.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
await db.Insertable(log.Entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
|
||||
await _sqlSugarClient.CopyNew().Insertable(log.Entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -107,77 +107,7 @@ public class RequestActionFilter : IAsyncActionFilter
|
||||
ModuleName = module.ModuleName,
|
||||
Json = string.Format("{0}应用【{1}】【{2}】", module.Action, args, result?.ToJsonString())
|
||||
}));
|
||||
}else if (actionName == "JNPF.VisualDev.VisualDevModelDataService.Create")
|
||||
{
|
||||
var args = context.ActionArguments.ToJsonString();
|
||||
var result = (actionContext.Result as JsonResult)?.Value;
|
||||
|
||||
string moduleId = httpRequest.Path.Value.Substring(httpRequest.Path.Value.LastIndexOf("/")+1);
|
||||
|
||||
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", options, new SysLogEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
UserId = userId,
|
||||
UserName = userName,
|
||||
Category = 3,
|
||||
IPAddress = NetHelper.Ip,
|
||||
RequestURL = httpRequest.Path,
|
||||
RequestDuration = (int)sw.ElapsedMilliseconds,
|
||||
RequestMethod = "新增",
|
||||
PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue),
|
||||
CreatorTime = DateTime.Now,
|
||||
ModuleName = moduleId,
|
||||
ModuleId = moduleId,
|
||||
Json = string.Format("{0}应用【{1}】【{2}】", "新增", args, result?.ToJsonString())
|
||||
}));
|
||||
}else if (actionName == "JNPF.VisualDev.VisualDevModelDataService.Update")
|
||||
{
|
||||
var args = context.ActionArguments.ToJsonString();
|
||||
var result = (actionContext.Result as JsonResult)?.Value;
|
||||
string[] arr = httpRequest.Path.Value.Split("/");
|
||||
string moduleId = arr[arr.Length - 2];
|
||||
|
||||
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", options, new SysLogEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
UserId = userId,
|
||||
UserName = userName,
|
||||
Category = 3,
|
||||
IPAddress = NetHelper.Ip,
|
||||
RequestURL = httpRequest.Path,
|
||||
RequestDuration = (int)sw.ElapsedMilliseconds,
|
||||
RequestMethod = "编辑",
|
||||
PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue),
|
||||
CreatorTime = DateTime.Now,
|
||||
ModuleName = moduleId,
|
||||
ModuleId = moduleId,
|
||||
Json = string.Format("{0}应用【{1}】【{2}】", "编辑", args, result?.ToJsonString())
|
||||
}));
|
||||
}else if (actionName == "JNPF.VisualDev.VisualDevModelDataService.Delete")
|
||||
{
|
||||
var args = context.ActionArguments.ToJsonString();
|
||||
var result = (actionContext.Result as JsonResult)?.Value;
|
||||
string[] arr = httpRequest.Path.Value.Split("/");
|
||||
string moduleId = arr[arr.Length - 2];
|
||||
|
||||
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", options, new SysLogEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
UserId = userId,
|
||||
UserName = userName,
|
||||
Category = 3,
|
||||
IPAddress = NetHelper.Ip,
|
||||
RequestURL = httpRequest.Path,
|
||||
RequestDuration = (int)sw.ElapsedMilliseconds,
|
||||
RequestMethod = "删除",
|
||||
PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue),
|
||||
CreatorTime = DateTime.Now,
|
||||
ModuleName = moduleId,
|
||||
ModuleId = moduleId,
|
||||
Json = string.Format("{0}应用【{1}】【{2}】", "删除", args, result?.ToJsonString())
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user