Exemplo n.º 1
0
    /* public static void mostrarError(string metodo, Exception ex, System.Web.UI.Page pagina, Boolean tieneMasterPage = true)
     * {
     *  //Muestra un mensaje de error en un modal de bootstrap
     *  //Autor:AR
     *  //
     *  string _msg = string.Empty;
     *  string mensaje = string.Empty;
     *  try
     *  {
     *     if (ex.InnerException != null)
     *     {
     *        mensaje = ex.InnerException.ToString();
     *     }
     *     else
     *     {
     *        mensaje = ex.Message;
     *     }
     *
     *     //EscribeMensaje en Log de errores
     *     escribeError(ex.Message, ex.TargetSite.Name, ex.StackTrace);
     *     mensaje = metodo + "-" + mensaje;
     *     mensaje = mensaje.Replace("'", " ");
     *     mensaje.Replace(Convert.ToChar(34).ToString(), "");
     *     mensaje = mensaje.Normalize();
     *     System.Web.UI.MasterPage master = new siteMaster();
     *     System.Web.UI.HtmlControls.HtmlGenericControl divDialog = new System.Web.UI.HtmlControls.HtmlGenericControl();
     *     //Si tiene masterPage busca el div en dicha masterpage
     *     if (tieneMasterPage)
     *     {
     *        divDialog = pagina.Master.FindControl("divDialog") as System.Web.UI.HtmlControls.HtmlGenericControl;
     *     }
     *     else
     *     {
     *        divDialog = pagina.FindControl("divDialog") as System.Web.UI.HtmlControls.HtmlGenericControl;
     *     }
     *     divDialog.InnerHtml = mensaje;
     *     pagina.ClientScript.RegisterStartupScript(master.GetType(), "MostrarError", "$('#errorModal').modal();", true);
     *  }
     *  catch (Exception exep)
     *  {
     *     escribeError(exep.Message, "clsHelper.cs", exep.StackTrace);
     *  }
     *
     * }*/


    public static void mensaje(string texto, System.Web.UI.Page pagina, tipoMensaje tipo = tipoMensaje.informacion, Boolean remplazarComillas = true)
    {
        /*Muestra una alerta con alertify
         * Autor:AR*/
        string script = string.Empty;
        string html   = string.Empty;

        try
        {
            script = " alertify.set('notifier','position', 'top-right');";
            if (remplazarComillas)
            {
                texto = texto.Replace("'", "  ").Replace(Convert.ToChar(34).ToString(), "  ");
            }
            texto = texto.Normalize();

            switch (tipo)
            {
            case tipoMensaje.informacion:
                script += " alertify.success('" + texto + "');";
                break;

            case tipoMensaje.alerta:
                script += " alertify.error('" + texto + "');";
                break;

            case tipoMensaje.err:
                html    = "<p style=" + Convert.ToChar(34).ToString() + "width:100%;overflow:scroll;" + Convert.ToChar(34).ToString() + ">" + texto + "</p>";
                script  = " alertify.alert().set('label','Aceptar'); ";
                script += "alertify.alert('Error','" + html + "');";
                break;

            case tipoMensaje.msgbx:
                html    = "<p style=" + Convert.ToChar(34).ToString() + "width:100%;overflow:scroll;" + Convert.ToChar(34).ToString() + ">" + texto + "</p>";
                script  = " alertify.alert().set('label','Aceptar'); ";
                script += "alertify.alert('','" + html + "');";
                break;
            }
            pagina.ClientScript.RegisterStartupScript(pagina.GetType(), "alertify", script, true);
        }
        catch (Exception ex)
        {
            escribeError(ex.Message, "clsHelper.cs", ex.StackTrace);
        }
    }
Exemplo n.º 2
0
 /// <summary>
 /// Crea un paquete para enviar de un tipo en específico
 /// </summary>
 /// <param name="tipo">Tipo de paquete</param>
 public PaqueteEdit(tipoMensaje tipo)
 {
     this.tipo = tipo;
 }