public override void OnException(ExceptionContext filterContext)
        {
            db_CenSystemEntities db = new db_CenSystemEntities();

            try
            {
                Exception ex = filterContext.Exception;
                db.ErrorLog.Add(new ErrorLog
                {
                    error_content        = ex.ToString(),
                    error_createdatetime = DateTime.Now,
                });
                db.SaveChanges();
                filterContext.HttpContext.Response.Redirect("/Logoin/Index");
                filterContext.ExceptionHandled = true;
                base.OnException(filterContext);
            }
            catch (Exception err)
            {
                db.ErrorLog.Add(new ErrorLog
                {
                    error_content        = err.ToString(),
                    error_createdatetime = DateTime.Now,
                });
                filterContext.HttpContext.Response.Redirect("/Logoin/Index");
            }
        }
Exemplo n.º 2
0
        public ActionResult GetReadArticle(Article d)
        {
            db_CenSystemEntities db = new db_CenSystemEntities();
            var datalist            = db.Article.FirstOrDefault(c => c.article_Id == d.article_Id);

            if (datalist == null)
            {
                return(Json(new { code = 1, msg = "Error" }, JsonRequestBehavior.AllowGet));
            }
            datalist.article_PV += 1;
            db.SaveChanges();
            return(Json(new { code = 0, data = list.ConditionQuery(d) }, JsonRequestBehavior.AllowGet));
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            //获取 控制器名 与 动作名
            log_OperAction      = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + "/" + filterContext.ActionDescriptor.ActionName;
            log_OperatelogAdmin = (int)filterContext.HttpContext.Session["AdminId"];
            var Request             = filterContext.RequestContext.HttpContext;//获取控制器传入的参数
            db_CenSystemEntities db = new db_CenSystemEntities();

            db.Operatelog.Add(new Operatelog
            {
                log_CreatDataTime   = this.log_CreatDataTime,
                log_Content         = this.log_Content,
                log_OperAction      = this.log_OperAction,
                log_OperatelogAdmin = this.log_OperatelogAdmin,
                log_OperStatus      = this.log_OperStatus
            });
            db.SaveChanges();
            //执行完action后跳转后执行
        }