コード例 #1
0
        public static void RecordException(Exception ex, string extraMSGContext)
        {
            Guid   userID = new Guid();
            string email  = "anonymous";

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                email  = HttpContext.Current.User.Identity.Name;
                userID = new CFController().GetClimberProfileByEmail(email).ID;
            }

            MailMan.SendAppExceptionEmail(ex, email);

            LogExceptionEvent exceptionEvent = exDA.Insert(
                new LogExceptionEvent
            {
                Browser           = HttpContext.Current.Request.Browser.Browser.ToString() + " v" + HttpContext.Current.Request.Browser.Version.ToString(),
                ExceptionDateTime = DateTime.Now,
                InnerMessage      = extraMSGContext + ", " + ex.Message,
                IP         = HttpContext.Current.Request.UserHostName.Take(15), //Try see if the length of this field is causing the truncated exception
                Url        = HttpContext.Current.Request.Url.ToString(),
                UserEmail  = email,
                Reviewed   = false,
                UserID     = userID,
                StackTrace = ex.StackTrace.ToString()
            });

            string messsage = String.Format("{0} experienced exception[{1}]: {2}", UsersEmail, exceptionEvent.ID, ex.Message).Take(254);

            da.Insert(new LogEvent(userID, CFLogEventType.Exception, messsage.Take(254)));
        }