1、优化全局异常企业微信通知模板内容 2、新增企业微信发送测试接口
This commit is contained in:
parent
1e00abd6f9
commit
dac5f8bbef
@ -49,6 +49,22 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
"如果觉得项目有用,打赏作者喝杯咖啡作为奖励\n☛☛http://www.izhaorui.cn/doc/support.html\n");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 企业消息测试
|
||||
/// </summary>
|
||||
/// <param name="msg">要发送的消息</param>
|
||||
/// <param name="toUser">要发送的人@all所有,xxx单独发送对个人</param>
|
||||
/// <returns></returns>
|
||||
[Route("/sendMsg")]
|
||||
[HttpGet]
|
||||
[Log(Title = "企业消息测试")]
|
||||
public IActionResult SendMsg(string msg, string toUser = "")
|
||||
{
|
||||
throw new Exception("ddddd");
|
||||
WxNoticeHelper.SendMsg("消息测试", msg, toUser, WxNoticeHelper.MsgType.markdown);
|
||||
return SUCCESS(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
|
||||
@ -67,7 +67,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
List<DbTableInfo> list = _CodeGeneraterService.GetAllTables(dbName, tableName, pager);
|
||||
var page = new PagedInfo<DbTableInfo>
|
||||
{
|
||||
TotalPage = pager.TotalPage,
|
||||
TotalNum = pager.TotalNum,
|
||||
PageSize = pager.PageSize,
|
||||
PageIndex = pager.PageNum,
|
||||
|
||||
@ -23,7 +23,7 @@ namespace ZR.Admin.WebApi.Middleware
|
||||
private readonly RequestDelegate next;
|
||||
private readonly ISysOperLogService SysOperLogService;
|
||||
|
||||
static readonly Logger Logger = LogManager.GetCurrentClassLogger();//声明NLog变量
|
||||
static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public GlobalExceptionMiddleware(RequestDelegate next, ISysOperLogService sysOperLog)
|
||||
{
|
||||
@ -88,7 +88,7 @@ namespace ZR.Admin.WebApi.Middleware
|
||||
RequestMethod = context.Request.Method,
|
||||
JsonResult = responseResult,
|
||||
ErrorMsg = string.IsNullOrEmpty(error) ? msg : error,
|
||||
OperName = context.User.Identity.Name,
|
||||
OperName = HttpContextExtension.GetName(context),
|
||||
OperLocation = ip_info.Province + " " + ip_info.City,
|
||||
OperTime = DateTime.Now
|
||||
};
|
||||
@ -113,23 +113,18 @@ namespace ZR.Admin.WebApi.Middleware
|
||||
ei.Properties["status"] = 1;//走正常返回都是通过走GlobalExceptionFilter不通过
|
||||
ei.Properties["jsonResult"] = responseResult;
|
||||
ei.Properties["requestParam"] = sysOperLog.OperParam;
|
||||
ei.Properties["user"] = HttpContextExtension.GetName(context);
|
||||
ei.Properties["user"] = sysOperLog.OperName;
|
||||
|
||||
Logger.Log(ei);
|
||||
context.Response.ContentType = "text/json;charset=utf-8";
|
||||
await context.Response.WriteAsync(responseResult, System.Text.Encoding.UTF8);
|
||||
|
||||
// 获取异常堆栈
|
||||
var traceFrame = new StackTrace(true)?.GetFrame(0);
|
||||
// 获取出错的文件名
|
||||
var exceptionFileName = traceFrame?.GetFileName();
|
||||
// 获取出错的行号
|
||||
var exceptionFileLineNumber = traceFrame?.GetFileLineNumber();
|
||||
string errorMsg = $"用户名:{sysOperLog.OperName}\n" +
|
||||
$"错误信息:{sysOperLog.ErrorMsg}\n"+
|
||||
$"错误行号:{exceptionFileLineNumber}\n" +
|
||||
$"{traceFrame}#{exceptionFileName}";
|
||||
WxNoticeHelper.SendMsg("系统出错", errorMsg);
|
||||
|
||||
string errorMsg = $"> 操作人:{sysOperLog.OperName} {sysOperLog.OperLocation}" +
|
||||
$"\n> 操作模块:{sysOperLog.Title}" +
|
||||
$"\n> 操作地址:{sysOperLog.OperUrl}" +
|
||||
$"\n> 错误信息:{msg}\n\n> {error}";
|
||||
|
||||
WxNoticeHelper.SendMsg("系统出错", errorMsg, "", WxNoticeHelper.MsgType.markdown);
|
||||
SysOperLogService.InsertOperlog(sysOperLog);
|
||||
}
|
||||
|
||||
|
||||
@ -14,20 +14,6 @@
|
||||
/// 总记录数
|
||||
/// </summary>
|
||||
public int TotalNum { get; set; }
|
||||
/// <summary>
|
||||
/// 总页码
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
public int TotalPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return TotalNum > 0 ? TotalNum % PageSize == 0 ? TotalNum / PageSize : TotalNum / PageSize + 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user