protected void ModificarAplicacion(object sender, EventArgs e) { try { var juez = InformacionPersonalJuezService.GetJuezByCorreo(Session[StringValues.CorreoSesion].ToString()); var eval = EvaluacionService.GetEvaluacionByAplicacionAndJuez(juez.Correo, cveAplicacion); if (eval != null) { try { short evaluacion = 0; short.TryParse(aplicationEvaluationNumber.Text, out evaluacion); EvaluacionService.ActualizaEvaluacion(eval.cveEvaluacion, evaluacion); cveMensaje = 1; } catch (Exception Ex2) { Console.WriteLine("Catched Exception: " + Ex2.Message + Environment.NewLine); cveMensaje = 2; } } } catch (Exception Ex) { Console.WriteLine("Catched Exception: " + Ex.Message + Environment.NewLine); cveMensaje = 0; } Response.Redirect("EvaluaAplicacion.aspx" + "?m=" + cveMensaje + "&a=" + cveAplicacion, false); }
protected void EvaluarAplicacion(object sender, EventArgs e) { try { String cveJuez = InformacionPersonalJuezService.GetJuezByCorreo(Session[StringValues.CorreoSesion].ToString()).cveJuez; // Verificar que no exista ya una evaluación if (EvaluacionService.GetEvaluacionByAplicacionAndJuez(cveAplicacion, cveJuez) == null) { short evaluacion = 0; short.TryParse(aplicationEvaluationNumber.Text, out evaluacion); PI_BA_Evaluacion ev = new PI_BA_Evaluacion(); ev.cveEvaluacion = Guid.NewGuid().ToString(); ev.cveAplicacion = cveAplicacion; ev.cveJuez = cveJuez; ev.Calificacion = evaluacion; EvaluacionService.CrearEvaluacion(ev); cveMensaje = 1; } // Si ya existe else { ModificarAplicacion(sender, e); } } catch (Exception Ex) { Console.WriteLine("Catched Exception: " + Ex.Message + Environment.NewLine); cveMensaje = 0; } Response.Redirect("EvaluaAplicacion.aspx" + "?m=" + cveMensaje + "&a=" + cveAplicacion, false); }
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); }
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)); }
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); }
private void LoadJudgeTable() { var jueces = InformacionPersonalJuezService.GetJueces(); string sType = Request.QueryString["t"]; if (jueces != null) { foreach (var juez in jueces) { TableRow tr = new TableRow(); // profile image column TableCell tdIP = new TableCell(); tdIP.CssClass = "dt-profile-pic"; Image ipImage = new Image(); if (juez.NombreImagen != null) { ipImage.ImageUrl = "/ProfilePictures/" + juez.NombreImagen; } else { ipImage.ImageUrl = "/Resources/img/default-pp.jpg"; } ipImage.CssClass = "avatar img-circle"; ipImage.AlternateText = "avatar"; ipImage.Style.Add("width", "28px"); ipImage.Style.Add("height", "28px"); tdIP.Controls.Add(ipImage); // name column TableCell tdName = new TableCell(); tdName.Text = juez.Nombre; // last name column TableCell tdLastName = new TableCell(); tdLastName.Text = juez.Apellido; TableCell tdEmail = new TableCell(); LiteralControl lHiddenValue = new LiteralControl("<span id=\"" + juez.cveJuez + "\">" + juez.Correo + "</span>"); tdEmail.Controls.Add(lHiddenValue); tr.Controls.Add(tdIP); tr.Controls.Add(tdName); tr.Controls.Add(tdLastName); tr.Controls.Add(tdEmail); if (!AplicacionService.GetJuecesIdsCategoria(idCategoria).Contains(juez.cveJuez)) { listaJuecesTableBody.Controls.Add(tr); } else { listaJuezTableAsignadosBody.Controls.Add(tr); } } } }
private void LoadJudgeTable() { litUsuarios.Text = "Jueces"; var jueces = InformacionPersonalJuezService.GetJueces(); string sType = Request.QueryString["t"]; if (jueces != null) { foreach (var juez in jueces) { TableRow tr = new TableRow(); // profile image column TableCell tdIP = new TableCell(); tdIP.CssClass = "dt-profile-pic"; tdIP.Attributes.Add("onclick", "window.open('AdministraInformacionPersonal.aspx?id=" + juez.cveJuez + "&t=" + sType + "');"); Image ipImage = new Image(); if (juez.NombreImagen != null) { ipImage.ImageUrl = "/ProfilePictures/" + juez.NombreImagen; } else { ipImage.ImageUrl = "/Resources/img/default-pp.jpg"; } ipImage.CssClass = "avatar img-circle"; ipImage.AlternateText = "avatar"; ipImage.Style.Add("width", "28px"); ipImage.Style.Add("height", "28px"); tdIP.Controls.Add(ipImage); // name column TableCell tdName = new TableCell(); tdName.Text = juez.Nombre; tdName.Attributes.Add("onclick", "window.open('AdministraInformacionPersonal.aspx?id=" + juez.cveJuez + "&t=" + sType + "');"); // last name column TableCell tdLastName = new TableCell(); tdLastName.Text = juez.Apellido; tdLastName.Attributes.Add("onclick", "window.open('AdministraInformacionPersonal.aspx?id=" + juez.cveJuez + "&t=" + sType + "');"); TableCell tdEmail = new TableCell(); LiteralControl lcMailLink = new LiteralControl("<a href=\"mailto:" + juez.Correo + "?Subject=Premios%20Institucionales\" target=\"_top\"> " + juez.Correo + "</a>"); tdEmail.Controls.Add(lcMailLink); tr.Controls.Add(tdIP); tr.Controls.Add(tdName); tr.Controls.Add(tdLastName); tr.Controls.Add(tdEmail); listaJuecesTableBody.Controls.Add(tr); } } }
public static bool CambiarContrasenaJuez(String cve, String password) { var objJuez = InformacionPersonalJuezService.GetJuezById(cve); if (objJuez != null) { objJuez.Password = password; return(InformacionPersonalJuezService.UpdateJuez(objJuez)); } return(false); }
private void MostrarCampos() { var juez = InformacionPersonalJuezService.GetJuezByCorreo(Session[StringValues.CorreoSesion].ToString()); NombresTextBox.Text = juez.Nombre; ApellidosTextBox.Text = juez.Apellido; if (juez.NombreImagen != null && juez.NombreImagen.Length > 0) { if (File.Exists(Server.MapPath("~/ProfilePictures/" + juez.NombreImagen))) { avatarImage.Attributes.Add("style", "background-image: url(/ProfilePictures/" + juez.NombreImagen + ")"); } } }
protected void ActualizarDatosGenerales() { var juez = InformacionPersonalJuezService.GetJuezByCorreo(Session[StringValues.CorreoSesion].ToString()); if (juez != null) { juez.Nombre = NombresTextBox.Text; juez.Apellido = ApellidosTextBox.Text; if (!InformacionPersonalJuezService.UpdateJuez(juez)) { MostrarCampos(); } } }
public static PI_BA_Evaluacion GetEvaluacionByAplicacionAndJuez(String juezMail, String appId) { using (var dbContext = new wPremiosInstitucionalesdbEntities()) { try { var juez = InformacionPersonalJuezService.GetJuezByCorreo(juezMail); return(dbContext.GetEvaluacion(null, appId, juez.cveJuez).FirstOrDefault()); } catch (Exception Ex) { Console.WriteLine("Catched Exception: " + Ex.Message + Environment.NewLine); return(null); } } }
public static List <PI_BA_Categoria> GetCategoriaByJuez(String email) { using (var dbContext = new wPremiosInstitucionalesdbEntities()) { try { var juez = InformacionPersonalJuezService.GetJuezByCorreo(email); return(dbContext.GetCategoriaByIdJuez(juez.cveJuez).ToList()); } catch (Exception Ex) { Console.WriteLine("Catched Exception: " + Ex.Message + Environment.NewLine); return(null); } } }
protected void ActualizarContrasena() { var juez = InformacionPersonalJuezService.GetJuezByCorreo(Session[StringValues.CorreoSesion].ToString()); string sCurrentPassword = currentPwdTextBox.Text; if (juez.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 (juez != null) { juez.Password = sha256(newPwdTextBox.Text); if (InformacionPersonalJuezService.UpdateJuez(juez)) { 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(); }
private void LoadMessage() { var correo = Session[StringValues.CorreoSesion].ToString(); var juez = InformacionPersonalJuezService.GetJuezByCorreo(correo); if (juez == null) { Response.Redirect("~/WebForms/Login.aspx", false); } if (juez.Nombre != null && juez.Nombre.Length > 0) { litBienvenidoUsuario.Text = "<h1> Bienvenido, " + juez.Nombre + " </h1>"; } else { litBienvenidoUsuario.Text = "<h1> Bienvenido </h1>"; } }
private void LoadJudgeInformation(string id) { controlFormCandidato.Style.Add("display", "none"); var juez = InformacionPersonalJuezService.GetJuezById(id); if (juez != null) { jNombresTextBox.Text = juez.Nombre; jApellidosTextBox.Text = juez.Apellido; jCorreoTextBox.Text = juez.Correo; if (juez.NombreImagen != null && juez.NombreImagen.Length > 0) { if (File.Exists(Server.MapPath("~/ProfilePictures/" + juez.NombreImagen))) { avatarImage.Attributes.Add("style", "background-image: url(/ProfilePictures/" + juez.NombreImagen + ")"); } } } else { Response.Redirect("InicioAdmin.aspx", false); } }
protected void ActualizarDatosGenerales() { string sUserType = Request.QueryString["t"]; string sUserId = Request.QueryString["id"]; if (sUserType.Equals("juez")) { var juez = InformacionPersonalJuezService.GetJuezById(sUserId); if (juez != null) { juez.Nombre = jNombresTextBox.Text; juez.Apellido = jApellidosTextBox.Text; InformacionPersonalJuezService.UpdateJuez(juez); } } else if (sUserType.Equals("candidato")) { var candidato = InformacionPersonalCandidatoService.GetCandidatoById(sUserId); 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; } InformacionPersonalCandidatoService.UpdateCandidato(candidato); } } }
protected void CambiarContrasena_Click(object sender, EventArgs e) { string sUserType = Request.QueryString["t"]; string sUserId = Request.QueryString["id"]; if (sUserType.Equals("juez")) { var juez = InformacionPersonalJuezService.GetJuezById(sUserId); 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 (juez != null) { juez.Password = sha256(newPwdTextBox.Text); if (InformacionPersonalJuezService.UpdateJuez(juez)) { MasterPage.ShowMessage("Aviso", "Contraseña cambiada con éxito."); } else { LoadJudgeInformation(sUserId); } } } 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 if (sUserType.Equals("candidato")) { var candidato = InformacionPersonalCandidatoService.GetCandidatoById(sUserId); 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 { LoadCandidateInformation(sUserId); } } } 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."); } } ResetFields(); }
protected DataTable loadDataTable() { DataTable DT = new DataTable(); string sType = Request.QueryString["t"]; if (sType != null) { if (sType == "candidato") { var candidatos = InformacionPersonalCandidatoService.GetCandidatos(); if (candidatos != null) { DT.Clear(); DT.Columns.AddRange(new DataColumn[] { new DataColumn("Nombre"), new DataColumn("Apellido"), new DataColumn("Correo"), new DataColumn("Telefono"), new DataColumn("Nacionalidad"), new DataColumn("RFC"), new DataColumn("Direccion") }); foreach (var cand in candidatos) { DT.Rows.Add(new object[] { cand.Nombre, cand.Apellido, cand.Correo, cand.Telefono, cand.Nacionalidad, cand.RFC, cand.Direccion }); DT.AcceptChanges(); } } } else if (sType == "juez") { var jueces = InformacionPersonalJuezService.GetJueces(); if (jueces != null) { DT.Clear(); DT.Columns.AddRange(new DataColumn[] { new DataColumn("Nombre"), new DataColumn("Apellido"), new DataColumn("Correo") }); foreach (var juez in jueces) { DT.Rows.Add(new object[] { juez.Nombre, juez.Apellido, juez.Correo }); DT.AcceptChanges(); } } } } return(DT); }
protected bool Upload(object sender, EventArgs e) { if (FileUploadImage.HasFile) { // Get filename string fileName = Path.GetFileName(FileUploadImage.PostedFile.FileName); // Get logged in candidate string sUserType = Request.QueryString["t"]; string sUserId = Request.QueryString["id"]; // 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 user if (sUserType.Equals("juez")) { var juez = InformacionPersonalJuezService.GetJuezById(sUserId); if (juez.NombreImagen != null && juez.NombreImagen.Length > 0) { // Delete previous image... File.Delete(Server.MapPath("~/ProfilePictures/") + juez.NombreImagen); } } else if (sUserType.Equals("candidato")) { var candidato = InformacionPersonalCandidatoService.GetCandidatoById(sUserId); 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 if (sUserType.Equals("juez")) { InformacionPersonalJuezService.CambiaImagen(sUserId, null, sNombreImagen); } else if (sUserType.Equals("candidato")) { InformacionPersonalCandidatoService.CambiaImagen(sUserId, null, sNombreImagen); } return(true); } } } else { MasterPage.ShowMessage("Error", "La imagen proporcionada debe estar en formato PNG , JPG o BMP."); return(false); } } return(true); }