Esempio n. 1
0
        protected void buttonSend_Click(object sender, EventArgs e)
        {
            string        asunto    = "SOLICITUD PARA CAMBIAR CATALOGOS";
            StringBuilder contenido = new StringBuilder("EL USUARIO: ");

            contenido.Append(this.CurrentUserName);
            contenido.Append(" SOLICITÓ QUE SE ");
            if (this.checkBoxListAction.Items[0].Selected)
            {
                contenido.Append("AGREGARA EL CATÁLOGO: ");
                contenido.Append(this.textBoxCatalogo.Text);
            }
            else
            {
                if (this.checkBoxListAction.Items[1].Selected)
                {
                    contenido.Append("MODIFICARA EL CATÁLOGO: ");
                    contenido.Append(this.textBoxCatalogo.Text);
                    contenido.Append(", POR ESTE OTRO: ");
                    contenido.Append(this.textBoxNuevoCatalogo.Text);
                }
                else
                {
                    contenido.Append("AGREGARA EL CATÁLOGO: ");
                    contenido.Append(this.textBoxCatalogo.Text);
                }
            }
            contenido.Append("<br /> ENTRE AL SISTEMA EN LA SECCIÓN DE CONFIGURACIÓN Y ADMINISTRACIÓN / CATALOGOS Y SUBCATÁLOGOS PARA REALIZAR CUALQUIER CAMBIO.");
            EMailUtils.SendTextEmail("[email protected], [email protected]", asunto, contenido.ToString().ToUpper(), true);
            this.lblAddResult.Text    = "SOLICITUD ENVIADA EXITOSAMENTE";
            this.lblAddResult.Visible = true;
        }
Esempio n. 2
0
        //Members must be properties but due time issues :-) I made public.
        public static bool SendTextEmail(String sTo, String sSubject, String sContent, bool bIsbodyHTML)
        {
            bool bRes = false;

            try
            {
                bRes = EMailUtils.SendTextEmail(sTo, sSubject, sContent, bIsbodyHTML, "");
            }
            catch
            {
                //Logger.Instance.LogException(Logger.typeUserActions.SELECT, "sending email", ref ex);
            }
            return(bRes);
        }
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(myConfig.ConnectionInfo);
            SqlCommand    comm = new SqlCommand();

            try
            {
                conn.Open();
                comm.Connection  = conn;
                comm.CommandText = "insert into situacion(titulo,descripcion,userID,activa) "
                                   + " values(@titulo,@descripcion,@userID,@activa); SELECT NewID = SCOPE_IDENTITY();";
                comm.Parameters.Add("@titulo", SqlDbType.VarChar).Value   = this.txtTitulo.Text;
                comm.Parameters.Add("@descripcion", SqlDbType.Text).Value = this.txtDescripcion.Text;
                comm.Parameters.Add("@userID", SqlDbType.Int).Value       = this.UserID;
                comm.Parameters.Add("@activa", SqlDbType.Bit).Value       = this.chkActivo.Checked ? 1 : 0;
                int newID = int.Parse(comm.ExecuteScalar().ToString());
                if (newID <= 0)
                {
                    throw new Exception("No se pudo agregar la situacion nueva.");
                }
                conn.Close();
                try
                {
                    String sTo   = "[email protected],[email protected],[email protected]";
                    String sBody = "<html><body>Se agrego una nueva situacion con los siguientes datos:<br />"
                                   + "<b>Fecha: </b>" + this.lblFecha.Text.ToUpper() + "<br />"
                                   + "<b>Titulo: </b>" + this.txtTitulo.Text.ToUpper() + "<br />"
                                   + "<b>Descripcion: </b>" + this.txtDescripcion.Text.ToUpper() + "<br />"
                                   + "<b>Generado por: </b>" + this.CurrentUserName.ToUpper()
                                   + "</body></html>";
                    EMailUtils.SendTextEmail("*****@*****.**", "Se Agrego nueva situacion: " + this.txtTitulo.Text.ToUpper(), sBody, true, sTo);
                }
                catch (System.Exception ex)
                {
                    Logger.Instance.LogException(Logger.typeUserActions.SELECT, "error enviando mail de situacion", ref ex);
                }

                Response.Redirect("frmSituacionAddUpdate.aspx" + Utils.GetEncriptedQueryString("situacionID=" + newID.ToString()));
            }
            catch (System.Exception ex)
            {
                Logger.Instance.LogException(Logger.typeUserActions.INSERT, "error agregando situacion", ref ex);
            }
            finally
            {
                conn.Close();
            }
        }
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(myConfig.ConnectionInfo);
            SqlCommand    comm = new SqlCommand();

            try
            {
                conn.Open();
                comm.Connection  = conn;
                comm.CommandText = "UPDATE Situacion SET titulo = @titulo, descripcion = @descripcion, "
                                   + " activa = @activa  WHERE     (situacionID = @situacionID)";
                comm.Parameters.Add("@titulo", SqlDbType.VarChar).Value   = this.txtTitulo.Text;
                comm.Parameters.Add("@descripcion", SqlDbType.Text).Value = this.txtDescripcion.Text;
                comm.Parameters.Add("@activa", SqlDbType.Bit).Value       = this.chkActivo.Checked ? 1 : 0;
                comm.Parameters.Add("@situacionID", SqlDbType.Int).Value  = this.txtSituacionID.Text;
                int iRowsUpdated = comm.ExecuteNonQuery();
                if (iRowsUpdated != 1)
                {
                    throw new Exception("No se pudo actualizar la situacion, ID = " + this.txtSituacionID.Text);
                }
                conn.Close();
                try
                {
                    String sTo   = "[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]";
                    String sBody = "<html><body>Se Actualizo la situacion con los siguientes datos:<br />"
                                   + "<b>Fecha: </b>" + this.lblFecha.Text.ToUpper() + "<br />"
                                   + "<b>Titulo: </b>" + this.txtTitulo.Text.ToUpper() + "<br />"
                                   + "<b>Descripcion: </b>" + this.txtDescripcion.Text.ToUpper() + "<br />"
                                   + "<b>Modificado por: </b>" + this.CurrentUserName.ToUpper()
                                   + "</body></html>";
                    EMailUtils.SendTextEmail(sTo, "Se Modifico la situacion: " + this.txtTitulo.Text.ToUpper(), sBody, true);
                }
                catch (System.Exception ex)
                {
                    Logger.Instance.LogException(Logger.typeUserActions.SELECT, "error enviando mail de situacion", ref ex);
                }
            }
            catch (System.Exception ex)
            {
                Logger.Instance.LogException(Logger.typeUserActions.INSERT, "error modificando situacion", ref ex);
            }
            finally
            {
                conn.Close();
            }
        }
        protected void btnAddHistory_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(myConfig.ConnectionInfo);
            SqlCommand    comm = new SqlCommand();

            try
            {
                conn.Open();
                comm.Connection  = conn;
                comm.CommandText = "INSERT INTO situacionHistory (descripcion, userID, situacionID) VALUES (@descripcion,@userID,@situacionID)";
                comm.Parameters.Add("@descripcion", SqlDbType.Text).Value = this.txtHistoryDescripcion.Text;
                comm.Parameters.Add("@userID", SqlDbType.Int).Value       = this.UserID;
                comm.Parameters.Add("@situacionID", SqlDbType.Int).Value  = this.txtSituacionID.Text;
                int newID = comm.ExecuteNonQuery();
                if (newID <= 0)
                {
                    throw new Exception("No se pudo agregar la descripcion");
                }
                try
                {
                    String sTo   = "[email protected],[email protected],[email protected]";
                    String sBody = "<html><body>Se agrego una nueva Actualizacion de situacion con los siguientes datos:<br />"
                                   + "<b>Fecha: </b>" + Utils.Now.ToString("dd/MM/yyyy")
                                   + "<b>Descripcion: </b>" + this.txtHistoryDescripcion.Text.ToUpper() + "<br />"
                                   + "<b>Generado por: </b>" + this.CurrentUserName.ToUpper()
                                   + "</body></html>";
                    EMailUtils.SendTextEmail(sTo, "Se Actualizacion a situacion: " + this.txtTitulo.Text.ToUpper(), sBody, true);
                }
                catch (System.Exception ex)
                {
                    Logger.Instance.LogException(Logger.typeUserActions.SELECT, "error enviando mail de situacion", ref ex);
                }
                this.txtHistoryDescripcion.Text = "";
                this.gvHistory.DataBind();
            }
            catch (System.Exception ex)
            {
                Logger.Instance.LogException(Logger.typeUserActions.INSERT, "error agregando situacion", ref ex);
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 6
0
 public void LogException(typeLogMessage MessageID, typeUserActions UserAction, string description, string urlpage, ref Exception ex)
 {
     if (ex.GetType() == typeof(SqlException))
     {
         StringBuilder sb = new StringBuilder();
         try
         {
             SqlException sqlEx = (SqlException)ex;
             for (int i = 0; i < sqlEx.Errors.Count; i++)
             {
                 sb.Append("Index #");
                 sb.AppendLine(i.ToString());
                 sb.Append("Message: ");
                 sb.AppendLine(sqlEx.Errors[i].Message);
                 sb.Append("LineNumber: ");
                 sb.AppendLine(sqlEx.Errors[i].LineNumber.ToString());
                 sb.Append("Source: ");
                 sb.AppendLine(sqlEx.Errors[i].Source);
                 sb.Append("Procedure: ");
                 sb.AppendLine(sqlEx.Errors[i].Procedure);
             }
         }
         finally
         {
             description = description + sb.ToString();
         }
     }
     description = description + " logging exception: EX:" + ex.Message + " stack: " + ex.StackTrace;
     if (ex.InnerException != null)
     {
         description += " Innerexception: " + ex.InnerException.Message + " stack: " + ex.InnerException.StackTrace;
     }
     try
     {
         description += " USUARIO: " + new BasePage().UserID + " NOMBRE: " + new BasePage().CurrentUserName;
         description += "<BR />Page:" + HttpContext.Current.Request.Url.ToString();
     }
     catch {}
     try
     {
         String        sTo     = "[email protected], [email protected]";
         StringBuilder Subject = new StringBuilder();
         Subject.Append("Exception: ");
         Subject.Append(ex.Message);
         StringBuilder Body = new StringBuilder();
         Body.Append("Time: ");
         Body.Append(Utils.Now.ToString("dd/MM/yyyy HH:mm:ss"));
         Body.Append("<br />");
         Body.Append("Message: ");
         Body.Append(ex.Message);
         Body.Append("<br />");
         Body.Append("Stack: ");
         Body.Append(ex.StackTrace);
         Body.Append("<br />");
         Body.Append("FullDesc: ");
         Body.Append(description);
         Body.Append("<br />");
         Body.Append(" :-( do not let this happen again");
         try
         {
             EMailUtils.SendTextEmail(sTo, Subject.ToString(), Body.ToString(), true);
         }
         catch {}
     }
     catch {}
     this.LogMessage(MessageID, UserAction, new BasePage().UserID, description, urlpage);
 }