Example #1
0
        public void SaveTechLog(string methodName, LevelError levelError, Exception ex)
        {
            TechLogInformation tech = new TechLogInformation
            {
                Exception = ex.GetType().Name,
                AssemblyName = this.GetType().Assembly.GetName().Name,
                ClassName = this.GetType().Name,
                ComputerIP = this.Context.Request.UserHostAddress,
                ExceptionDetail = ex.Message + " // " + ex.StackTrace,
                StartDateTime = DateTime.Now,
                MethodName = methodName,
                Level = (short)levelError
            };

            new Auxiliar().SaveTechLogInformation(tech);
        }
Example #2
0
        private void sendEmail(TechLogInformation tech)
        {
            try
            {
                Auxiliar aux = new Auxiliar();
                SMTPEmail email = new SMTPEmail();

                email.From = aux.GetGeneralParameterValue("EmailSMTP Error");
                email.To = aux.GetGeneralParameterValue("ToEmail Error");
                email.subject = aux.GetGeneralParameterValue("Subject Error");
                email.SMTPClient = aux.GetGeneralParameterValue("SMTP Client");
                email.SMTPPort = Convert.ToInt32(aux.GetGeneralParameterValue("SMTP Port"));

                email.Message = "<label style=\"display:block;\">Página: " + tech.ClassName + "</label></br></br><label style=\"display:block;\">Método: " + tech.MethodName + "</label></br></br><label style=\"display:block;\">Excepción: " + tech.ExceptionDetail + "</label></br></br>";

                MailMessage Email;

                Email = new MailMessage(email.From, email.To, email.subject, email.Message);

                SmtpClient smtpMail = new SmtpClient(email.SMTPClient);
                Email.IsBodyHtml = true;

                smtpMail.UseDefaultCredentials = false;
                smtpMail.Host = email.SMTPClient;
                smtpMail.Port = email.SMTPPort;
                smtpMail.EnableSsl = false;
                smtpMail.Credentials = new NetworkCredential(aux.GetGeneralParameterValue("EmailSMTP Error"), aux.GetGeneralParameterValue("PasswordSMTP Error"));//[email protected] // Aep123456

                smtpMail.Send(Email);
            }
            catch (Exception ex)
            {
                //log the error
                SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex);
                throw ex;
            }
        }