Exemplo n.º 1
0
        public bool EnviarCorreoRecuperacion(String toMail, String id)
        {
            String titulo = "Recuperación de contraseña para el sistema Premios Institucionales del Tec de Monterrey";
            String cuerpo = "";

            cuerpo = File.ReadAllText(Server.MapPath("~/Values/CorreoRecuperaPassword.txt"));
            cuerpo = cuerpo.Replace(StringValues.ContenidoCorreoFecha, DateTime.Today.ToShortDateString());
            cuerpo = cuerpo.Replace(StringValues.ContenidoCorreoId, id);

            switch (id[0])
            {
            case 'c':
                cuerpo = cuerpo.Replace(StringValues.ContenidoCorreoNombre,
                                        InformacionPersonalCandidatoService.GetCandidatoByCorreo(toMail).Nombre);
                break;

            case 'j':
                cuerpo = cuerpo.Replace(StringValues.ContenidoCorreoNombre,
                                        InformacionPersonalJuezService.GetJuezByCorreo(toMail).Nombre);
                break;

            case 'a':
                cuerpo = cuerpo.Replace(StringValues.ContenidoCorreoNombre,
                                        "Administrador");
                break;
            }

            return(EnviarCorreo(toMail, titulo, cuerpo));
        }
Exemplo n.º 2
0
        public static String GetID(String email)
        {
            String id        = null;
            var    candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(email);

            if (candidato == null)
            {
                var juez = InformacionPersonalJuezService.GetJuezByCorreo(email);
                if (juez == null)
                {
                    var admin = InformacionPersonalAdministradorService.GetAdministradorByCorreo(email);
                    if (admin != null)
                    {
                        id = "a" + admin.cveAdministrador;
                    }
                }
                else
                {
                    id = "j" + juez.cveJuez;
                }
            }
            else
            {
                id = "c" + candidato.cveCandidato;
            }
            return(id);
        }
Exemplo n.º 3
0
        private string htmlProfilePicture()
        {
            // Consigo el correo de la sesion actual
            string rolSesionActual = Session[StringValues.RolSesion].ToString();

            // Foto de perfil por default, si el usuario tiene otra, se reemplazara
            string htmlContent = "<img src=\"/Resources/img/default-pp.jpg\" class=\"avatar img-circle nav-profilepic\"/>";

            // Verifico si la sesion pertenece a la tipo de cuenta candidato
            if (Session[StringValues.RolSesion] != null)
            {
                if (Session[StringValues.RolSesion].ToString() == StringValues.RolCandidato)
                {
                    // Consigo al candidato segun su correo
                    var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(Session[StringValues.CorreoSesion].ToString());
                    htmlContent = "<a href=\"/Webforms/Candidato/InformacionPersonalCandidato.aspx\" title=\"" + candidato.Nombre + " " + candidato.Apellido + "\">" + htmlContent + "</a>";

                    // Si tiene imagen de perfil la muestro
                    if (candidato.NombreImagen != null && candidato.NombreImagen.Length > 0)
                    {
                        if (File.Exists(Server.MapPath("~/ProfilePictures/" + candidato.NombreImagen)))
                        {
                            htmlContent = "<a href=\"/Webforms/Candidato/InformacionPersonalCandidato.aspx\" title=\"" + candidato.Nombre + " " + candidato.Apellido + "\">" +
                                          "<img src=\"/ProfilePictures/" + candidato.NombreImagen + "\" class=\"avatar img-circle nav-profilepic\"/>" +
                                          "</a>";
                        }
                    }
                }

                // Verifico si la sesion pertenece a la tipo de cuenta juez
                else if (Session[StringValues.RolSesion].ToString() == StringValues.RolJuez)
                {
                    // Consigo al juez segun su correo
                    var juez = InformacionPersonalJuezService.GetJuezByCorreo(Session[StringValues.CorreoSesion].ToString());
                    htmlContent = "<a href=\"/webforms/Juez/InformacionPersonalJuez.aspx\" title=\"" + juez.Nombre + " " + juez.Apellido + "\">" + htmlContent + "</a>";

                    // Si tiene imagen de perfil la muestro
                    if (juez.NombreImagen != null && juez.NombreImagen.Length > 0)
                    {
                        if (File.Exists(Server.MapPath("~/ProfilePictures/" + juez.NombreImagen)))
                        {
                            htmlContent = "<a href=\"/webforms/Juez/InformacionPersonalJuez.aspx\" title=\"" + juez.Nombre + " " + juez.Apellido + "\">" +
                                          "<img src=\"/ProfilePictures/" + juez.NombreImagen + "\" class=\"avatar img-circle nav-profilepic\"/>" +
                                          "</a>";
                        }
                    }
                }

                // Verifico si la sesion pertenece a la tipo de cuenta administrador
                else if (Session[StringValues.RolSesion].ToString() == StringValues.RolAdmin)
                {
                    // administrador no utiliza imagen de perfil
                    htmlContent = "";
                }
            }

            // Retorno el string que contiene el html de la imagen de perfil
            return(htmlContent);
        }
Exemplo n.º 4
0
        protected void EnviarBtn_Click(object sender, EventArgs e)
        {
            var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(Session[StringValues.CorreoSesion].ToString());

            if (candidato != null)
            {
                if (!candidato.FechaPrivacidadDatos.HasValue)
                {
                    candidato.FechaPrivacidadDatos = DateTime.Today.Date;
                }
                InformacionPersonalCandidatoService.UpdateCandidato(candidato);
            }
        }
Exemplo n.º 5
0
        protected void ActualizarContrasena()
        {
            var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(Session[StringValues.CorreoSesion].ToString());

            string sCurrentPassword = currentPwdTextBox.Text;

            if (candidato.Password == sha256(sCurrentPassword))
            {
                if (newPwdTextBox.Text == confirmNewPwdTextBox.Text)
                {
                    Regex regexNumero = new Regex(@".*\d.*");
                    Regex regexLetra  = new Regex(@".*[a-zA-z].*");
                    Match matchNumero = regexNumero.Match(newPwdTextBox.Text);
                    Match matchLetra  = regexLetra.Match(newPwdTextBox.Text);

                    if (newPwdTextBox.Text.Length >= 6 && matchNumero.Success && matchLetra.Success)
                    {
                        if (candidato != null)
                        {
                            candidato.Password = sha256(newPwdTextBox.Text);
                            if (InformacionPersonalCandidatoService.UpdateCandidato(candidato))
                            {
                                MasterPage.ShowMessage("Aviso", "Contraseña cambiada con éxito.");
                            }
                            else
                            {
                                MostrarCampos();
                            }
                        }
                    }
                    else
                    {
                        MasterPage.ShowMessage("Error", "Contraseña debe ser de al menos 6 caracteres y debe contener al menos un número y una letra.");
                    }
                }
                else
                {
                    MasterPage.ShowMessage("Error", "Contraseñas no coinciden.");
                }
            }
            else
            {
                MasterPage.ShowMessage("Error", "Contraseña actual incorrecta.");
            }

            ResetFields();
        }
Exemplo n.º 6
0
        private void MostrarCampos()
        {
            var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(Session[StringValues.CorreoSesion].ToString());

            NombresTextBox.Text      = candidato.Nombre;
            ApellidosTextBox.Text    = candidato.Apellido;
            DomicilioTextBox.Text    = candidato.Direccion;
            RFCTextBox.Text          = candidato.RFC;
            TelefonoTextBox.Text     = candidato.Telefono;
            NacionalidadTextBox.Text = candidato.Nacionalidad;

            if (candidato.NombreImagen != null && candidato.NombreImagen.Length > 0)
            {
                if (File.Exists(Server.MapPath("~/ProfilePictures/" + candidato.NombreImagen)))
                {
                    avatarImage.Attributes.Add("style", "background-image: url(/ProfilePictures/" + candidato.NombreImagen + ")");
                }
            }
        }
Exemplo n.º 7
0
        protected void ActualizarDatosGenerales()
        {
            var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(Session[StringValues.CorreoSesion].ToString());

            if (candidato != null)
            {
                candidato.Nombre       = NombresTextBox.Text;
                candidato.Apellido     = ApellidosTextBox.Text;
                candidato.Direccion    = DomicilioTextBox.Text.ToString();
                candidato.Nacionalidad = NacionalidadTextBox.Text.ToString();
                candidato.RFC          = RFCTextBox.Text.ToString();
                candidato.Telefono     = TelefonoTextBox.Text.ToString();

                if (!candidato.FechaPrivacidadDatos.HasValue)
                {
                    candidato.FechaPrivacidadDatos = DateTime.Today.Date;
                }

                if (!InformacionPersonalCandidatoService.UpdateCandidato(candidato))
                {
                    MostrarCampos();
                }
            }
        }
Exemplo n.º 8
0
        private void LoadMessage()
        {
            var correo    = Session[StringValues.CorreoSesion].ToString();
            var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(correo);

            if (candidato == null)
            {
                Response.Redirect("~/WebForms/Login.aspx", false);
            }

            if (candidato.Nombre != null && candidato.Nombre.Length > 0)
            {
                litBienvenidoUsuario.Text = "<h1> Bienvenido, " + candidato.Nombre + " </h1>";
            }
            else
            {
                litBienvenidoUsuario.Text = "<h1> Bienvenido </h1>";
            }

            if (!candidato.FechaPrivacidadDatos.HasValue)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Pop", "openModal();", true);
            }
        }
Exemplo n.º 9
0
        protected bool Upload(object sender, EventArgs e)
        {
            if (FileUploadImage.HasFile)
            {
                // Get filename
                string fileName = Path.GetFileName(FileUploadImage.PostedFile.FileName);

                // Get string image format (png, jpg, etc)
                var    startIndex    = fileName.LastIndexOf(".");
                var    endIndex      = fileName.Length - startIndex;
                string sFormat       = fileName.Substring(startIndex, endIndex).ToLower();
                string sNombreImagen = Guid.NewGuid().ToString() + sFormat;

                // Formatos Validos
                List <String> supportedFormats = new List <String>()
                {
                    ".png",
                    ".bmp",
                    ".jpg",
                    ".jpeg"
                };

                if (supportedFormats.Contains(sFormat))
                {
                    using (var image = Image.FromStream(FileUploadImage.PostedFile.InputStream, true, true))
                    {
                        using (var newImage = ScaleImage(image, 364, 364))
                        {
                            // Get logged in candidate
                            var candidato = InformacionPersonalCandidatoService.GetCandidatoByCorreo(Session[StringValues.CorreoSesion].ToString());
                            if (candidato.NombreImagen != null && candidato.NombreImagen.Length > 0)
                            {
                                // Delete previous image...
                                File.Delete(Server.MapPath("~/ProfilePictures/") + candidato.NombreImagen);
                            }

                            // Upload image to server
                            switch (sFormat)
                            {
                            case ".png":
                                newImage.Save(Server.MapPath("~/ProfilePictures/") + sNombreImagen, ImageFormat.Png);
                                break;

                            case ".bmp":
                                newImage.Save(Server.MapPath("~/ProfilePictures/") + sNombreImagen, ImageFormat.Bmp);
                                break;

                            default:
                                newImage.Save(Server.MapPath("~/ProfilePictures/") + sNombreImagen, ImageFormat.Jpeg);
                                break;
                            }

                            // Update data in database
                            InformacionPersonalCandidatoService.CambiaImagen(null, Session[StringValues.CorreoSesion].ToString(), sNombreImagen);
                            return(true);
                        }
                    }
                }
                else
                {
                    MasterPage.ShowMessage("Error", "La imagen proporcionada debe estar en formato PNG , JPG o BMP.");
                    return(false);
                }
            }
            return(true);
        }