コード例 #1
0
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            HttpSessionStateBase session = filterContext.HttpContext.Session;

            if (session.IsNewSession || Session["LoginUser"] == null)
            {
                //filterContext.Result = Json("Session Timeout", "text/html", JsonRequestBehavior.AllowGet);
                filterContext.Result = new RedirectToRouteResult(
                    new RouteValueDictionary
                {
                    { "controller", "Account" },
                    { "action", "Login" }
                });
            }

            if (Session["LoginUser"] != null && !filterContext.RequestContext.RouteData.Values["Action"].ToString().Equals("SiteMap") &&
                !filterContext.RequestContext.RouteData.Values["Action"].ToString().Contains("Grid") && !filterContext.RequestContext.RouteData.Values["Controller"].ToString().Contains("Audit") && !filterContext.RequestContext.RouteData.Values["Controller"].ToString().Contains("Home"))
            {
                var request = new Services.Requests.AuditTrail.CreateAuditUserRequest();
                request.UserId         = this.UserProfile().UserId;
                request.Login_Id       = this.UserProfile().LoginId;
                request.ControllerName = filterContext.RequestContext.RouteData.Values["Controller"].ToString();
                request.ActionName     = filterContext.RequestContext.RouteData.Values["Action"].ToString();
                request.Url            = filterContext.RequestContext.HttpContext.Request.Url.AbsolutePath;
                _auditService.CreateAuditUserRequest(request);
            }
            base.OnActionExecuted(filterContext);
            filterContext.Controller.ViewBag.BodyClass = "";
            var absolutePath = filterContext.RequestContext.HttpContext.Request.Url.AbsolutePath;

            if (!filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
            {
                var _menuService = ObjectFactory.Container.GetInstance <IMenuService>();
                var rootMenu     = _menuService.GetRootMenu(new GetRootMenuRequest {
                    AbsolutePath = absolutePath
                });
                if (!string.IsNullOrEmpty(rootMenu.RootName))
                {
                    filterContext.Controller.ViewBag.BodyClass = rootMenu.RootName.ToLower();
                }
            }
        }