public void AddCtWebLogAsync(CtWebLog ctWebLog) { var ctWebLogRepository = new CtWebLogRepository(new DbFactory()); ctWebLogRepository.Insert(ctWebLog); }
/// <summary> /// [기능] : Exception 처리 및 로깅 /// [작성] : 2014-10-23 김충기 /// [수정] : /// </summary> /// <param name="filterContext"></param> protected override void OnException(ExceptionContext filterContext) { if (filterContext.ExceptionHandled) return ; string actionName = filterContext.RouteData.Values["action"].ToString(); string controllerName = filterContext.RouteData.Values["controller"].ToString(); Type controllerType = filterContext.Controller.GetType(); //통합관제 DB에 웹에러 로깅 #region Insert WebLog CtWebLog log = new CtWebLog { SrvCd = ConfigurationManager.AppSettings["ServiceCode"], SvrIp = HttpContext.Request.UserHostAddress, RmkTxt = filterContext.Exception.Message, Line = filterContext.Exception.StackTrace, LoginId = (_LogOnUser != null) ? _LogOnUser.LoginId : "", UsrAgn = HttpContext.Request.UserAgent, FileNm = string.Format("/{0}/{1}", controllerName, actionName), RegDt = DateTime.Now }; if(log.Line.Length > 500) { log.Line = log.Line.Substring(0, 500); } var ctWebLogService = new CtWebLogService(); ctWebLogService.AddCtWebLogAsync(log); #endregion string userComment = "일시적인 장애가 발생했습니다.잠시후 다시 시도해주시기 바랍니다."; //리소스에서 메시지 가져오기 if (filterContext.HttpContext.Request.IsAjaxRequest()) { filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; filterContext.Result = new JsonResult() { Data = userComment }; } else { filterContext.Result = new RedirectResult("/Error/Error500"); } filterContext.ExceptionHandled = true; }