예제 #1
0
 public virtual void EmailException(ExceptionLog exLog)
 {
     try
     {
         string smtp_server = PerFormsConfig.EmailConfig.EmailServerAddress;
         MailMessage msg = new MailMessage(PerFormsConfig.EmailConfig.OnExceptionEmailFrom, PerFormsConfig.EmailConfig.OnExceptionEmailTo, PerFormsConfig.AppConfig.ApplicationName + " Exception [" + exLog.Guid + "]", "<pre>Type: " + exLog.Type + "\r\n\r\nMessage: " + exLog.Message + "\r\n\r\nStackTrace: " + exLog.StackTrace + "\r\n\r\nInner Message: " + exLog.InnerMessage + "\r\n\r\nInner StackTrace: " + exLog.InnerStackTrace + "</pre>");
         msg.IsBodyHtml = true;
         SmtpClient mail = new SmtpClient(smtp_server);
         mail.Send(msg);
     }
     catch { }
 }
예제 #2
0
        /// <summary>
        /// <para>Log an exception in the database.</para>
        /// </summary>
        public virtual ExceptionLog LogException(Exception exp, ActionLog actionLog)
        {
            string guid = Guid.NewGuid().ToString("N");
            ExceptionLog exLog = new ExceptionLog
            {
                Message = exp.Message,
                StackTrace = exp.StackTrace,
                Type = exp.GetType().ToString(),
                Guid = guid,
                ActionLog = actionLog
            };

            if (exp.InnerException != null)
            {
                exLog.InnerMessage = exp.InnerException.Message;
                exLog.InnerStackTrace = exp.InnerException.StackTrace;
            }

            new BaseRepository().Insert<ExceptionLog>(exLog);
            return exLog;
        }