Ejemplo n.º 1
0
        public void SaveTechLog(string methodName, LevelError levelError, Exception ex)
        {
            var 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 Admin().SaveTechLogInformation(tech);
        }
Ejemplo n.º 2
0
Archivo: Admin.cs Proyecto: GeraElem/VS
 public bool SaveTechLogInformation(TechLogInformation info)
 {
     using (var context = new QuirofanoEntities())
     {
         context.TechLogInformation.AddObject(info);
         return context.SaveChanges() > 0;
     }
 }
Ejemplo n.º 3
0
        private void sendEmail(TechLogInformation tech)
        {
            try
            {
                var aux = new Admin();
                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 = new MailMessage(email.From, email.To, email.subject, email.Message);

                var 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;
            }
        }