|
|
@@ -7,17 +7,14 @@ using Masuit.MyBlogs.Core.Models.DTO;
|
|
|
using Masuit.MyBlogs.Core.Models.Enum;
|
|
|
using Masuit.MyBlogs.Core.Models.ViewModel;
|
|
|
using Masuit.Tools.Core.Net;
|
|
|
-using Masuit.Tools.Logging;
|
|
|
using Masuit.Tools.Security;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
|
using Microsoft.EntityFrameworkCore.Internal;
|
|
|
using System;
|
|
|
-using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using System.Net;
|
|
|
-using System.Web;
|
|
|
|
|
|
namespace Masuit.MyBlogs.Core.Controllers
|
|
|
{
|
|
|
@@ -25,7 +22,7 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
/// 基本父控制器
|
|
|
/// </summary>
|
|
|
[ApiExplorerSettings(IgnoreApi = true), ServiceFilter(typeof(FirewallAttribute))]
|
|
|
- public class BaseController : Controller, IResultFilter
|
|
|
+ public class BaseController : Controller
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// UserInfoService
|
|
|
@@ -53,7 +50,6 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
|
|
|
public IMapper Mapper { get; set; }
|
|
|
public MapperConfiguration MapperConfig { get; set; }
|
|
|
- public Stopwatch Stopwatch { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 响应数据
|
|
|
@@ -80,7 +76,6 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
/// <param name="filterContext">有关当前请求和操作的信息。</param>
|
|
|
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
|
{
|
|
|
- Stopwatch.Start();
|
|
|
base.OnActionExecuting(filterContext);
|
|
|
var user = filterContext.HttpContext.Session.Get<UserInfoDto>(SessionKey.UserInfo);
|
|
|
#if DEBUG
|
|
|
@@ -145,35 +140,12 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- #region 准备页面数据模型
|
|
|
-
|
|
|
ViewBag.menus = MenuService.GetQueryFromCache<MenuDto>(m => m.Status == Status.Available).OrderBy(m => m.Sort).ToList(); //菜单
|
|
|
var model = new PageFootViewModel //页脚
|
|
|
{
|
|
|
Links = LinksService.GetQueryFromCache<LinksDto>(l => l.Status == Status.Available).OrderByDescending(l => l.Recommend).ThenByDescending(l => l.Weight).ThenByDescending(l => new Random().Next()).Take(40).ToList()
|
|
|
};
|
|
|
ViewBag.Footer = model;
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- ViewData["ActionElapsed"] = Stopwatch.ElapsedMilliseconds + "ms";
|
|
|
- if (Stopwatch.ElapsedMilliseconds > 5000)
|
|
|
- {
|
|
|
- LogManager.Debug($"请求路径:{Request.Scheme}://{Request.Host}{HttpUtility.UrlDecode(Request.Path)}执行耗时{Stopwatch.ElapsedMilliseconds}ms");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>Called after the action result executes.</summary>
|
|
|
- /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext" />.</param>
|
|
|
- public void OnResultExecuted(ResultExecutedContext context)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>Called before the action result executes.</summary>
|
|
|
- /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext" />.</param>
|
|
|
- public void OnResultExecuting(ResultExecutingContext context)
|
|
|
- {
|
|
|
- Stopwatch.Restart();
|
|
|
}
|
|
|
}
|
|
|
}
|