예제 #1
0
 public void OnException(ExceptionContext filterContext)
 {
     try
     {
         if (filterContext.Exception is SemPermissaoException)
         {
             filterContext.Result = new RedirectToRouteResult(
                 new RouteValueDictionary
             {
                 { "controller", "Dashboards" },
                 { "action", "SemPermissao" }
             });
             filterContext.ExceptionHandled = true;
         }
         if (!Directory.Exists(FILE_EXCEPTION_LOG))
         {
             Directory.CreateDirectory(FILE_EXCEPTION_LOG);
         }
         ExceptionToFile(filterContext.Exception);
     }
     catch (Exception e)
     {
         var db  = new ProjetoBaseContext();
         Log log = new Log();
         log.nomeUsuario = "EXCEPTION_SISTEMA";
         log.menu        = "EXCEPTION_DURANTE_EXCEPTION";
         log.opcao       = e.Message + "<br><br>" + e.StackTrace;
         log.data        = DateTime.Now;
         db.Log.Add(log);
         db.SaveChanges();
     }
 }
예제 #2
0
파일: SessionHelper.cs 프로젝트: lrs96/abbc
 /// <summary>
 /// Retorna o contexto do entity framework, trabalhando com um context por request
 /// </summary>
 /// <returns></returns>
 public static ProjetoBaseContext getProjetoBaseContext()
 {
     if (HttpContext.Current.Session["ProjetoBaseContext"] == null)
     {
         var db = new ProjetoBaseContext();
         HttpContext.Current.Session["ProjetoBaseContext"] = db;
     }
     return((ProjetoBaseContext)HttpContext.Current.Session["ProjetoBaseContext"]);
 }