// Evento PreLoad protected void Override_PagePreLoad(object sender, EventArgs e) { DAArea oDAArea = new DAArea(); ENTSession oENTSession; GCEncryption gcEncryption = new GCEncryption(); String sKey = ""; String sPage = ""; // Validación. Solo la primera vez que entre a la página if (this.IsPostBack) { return; } // Mensaje de error general sKey = gcEncryption.EncryptString("[V01] Acceso denegado", true); // Sesión if (this.Session["oENTSession"] == null){ this.Response.Redirect("~/Index.aspx", true); } // Información de Sesión oENTSession = (ENTSession)this.Session["oENTSession"]; // Token generado if (!oENTSession.TokenGenerado){ this.Response.Redirect("~/Index.aspx", true); } // Página que esta visitando sPage = this.Request.Url.AbsolutePath; sPage = sPage.Split(new Char[] { '/' })[sPage.Split(new Char[] { '/' }).Length - 1]; // Validación de permisos en la página actual if (sPage != "AppIndex.aspx" && sPage != "saLogout.aspx" && sPage != "saNotificacion.aspx"){ // Permisos if (oENTSession.tblSubMenu.Select("sPageName = '" + sPage + "'").Length < 1){ sKey = gcEncryption.EncryptString("[V02] No tiene permisos para acceder a esta página", true); this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sKey, true); } } // Validación de acceso a opciones [System Administrator] if ((sPage == "scatArea.aspx" || sPage == "scatMenu.aspx" || sPage == "scatSubMenu.aspx") && (oENTSession.idRol != 1) ){ sKey = gcEncryption.EncryptString("[V03] No tiene permisos para acceder a esta página", true); this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sKey, true); } // Deshabilitar caché this.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); }
///<remarks> /// <name>BPUsuario.InsertUsuario</name> /// <create>21-Octubre-2013</create> /// <author>GCSoft - Web Project Creator BETA 1.0</author> ///</remarks> ///<summary>Actualiza la información de un usuario</summary> ///<param name="oENTUsuario">Entidad de usuario con los parámetros necesarios para actualizar su información</param> ///<returns>Una entidad de respuesta</returns> public ENTResponse InsertUsuario(ENTUsuario oENTUsuario) { GCMail gcMail = new GCMail(); GCEncryption gcEncryption = new GCEncryption(); GCPassword gcPassword = new GCPassword(); DAUsuario oDAUsuario = new DAUsuario(); ENTResponse oENTResponse = new ENTResponse(); String sHTMLMessage = ""; String sPassword = ""; try { // Generar Password sPassword = gcPassword.Create(); // Encriptar el Password oENTUsuario.sPassword = gcEncryption.EncryptString(sPassword, false); // Validación de creación de password if (oENTUsuario.sPassword.Trim() == "") { throw (new Exception("Se generó una excepción al crear el usuario. Por favor intente de nuevo")); } // Transacción en base de datos oENTResponse = oDAUsuario.InsertUsuario(oENTUsuario, this.sConnectionApplication, 300); // Validación de error en consulta if (oENTResponse.GeneratesException) { return oENTResponse; } // Validación de mensajes de la BD oENTResponse.sMessage = oENTResponse.dsResponse.Tables[0].Rows[0]["sResponse"].ToString(); if (oENTResponse.sMessage != "") { return oENTResponse; } // Configuración del correo sHTMLMessage = "" + "<html>" + "<head>" + "<title>SIAQ - Bienvenido al sistema</title>" + "</head>" + "<body style='height:100%; margin:0px; padding:0px; width:100%;'>" + "<div style='clear:both; height:90%; text-align:center; width:100%;'>" + "<div style='height:80%; clear: both; margin:0px auto; position:relative; top:10%; width:90%;'>" + "<table border='0px;' cellpadding='0' cellspacing='0' style='height:100%; width:100%;'>" + "<tr>" + "<td colspan='2' valign='middle' style='color:#549CC6; font-family:Arial; font-size:12px; font-weight:bold; text-align:left;'>SIAQ - Bienvenido al sistema</td>" + "</tr>" + "<tr><td colspan='3'><div style='border-bottom:1px solid #549CC6;'></div></td></tr>" + "<tr style='height:10px'><td colspan='3'></td></tr>" + "<tr>" + "<td colspan='2' valign='top' style='font-family:Arial; font-size:12px;'>" + "El equipo de Logística le da la bienvenida al sistema de SIAQ. Los datos de acceso a la aplicación son los siguientes<br><br>" + "<table border='0px' cellpadding='0' cellspacing ='0' class='Text' style='height:100%; width:100%'>" + "<tr style='height:10px'><td></td></tr>" + "<tr>" + "<td style='text-align:left;'>" + "<b>Usuario:</b> " + oENTUsuario.sEmail + "</td>" + "</tr>" + "<tr>" + "<td style='text-align:left;'>" + "<b>Password:</b> " + sPassword + "</td>" + "</tr>" + "<tr>" + "<td style='font-family:Arial; font-size:12px; text-align:left;'>" + "<br>Puede acceder al sistema haciendo click <a href='" + this.sApplicationURL + "'>aqui</a>" + "</td>" + "</tr>" + "<tr>" + "<td style='text-align:left;'>" + "<br><br>NOTA: Es recomendable que cambie su contraseña desde el menú Administración/Cambio de Contraseña." + "</td>" + "</tr>" + "<tr>" + "<td style='font-family:Arial; font-size:12px; text-align:left;'>" + "<br><br><br>Gracias por utilizar nuestros servicios informáticos" + "</td>" + "</tr>" + "<tr>" + "<td style='font-family:Arial; font-size:9px; text-align:center;'>" + "<br><br>Powered By SetUp" + "</td>" + "</tr>" + "</table>" + "</td>" + "</tr>" + "<tr style='height:20px'><td colspan='3'></td></tr>" + "<tr style='height:20px'><td colspan='3'></td></tr>" + "<tr style='height:1px'><td colspan='3' style='background:#000063 repeat-x;'></td></tr>" + "<tr style='height:60px; vertical-align:top;'>" + "<td colspan='2' style='font-family:Arial; font-size:10px; color: #180A3B; text-align:justify; vertical-align:middle;'>" + "Este correo electronico es confidencial y/o puede contener informacion privilegiada. Si usted no es su destinatario o no es alguna persona autorizada por este para recibir sus correos electronicos, NO debera usted utilizar, copiar, revelar, o tomar ninguna accion basada en este correo electronico o cualquier otra informacion incluida en el, favor de notificar al remitente de inmediato mediante el reenvio de este correo electronico y borrar a continuacion totalmente este correo electronico y sus anexos.<br/><br/>Nota: Los acentos y caracteres especiales fueron omitidos para su correcta lectura en cualquier medio electronico.<br/>" + "</td>" + "<td></td>" + "</tr>" + "<tr><td colspan='3'></td></tr>" + "</table>" + "</div>" + "</div>" + "</body>" + "</html>"; // Enviar correo gcMail.Send("SIAQ - Bienvenido al sistema", oENTUsuario.sEmail, "SIAQ - Bienvenido al sistema", sHTMLMessage); }catch (Exception ex){ oENTResponse.ExceptionRaised(ex.Message); } // Resultado return oENTResponse; }
///<remarks> /// <name>BPUsuario.UpdateUsuario_ActualizaContrasena</name> /// <create>21-Octubre-2013</create> /// <author>GCSoft - Web Project Creator BETA 1.0</author> ///</remarks> ///<summary>Actualiza la contraseña de un usuario</summary> ///<param name="oENTUsuario">Entidad de usuario con los parámetros necesarios para actualizar la contraseña</param> ///<returns>Una entidad de respuesta</returns> public ENTResponse UpdateUsuario_ActualizaContrasena(ENTUsuario oENTUsuario) { GCEncryption gcEncryption = new GCEncryption(); DAUsuario oDAUsuario = new DAUsuario(); ENTResponse oENTResponse = new ENTResponse(); try { // Encriptar el passwords oENTUsuario.sPassword = gcEncryption.EncryptString(oENTUsuario.sPassword, false); oENTUsuario.sOldPassword = gcEncryption.EncryptString(oENTUsuario.sOldPassword, false); // Transacción en base de datos oENTResponse = oDAUsuario.UpdateUsuario_ActualizaContrasena(oENTUsuario, this.sConnectionApplication, 0); // Validación de error en consulta if (oENTResponse.GeneratesException) { return oENTResponse; } // Validación de mensajes de la BD oENTResponse.sMessage = oENTResponse.dsResponse.Tables[0].Rows[0]["sResponse"].ToString(); if (oENTResponse.sMessage != "") { return oENTResponse; } }catch (Exception ex){ oENTResponse.ExceptionRaised(ex.Message); } // Resultado return oENTResponse; }
///<remarks> /// <name>BPUsuario.selectUsuario_Autenticacion</name> /// <create>21-Octubre-2013</create> /// <author>GCSoft - Web Project Creator BETA 1.0</author> ///</remarks> ///<summary>Valida las credenciales de un usuario para verificar el acceso al sistema. Si las credenciales son válidas configura la sesión.</summary> ///<param name="oENTUsuario">Entidad de usuario con los parámetros necesarios para consultar la información</param> ///<returns>Una entidad de respuesta</returns> public ENTResponse SelectUsuario_Autenticacion(ENTUsuario oENTUsuario) { GCAuthentication gcAuthentication = new GCAuthentication(); GCEncryption gcEncryption = new GCEncryption(); DAUsuario oDAUsuario = new DAUsuario(); ENTResponse oENTResponse = new ENTResponse(); ENTSession oENTSession = new ENTSession(); HttpContext oContext; try { // Encriptar el password oENTUsuario.sPassword = gcEncryption.EncryptString(oENTUsuario.sPassword, false); // Consulta a base de datos oENTResponse = oDAUsuario.SelectUsuario_Autenticacion(oENTUsuario, this.sConnectionApplication, 0); // Validación de error en consulta if (oENTResponse.GeneratesException) { return oENTResponse; } // Validación de mensajes de la BD oENTResponse.sMessage = oENTResponse.dsResponse.Tables[0].Rows[0]["sResponse"].ToString(); if (oENTResponse.sMessage != "") { return oENTResponse; } // Configurar de entidad de sesión oENTSession.idUsuario = int.Parse(oENTResponse.dsResponse.Tables[1].Rows[0]["idUsuario"].ToString()); oENTSession.FuncionarioId = int.Parse(oENTResponse.dsResponse.Tables[1].Rows[0]["FuncionarioId"].ToString()); oENTSession.idArea = int.Parse(oENTResponse.dsResponse.Tables[1].Rows[0]["idArea"].ToString()); oENTSession.idRol = int.Parse(oENTResponse.dsResponse.Tables[1].Rows[0]["idRol"].ToString()); oENTSession.sEmail = oENTUsuario.sEmail; oENTSession.sNombre = oENTResponse.dsResponse.Tables[1].Rows[0]["sNombre"].ToString(); oENTSession.tblSubMenu = oENTResponse.dsResponse.Tables[2]; oENTSession.tblMenu = oENTResponse.dsResponse.Tables[3]; // Autenticar el usuario gcAuthentication.AuthenticateUser(oENTSession.sEmail, this.iSessionTimeout); oENTSession.TokenGenerado = true; // Variable de sesión con los datos del usuario oContext = HttpContext.Current; oContext.Session["oENTSession"] = oENTSession; }catch (Exception ex){ oENTResponse.ExceptionRaised(ex.Message); } // Resultado return oENTResponse; }