diff --git a/Business/Business.csproj b/Business/Business.csproj index e7919c36..40e6bc94 100644 --- a/Business/Business.csproj +++ b/Business/Business.csproj @@ -148,6 +148,7 @@ + @@ -321,6 +322,7 @@ + diff --git a/Business/Data/Laboratorio/LogAccesoTerminosCondiciones.cs b/Business/Data/Laboratorio/LogAccesoTerminosCondiciones.cs new file mode 100644 index 00000000..ddf0777f --- /dev/null +++ b/Business/Data/Laboratorio/LogAccesoTerminosCondiciones.cs @@ -0,0 +1,104 @@ +/* +insert license info here +*/ +using System; +using System.Collections; + +namespace Business.Data.Laboratorio +{ + /// + /// Generated by MyGeneration using the NHibernate Object Mapping template + /// + [Serializable] + public sealed class LogAccesoTerminosCondiciones: Business.BaseDataAccess + { + + #region Private Members + private bool m_isChanged; + + private int m_idlogacceso; + private int m_idusuario; + private DateTime m_fecha; + #endregion + + #region Default ( Empty ) Class Constuctor + /// + /// default constructor + /// + public LogAccesoTerminosCondiciones() + { + m_idlogacceso = 0; + m_idusuario = 0; + m_fecha = DateTime.MinValue; + } + #endregion // End of Default ( Empty ) Class Constuctor + + #region Required Fields Only Constructor + /// + /// required (not null) fields only constructor + /// + public LogAccesoTerminosCondiciones( + int idusuario, + DateTime fecha) + : this() + { + m_idusuario = idusuario; + m_fecha = fecha; + } + #endregion // End Required Fields Only Constructor + + #region Public Properties + + /// + /// + /// + public int IdLogAcceso + { + get { return m_idlogacceso; } + set + { + m_isChanged |= ( m_idlogacceso != value ); + m_idlogacceso = value; + } + + } + + /// + /// + /// + public int IdUsuario + { + get { return m_idusuario; } + set + { + m_isChanged |= ( m_idusuario != value ); + m_idusuario = value; + } + + } + + /// + /// + /// + public DateTime Fecha + { + get { return m_fecha; } + set + { + m_isChanged |= ( m_fecha != value ); + m_fecha = value; + } + + } + + /// + /// Returns whether or not the object has changed it's values. + /// + public bool IsChanged + { + get { return m_isChanged; } + } + + #endregion + } +} diff --git a/Business/Data/Laboratorio/LogAccesoTerminosCondiciones.hbm.xml b/Business/Data/Laboratorio/LogAccesoTerminosCondiciones.hbm.xml new file mode 100644 index 00000000..180265fc --- /dev/null +++ b/Business/Data/Laboratorio/LogAccesoTerminosCondiciones.hbm.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Business/Data/Usuario.cs b/Business/Data/Usuario.cs index af779a53..228557d9 100644 --- a/Business/Data/Usuario.cs +++ b/Business/Data/Usuario.cs @@ -33,9 +33,10 @@ public sealed class Usuario: Business.BaseDataAccess private int m_idarea; private bool m_requiereCambioPass; private bool m_administrador; - private bool m_externo; + private bool m_externo; private string m_email; private string m_telefono; + private DateTime m_fechaTerminosCondiciones; #endregion #region Default ( Empty ) Class Constuctor @@ -63,7 +64,7 @@ public Usuario() m_externo = false; m_email= String.Empty; m_telefono = String.Empty; - + m_fechaTerminosCondiciones = new DateTime(1900,01,01); } @@ -93,7 +94,7 @@ public Usuario( m_requiereCambioPass = false; m_administrador = false; m_externo = false; - + m_fechaTerminosCondiciones = new DateTime(1900, 01, 01); } #endregion // End Required Fields Only Constructor @@ -330,7 +331,7 @@ public bool Activo } } - public bool Externo + public bool Externo { get { return m_externo; } set @@ -429,24 +430,32 @@ public bool IsChanged get { return m_isChanged; } } - - #endregion + #endregion - #region Metodos + #region Metodos - #endregion - //public bool esHemoterapia() - //{ - // var index=this.IdPerfil.Nombre.ToUpper().IndexOf("HEMOTERAPIA"); - // if (index > -1) return true; - // else return false; + #endregion - //} + //public bool esHemoterapia() + //{ + // var index=this.IdPerfil.Nombre.ToUpper().IndexOf("HEMOTERAPIA"); + // if (index > -1) return true; + // else return false; + //} + + + public DateTime FechaAceptaTerminosCondiciones { + get { return m_fechaTerminosCondiciones; } + set { + m_isChanged |= (m_fechaTerminosCondiciones != value); + m_fechaTerminosCondiciones = value; + } } + } } diff --git a/Business/Data/Usuario.hbm.xml b/Business/Data/Usuario.hbm.xml index c0208ff7..c7800e2d 100644 --- a/Business/Data/Usuario.hbm.xml +++ b/Business/Data/Usuario.hbm.xml @@ -30,5 +30,7 @@ + + diff --git a/WebLab/loginSIL.ascx b/WebLab/loginSIL.ascx index 5034c9b8..9bc29ebc 100644 --- a/WebLab/loginSIL.ascx +++ b/WebLab/loginSIL.ascx @@ -17,7 +17,7 @@ PasswordRequiredErrorMessage="Contraseña es requerida" TitleText="Nueva autenticación de usuario" UserNameLabelText="Usuario:" UserNameRequiredErrorMessage="Usuario es requerido" - > + FailureText="" >
@@ -61,3 +61,84 @@
+ + + + + \ No newline at end of file diff --git a/WebLab/loginSIL.ascx.cs b/WebLab/loginSIL.ascx.cs index 63c66773..a70c65b0 100644 --- a/WebLab/loginSIL.ascx.cs +++ b/WebLab/loginSIL.ascx.cs @@ -40,8 +40,6 @@ protected void Page_Load(object sender, EventArgs e) } } - ////else - } protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) @@ -60,9 +58,9 @@ protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) adapter.Fill(Ds); DataTable dtPermisos = Ds.Tables[0]; - if (dtPermisos.Rows.Count > 0) { - i_idusuario = int.Parse(dtPermisos.Rows[0][0].ToString()); - } + if (dtPermisos.Rows.Count > 0) { + i_idusuario = int.Parse(dtPermisos.Rows[0][0].ToString()); + } Usuario oUser = new Usuario(); @@ -71,6 +69,13 @@ protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { oUser = (Usuario)oUser.Get(typeof(Usuario), i_idusuario); + if (MostrarTerminosCondiciones(oUser)) + { + Session["usuarioPendienteAceptacion"] = oUser; + ScriptManager.RegisterStartupScript(this, this.GetType(), "mostrarModal", "$('#modalTerminosCondiciones').modal('show');", true); + return; + } + } else { @@ -80,113 +85,7 @@ protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) } - /* Habilitar cuando se quiera autogestion de usuarios medicos - if (oUser == null) - AutenticarUsuarioLdap(Login1.UserName, Login1.Password); - */ - if (oUser != null) - { - if ((oUser.Activo)&&(oUser.IdPerfil.Activo)) - { - if ((oUser.Activo) && (oUser.Externo)) - { - Session["idUsuario"] = oUser.IdUsuario.ToString(); - Response.Redirect("~/Consulta/Historiaclinicafiltro.aspx", false); - - } - else - { - Session["idUsuarioValida"] = null; - - if (Request["Operacion"] == null) - {//////////////nuevo login - Session["SIL"] = "1"; - - if (oUser.RequiereCambioPass) - Response.Redirect("~/Usuarios/PasswordEdit2.aspx?idUsuario="+ oUser.IdUsuario.ToString(), false); - - else - { - Session["idUsuarioAux"] = oUser.IdUsuario.ToString(); - Response.Redirect("LoginEfector.aspx", false); - - //Session["idUsuario"] = oUser.IdUsuario.ToString(); - //Response.Redirect("Default.aspx", false); - } - } - else - {///////////////validacion - if (Request["idCasoFiliacion"] != null) - { - - - if ((Request["idServicio"].ToString() == "6") && (VerificarSiTienePermisodeValidar(oUser.Username, "/CasoFiliacion/CasoResultado.aspx"))) - { - //HttpContext Context; - //Context = HttpContext.Current; - //Context.Items.Add("id", Request["idCasoFiliacion"].ToString()); - Session["idUsuarioValida"] = oUser.IdUsuario.ToString(); - //Context.Items.Add("Desde", "Valida"); - //Server.Transfer("~/CasoFiliacion/CasoResultado.aspx"); - - Response.Redirect("~/casoFiliacion/CasoResultado3.aspx?id=" + Request["idCasoFiliacion"].ToString()+ "&Desde=Valida&logIn=1"); - - - } - if ((Request["idServicio"].ToString() == "3") && (VerificarSiTienePermisodeValidar(oUser.Username, "/CasoFiliacion/CasoResultadoHisto.aspx"))) - { - //HttpContext Context2; - //Context2 = HttpContext.Current; - //Context2.Items.Add("id", Request["idCasoFiliacion"].ToString()); - Session["idUsuarioValida"] = oUser.IdUsuario.ToString(); - //Context2.Items.Add("Desde", "Valida"); - //Server.Transfer("~/CasoFiliacion/CasoResultadoHisto.aspx"); - - Response.Redirect("~/CasoFiliacion/CasoResultadoHisto.aspx?id=" + Request["idCasoFiliacion"].ToString() + "&Desde=Valida&logIn=1", false); - - } - - } - else - { - string idServicio = Request["idServicio"].ToString(); - string operacion = Request["Operacion"].ToString(); - string modo = Request["modo"].ToString(); - if (VerificarSiTienePermisodeValidar(oUser.Username, "/Resultados/ResultadoBusqueda.aspx?idServicio=" + idServicio + "&Operacion=" + operacion + "&modo=" + modo)) - { - Session["idUsuarioValida"] = oUser.IdUsuario.ToString(); - if (Request["urgencia"] != null) - { - - string sredirect = "~/resultados/ResultadoEdit2.aspx?idServicio=1&Operacion=Valida&idProtocolo=" + Request["idProtocolo"].ToString() + "&Index=0&Parametros=" + Request["idProtocolo"].ToString() + "&idArea=0&urgencia=1&validado=0&modo=Urgencia"; //&idUsuarioValida=" + oUser.IdUsuario.ToString(); - if (Request["desde"] != null) - sredirect += "&desde=" + Request["desde"].ToString(); - Response.Redirect(sredirect, false); - // Response.Redirect("~/Resultados/ResultadoBusqueda.aspx?idServicio=" + idServicio + "&Operacion=" + operacion + "&modo=" + modo + "&idUsuarioValida=" + oUser.IdUsuario, false); - } - else - Response.Redirect("~/Resultados/ResultadoBusqueda.aspx?idServicio=" + idServicio + "&Operacion=" + operacion + "&modo=" + modo + "&logIn=1", false);// + "&idUsuarioValida=" + oUser.IdUsuario, false); - } - else - { - e.Authenticated = false; - Login1.FailureText = "El usuario no tiene permisos para validar."; - } - } - }//fin else casofi - }//externo - }//activo - else - { - e.Authenticated = false; - Login1.FailureText = "El usuario no está activo por inactividad."; - } - } - else - { - e.Authenticated = false; - Login1.FailureText = "El usuario y/o contraseña no son correctos."; - } + IngresoSistema(oUser, e); } @@ -327,5 +226,171 @@ FROM Sys_Menu AS M INNER JOIN return b_permiso; } } + + private void IngresoSistema(Usuario oUser, AuthenticateEventArgs e) + { + + /* Habilitar cuando se quiera autogestion de usuarios medicos + if (oUser == null) + AutenticarUsuarioLdap(Login1.UserName, Login1.Password); + */ + if (oUser != null) + { + if ((oUser.Activo) && (oUser.IdPerfil.Activo)) + { + if ((oUser.Activo) && (oUser.Externo)) + { + Session["idUsuario"] = oUser.IdUsuario.ToString(); + Response.Redirect("~/Consulta/Historiaclinicafiltro.aspx", false); + + } + else + { + Session["idUsuarioValida"] = null; + + if (Request["Operacion"] == null) + {//////////////nuevo login + Session["SIL"] = "1"; + + if (oUser.RequiereCambioPass) + Response.Redirect("~/Usuarios/PasswordEdit2.aspx?idUsuario=" + oUser.IdUsuario.ToString(), false); + + else + { + Session["idUsuarioAux"] = oUser.IdUsuario.ToString(); + Response.Redirect("LoginEfector.aspx", false); + + //Session["idUsuario"] = oUser.IdUsuario.ToString(); + //Response.Redirect("Default.aspx", false); + } + } + else + {///////////////validacion + if (Request["idCasoFiliacion"] != null) + { + + + if ((Request["idServicio"].ToString() == "6") && (VerificarSiTienePermisodeValidar(oUser.Username, "/CasoFiliacion/CasoResultado.aspx"))) + { + //HttpContext Context; + //Context = HttpContext.Current; + //Context.Items.Add("id", Request["idCasoFiliacion"].ToString()); + Session["idUsuarioValida"] = oUser.IdUsuario.ToString(); + //Context.Items.Add("Desde", "Valida"); + //Server.Transfer("~/CasoFiliacion/CasoResultado.aspx"); + + Response.Redirect("~/casoFiliacion/CasoResultado3.aspx?id=" + Request["idCasoFiliacion"].ToString() + "&Desde=Valida&logIn=1"); + + + } + if ((Request["idServicio"].ToString() == "3") && (VerificarSiTienePermisodeValidar(oUser.Username, "/CasoFiliacion/CasoResultadoHisto.aspx"))) + { + //HttpContext Context2; + //Context2 = HttpContext.Current; + //Context2.Items.Add("id", Request["idCasoFiliacion"].ToString()); + Session["idUsuarioValida"] = oUser.IdUsuario.ToString(); + //Context2.Items.Add("Desde", "Valida"); + //Server.Transfer("~/CasoFiliacion/CasoResultadoHisto.aspx"); + + Response.Redirect("~/CasoFiliacion/CasoResultadoHisto.aspx?id=" + Request["idCasoFiliacion"].ToString() + "&Desde=Valida&logIn=1", false); + + } + + } + else + { + string idServicio = Request["idServicio"].ToString(); + string operacion = Request["Operacion"].ToString(); + string modo = Request["modo"].ToString(); + if (VerificarSiTienePermisodeValidar(oUser.Username, "/Resultados/ResultadoBusqueda.aspx?idServicio=" + idServicio + "&Operacion=" + operacion + "&modo=" + modo)) + { + Session["idUsuarioValida"] = oUser.IdUsuario.ToString(); + if (Request["urgencia"] != null) + { + + string sredirect = "~/resultados/ResultadoEdit2.aspx?idServicio=1&Operacion=Valida&idProtocolo=" + Request["idProtocolo"].ToString() + "&Index=0&Parametros=" + Request["idProtocolo"].ToString() + "&idArea=0&urgencia=1&validado=0&modo=Urgencia"; //&idUsuarioValida=" + oUser.IdUsuario.ToString(); + if (Request["desde"] != null) + sredirect += "&desde=" + Request["desde"].ToString(); + Response.Redirect(sredirect, false); + // Response.Redirect("~/Resultados/ResultadoBusqueda.aspx?idServicio=" + idServicio + "&Operacion=" + operacion + "&modo=" + modo + "&idUsuarioValida=" + oUser.IdUsuario, false); + } + else + Response.Redirect("~/Resultados/ResultadoBusqueda.aspx?idServicio=" + idServicio + "&Operacion=" + operacion + "&modo=" + modo + "&logIn=1", false);// + "&idUsuarioValida=" + oUser.IdUsuario, false); + } + else + { + e.Authenticated = false; + Login1.FailureText = "El usuario no tiene permisos para validar."; + } + } + }//fin else casofi + }//externo + }//activo + else + { + e.Authenticated = false; + Login1.FailureText = "El usuario no está activo por inactividad."; + } + } + else + { + e.Authenticated = false; + Login1.FailureText = "El usuario y/o contraseña no son correctos."; + } + } + protected void btn_aceptarTerminosCondiciones_Click(object sender, EventArgs e) + { + Usuario oUser = (Usuario) Session["usuarioPendienteAceptacion"]; + + if (oUser != null) + { + Session["usuarioPendienteAceptacion"] = null; + //Actualizar la fecha en la bd + oUser.FechaAceptaTerminosCondiciones = DateTime.Now; + oUser.Save(); + //Actualizo acceso en log + CrearLogAcceso(oUser); + //Ingreso al sistema + AuthenticateEventArgs evento = new AuthenticateEventArgs(); + IngresoSistema(oUser, evento); + } + else + { + // Fallback: recargar página o mostrar error + Response.Redirect("Logout.aspx", true); + } + } + private void CrearLogAcceso(Usuario oUser) + { + LogAccesoTerminosCondiciones RegistroAcceso = new LogAccesoTerminosCondiciones(); + RegistroAcceso.IdUsuario = oUser.IdUsuario; + RegistroAcceso.Fecha = DateTime.Now; + RegistroAcceso.Save(); + } + + private bool MostrarTerminosCondiciones(Usuario oUser) + { + int dias = Convert.ToInt32(ConfigurationManager.AppSettings["DiasTerminosCondiciones"]); + if(dias > 0) + { + DateTime ultimaFecha = oUser.FechaAceptaTerminosCondiciones; + DateTime hoy = DateTime.Now; + + TimeSpan diferencia = hoy.Subtract(ultimaFecha); + int diferenciasDias = diferencia.Days; + + if (diferenciasDias > dias) + return true; + else + return false; + } + else + { + ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "alert('❌ No hay dias definidos para los terminos y condiciones');", true); + return true; + } + + + } } } \ No newline at end of file diff --git a/WebLab/loginSIL.ascx.designer.cs b/WebLab/loginSIL.ascx.designer.cs index c841dfbd..fda68eb1 100644 --- a/WebLab/loginSIL.ascx.designer.cs +++ b/WebLab/loginSIL.ascx.designer.cs @@ -7,12 +7,13 @@ // //------------------------------------------------------------------------------ -namespace WebLab { - - +namespace WebLab +{ + + public partial class loginSIL { - + /// /// Login1 control. /// @@ -21,5 +22,23 @@ public partial class loginSIL /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.Login Login1; + + /// + /// cb_aceptaTerminos control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox cb_aceptaTerminos; + + /// + /// btn_aceptarTerminosCondiciones control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btn_aceptarTerminosCondiciones; } }