protected IList <FuncionDTO> CargarSubMenu(string pFuncionGrupoCod) { myUsuario = (YouCom.DTO.Seguridad.UsuarioDTO)Session["usuario"]; IList <FuncionDTO> IFuncion = new List <FuncionDTO>(); foreach (YouCom.DTO.Seguridad.CondominioDTO condominio in myUsuario.TheCondominioDTO) { foreach (YouCom.DTO.ProductoDTO producto in condominio.Productos) { if (producto.Codigo.Equals(pFuncionGrupoCod)) { foreach (YouCom.DTO.Item funciones in producto.Funciones) { FuncionDTO funcion = new FuncionDTO(); FuncionDTO theFuncion = new FuncionDTO(); theFuncion = YouCom.Seguridad.BLL.FuncionBLL.detalleFuncion(funciones.Codigo); funcion.FuncionNombre = funciones.Descripcion; funcion.FuncionGrupoCod = theFuncion.FuncionGrupoCod; funcion.Url = "http://" + Request.Url.Authority + ResolveUrl("~/") + "Private/" + theFuncion.Url.Replace("~/", ""); funcion.GrupoCod = theFuncion.FuncionGrupoCod; IFuncion.Add(funcion); } } } } return(IFuncion); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { myUsuario = (YouCom.DTO.Seguridad.UsuarioDTO)Session["usuario"]; cargarCondominio(); if (myUsuario.IndexCondominio == 0) { pnlAdministrador.Visible = true; } else { pnlAdministrador.Visible = false; ddlCondominio.SelectedIndex = ddlCondominio.Items.IndexOf(ddlCondominio.Items.FindByValue(myUsuario.TheCondominioSeleccionDTO.IdCondominio.ToString())); ddlComunidad.DataSource = YouCom.bll.ComunidadBLL.getListadoComunidadByCondominio(decimal.Parse(ddlCondominio.SelectedValue)); ddlComunidad.DataTextField = "NombreComunidad"; ddlComunidad.DataValueField = "IdComunidad"; ddlComunidad.DataBind(); ddlComunidad.Items.Insert(0, new ListItem("Seleccione Comunidad", string.Empty)); ddlComunidad.SelectedIndex = ddlComunidad.Items.IndexOf(ddlComunidad.Items.FindByValue(myUsuario.TheComunidadSeleccionDTO.IdComunidad.ToString())); } } }
/// <summary> /// Carga Menu Dinamico desde BD /// </summary> protected IList <FuncionGrupoDTO> CargarMenu() { IList <FuncionGrupoDTO> IFuncionGrupo = new List <FuncionGrupoDTO>(); myUsuario = (YouCom.DTO.Seguridad.UsuarioDTO)Session["usuario"]; string grupoCod = string.Empty; foreach (YouCom.DTO.Seguridad.CondominioDTO condominio in myUsuario.TheCondominioDTO) { foreach (YouCom.DTO.ProductoDTO producto in condominio.Productos) { FuncionGrupoDTO funcionGrupo = new FuncionGrupoDTO(); funcionGrupo.FuncionGrupoCod = producto.Codigo; funcionGrupo.FuncionGrupoNombre = producto.Descripcion; //funcionGrupo.FuncionGrupoTipo = principal.FuncionGrupoTipo; IFuncionGrupo.Add(funcionGrupo); //grupoCod = principal.FuncionGrupoCod; } } return(IFuncionGrupo); }
public List <YouCom.DTO.Seguridad.UsuarioDTO> LoginUsuario(string mvarUsuarioCod, string mvarPassword) { YouCom.DTO.Seguridad.UsuarioDTO theOperador = new YouCom.DTO.Seguridad.UsuarioDTO(); try { if (!string.IsNullOrEmpty(mvarUsuarioCod)) { theOperadorDTO = AuntetificaUsuario(mvarUsuarioCod, mvarPassword); } else { throw new Exception("Debe indicarse UsuarioCod"); } List <FuncionGrupoDTO> grupos = new List <FuncionGrupoDTO>(); FuncionGrupoDTO theFuncionGrupoDTO = new FuncionGrupoDTO(); FuncionDTO theFuncionDTO; theOperador.Grupo = new List <FuncionGrupoDTO>(); theOperador = GetGrupos(theOperadorDTO.Usuario.ToString()); foreach (var item in grupos) { ///Carga Funciones de Menu General theFuncionGrupoDTO.FuncionGrupoCod = item.FuncionGrupoCod; theFuncionGrupoDTO.FuncionGrupoNombre = item.FuncionGrupoNombre; theFuncionGrupoDTO.FuncionGrupoTipo = item.FuncionGrupoTipo; theFuncionGrupoDTO.Funciones = new List <FuncionDTO>(); ///Carga Opciones de Menu y Configuracion de Negocio foreach (var opciones in item.Funciones) { theFuncionDTO = new FuncionDTO(); theFuncionDTO.FuncionGrupoCod = opciones.FuncionGrupoCod; theFuncionDTO.FuncionNombre = opciones.FuncionNombre; theFuncionDTO.FuncionTipoCod = opciones.FuncionTipoCod; theFuncionDTO.FuncionalidadNegocio = opciones.FuncionalidadNegocio; theFuncionDTO.Url = opciones.Url; theFuncionGrupoDTO.Funciones.Add(theFuncionDTO); } } theOperador.Usuario = theOperadorDTO.Usuario; theOperador.Nombres = theOperadorDTO.Nombres; theOperador.Paterno = theOperadorDTO.Paterno; theOperador.Materno = theOperadorDTO.Materno; theOperador.Grupo.Add(theFuncionGrupoDTO); operador.Add(theOperador); } catch (Exception eobjException) { throw new Exception(eobjException.Message); } return(operador); }
public static YouCom.DTO.Seguridad.UsuarioDTO GetGrupos(string pvarUsuarioCod) { SqlConnection myConnection = IMDB.GetConnection(); SqlCommand myCommand = new SqlCommand("QRY_Permiso3", myConnection); myCommand.CommandType = CommandType.StoredProcedure; SqlDataReader datos; List <FuncionGrupoDTO> ListfuncionGrupo = new List <FuncionGrupoDTO>(); FuncionGrupoDTO theFuncionGrupo; FuncionDTO theFuncionDTO; YouCom.DTO.Seguridad.UsuarioDTO theOperador = new YouCom.DTO.Seguridad.UsuarioDTO(); theOperador.Grupo = new List <FuncionGrupoDTO>(); myCommand.Parameters.Add("@pUSU_RUT", SqlDbType.VarChar).Value = pvarUsuarioCod; try { myConnection.Open(); datos = myCommand.ExecuteReader(); while (datos.Read()) { theFuncionDTO = new FuncionDTO(); theFuncionGrupo = new FuncionGrupoDTO(); theFuncionGrupo.Funciones = new List <FuncionDTO>(); ListfuncionGrupo = new List <FuncionGrupoDTO>(); ///Carga Grupo theFuncionGrupo.FuncionGrupoCod = datos.GetInt32(0).ToString(); theFuncionGrupo.FuncionGrupoNombre = datos.GetString(1); theFuncionGrupo.FuncionGrupoTipo = datos.GetString(5); ///Carga Funcionalidades de Grupo y Funcionalidades Internas del Negocio theFuncionDTO.FuncionCod = datos.GetInt32(2).ToString(); theFuncionDTO.FuncionNombre = datos.GetString(3); theFuncionDTO.Url = datos.GetString(4); theFuncionDTO.FuncionalidadNegocio = datos.GetString(5); theFuncionGrupo.Funciones.Add(theFuncionDTO); // ListfuncionGrupo.Add(theFuncionGrupo); theOperador.Grupo.Add(theFuncionGrupo); } } catch (SqlException ex) { throw new Exception(ex.Message); } catch (Exception e) { throw new Exception(e.Message); } finally { myConnection.Close(); } return(theOperador); }
protected void Page_Load(object sender, EventArgs e) { this.LitFecha.Text = DateTime.Now.ToString("dddd dd/MM/yyyy tt"); this.LitHora.Text = DateTime.Now.ToString("HH:mm tt"); if (!IsPostBack) { myUsuario = (YouCom.DTO.Seguridad.UsuarioDTO)Session["usuario"]; this.LitUsuario.Text = myUsuario.NombreCompleto; ddlCondominio.DataSource = myUsuario.TheCondominioDTO; ddlCondominio.DataTextField = "NombreCondominio"; ddlCondominio.DataValueField = "IdCondominio"; ddlCondominio.DataBind(); if (myUsuario.TheCondominioDTO.Count == 1) { ddlCondominio.Enabled = false; } } }
protected void ValidarClaveEmpresa(string pRut, string pRutCondominio, string pPassword) { try { //Genero token para log YouCom.DTO.Seguridad.UsuarioDTO myUsuario = new YouCom.DTO.Seguridad.UsuarioDTO(); string retornoToken = YouCom.Service.Configuracion.General.getGeneraToken(HttpContext.Current.Server.HtmlEncode(pRut), HttpContext.Current.Server.HtmlEncode(pRutCondominio), HttpContext.Current.Server.HtmlEncode(pPassword)); myUsuario.Token_Usr = retornoToken; HttpContext.Current.Session["usuario"] = myUsuario; //Genero token para log string pass = string.Empty; string sXmlResponse = string.Empty; string rut = YouCom.Service.Configuracion.Formato.LimpiarRut(pRut).ToUpper(); string rut_empresa = YouCom.Service.Configuracion.Formato.LimpiarRut(pRutCondominio).ToUpper(); string grupo_cod = string.Empty; string pAmbiente = YouCom.Service.Parametrizacion.Parametros.GetConsultaParametros("AMBIENTE", "DISPONIBLE"); string pUrlAmbiente = YouCom.Service.Parametrizacion.Parametros.GetConsultaParametros("AMBIENTE", "URLNODISP"); if (pAmbiente.Equals("INFORMACIÓN NO CARGADA")) { Response.Redirect("ErrorClaveErronea.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } if (pPassword.Length == 4) { pass = pPassword.ToUpper(); } else { pass = pPassword; } if (pAmbiente == "1") { if (YouCom.Service.Configuracion.General.AuthenticateAdmin(Server.HtmlEncode(rut), Server.HtmlEncode(pass), ref sXmlResponse)) { myUsuario = (YouCom.DTO.Seguridad.UsuarioDTO)Session["usuario"]; string retorno = YouCom.Service.Configuracion.General.getGeneraToken(Server.HtmlEncode(rut), Server.HtmlEncode(rut_empresa), Server.HtmlEncode(pass)); myUsuario.Token_Usr = retorno; HttpContext.Current.Session["usuario"] = myUsuario; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, myUsuario.Rut, DateTime.Now, DateTime.Now.AddDays(1), // value of time out property false, // Value of IsPersistent property String.Empty, FormsAuthentication.FormsCookiePath); if (myUsuario.TheCondominioDTO.Count == 0) { string script = "var texto='Usted no tiene acceso para entrar a este portal.'; alert(texto);"; ScriptManager.RegisterStartupScript(this, this.GetType(), "trxErr", script, true); } else { FormsAuthentication.RedirectFromLoginPage(myUsuario.Rut, false); } } else { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sXmlResponse); Session.Add("RutCliente", rut); Session.Add("RutCondominio", rut_empresa); if (xmlDoc.SelectSingleNode("Error/ErrorCod").InnerText == "3") { Response.Redirect("funcionales/cambia_clave.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } else if (xmlDoc.SelectSingleNode("Error/ErrorCod").InnerText == "4") { Response.Redirect(YouCom.Service.Parametrizacion.Parametros.GetConsultaParametros("PUBLICO", "URLERRORBLOQ"), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } else { Response.Redirect("ErrorClaveErronea.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } } else { Response.Redirect(YouCom.Service.Parametrizacion.Parametros.GetConsultaParametros("AMBIENTE", "URLNODISP"), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } catch (Exception ex) { string script = "var texto='" + ex.Message + "'; alert(texto);"; ScriptManager.RegisterStartupScript(this, this.GetType(), "trxErr", script, true); } }
public static YouCom.DTO.Seguridad.UsuarioDTO AuntetificaUsuario(string usuario, string password) { SqlConnection myConnection = IMDB.GetConnection(); SqlCommand myCommand = new SqlCommand("QRY_Operador", myConnection); myCommand.CommandType = CommandType.StoredProcedure; SqlDataReader datos; YouCom.DTO.Seguridad.UsuarioDTO theOperadorDTO = new YouCom.DTO.Seguridad.UsuarioDTO(); string idEmpleado = string.Empty; myCommand.Parameters.Add("@pUsuario", SqlDbType.VarChar).Value = usuario; try { myConnection.Open(); datos = myCommand.ExecuteReader(); while (datos.Read()) { if (!datos.IsDBNull(0)) { theOperadorDTO.OperadorNro = int.Parse(datos.GetString(0).ToString().Substring(0, datos.GetString(0).ToString().Length - 1)); theOperadorDTO.Usuario = datos.GetString(0).ToString(); } if (!datos.IsDBNull(1)) { theOperadorDTO.Password = datos.GetString(1); } if (!datos.IsDBNull(2)) { theOperadorDTO.Fechapass = datos.GetDateTime(2); } if (!datos.IsDBNull(3)) { theOperadorDTO.IntentoFallidoFecha = datos.GetDateTime(3); } if (!datos.IsDBNull(4)) { theOperadorDTO.IntentoFallidoCant = datos.GetInt32(4); } if (!datos.IsDBNull(5)) { theOperadorDTO.Nombres = datos.GetString(5).ToString(); } if (!datos.IsDBNull(6)) { theOperadorDTO.Paterno = datos.GetString(6).ToString(); } if (!datos.IsDBNull(7)) { theOperadorDTO.Materno = datos.GetString(7).ToString(); } } if (theOperadorDTO.Password == password) { if (theOperadorDTO.IntentoFallidoCant >= 3) { throw new Exception("4|Estimado Cliente, Supero reintentos permitidos Usuario Bloqueado"); } else { ActIntentoFallidos(usuario, 0); } } else { theOperadorDTO.IntentoFallidoCant = theOperadorDTO.IntentoFallidoCant + 1; ActIntentoFallidos(usuario, Convert.ToInt16(theOperadorDTO.IntentoFallidoCant)); throw new Exception("2|El usuario o la contraseña son incorrectos."); ///usuario pass erroneas //return false } } catch (SqlException ex) { throw new Exception(ex.Message); } catch (Exception e) { throw new Exception(e.Message); } finally { myConnection.Close(); } return(theOperadorDTO); }
public List <YouCom.DTO.Seguridad.UsuarioDTO> LoginPrivado(string mvarUsuarioCod, string mvarPassword) { YouCom.DTO.Seguridad.UsuarioDTO theOperador = new YouCom.DTO.Seguridad.UsuarioDTO(); try { if (!string.IsNullOrEmpty(mvarUsuarioCod)) { theOperadorDTO = AuntetificaUsuario(mvarUsuarioCod, mvarPassword); IList <YouCom.DTO.FamiliaDTO> familia = new List <YouCom.DTO.FamiliaDTO>(); familia = YouCom.bll.FamiliaBLL.listaFamiliaActivo(); familia = familia.Where(x => x.RutFamilia == mvarUsuarioCod).ToList(); if (familia.Any()) { existe = true; } } else { throw new Exception("Debe indicarse UsuarioCod"); } if (existe) { List <FuncionGrupoDTO> grupos = new List <FuncionGrupoDTO>(); FuncionGrupoDTO theFuncionGrupoDTO = new FuncionGrupoDTO(); FuncionDTO theFuncionDTO; theOperador.Grupo = new List <FuncionGrupoDTO>(); theOperador = GetGrupos(theOperadorDTO.Usuario.ToString()); foreach (var item in grupos) { ///Carga Funciones de Menu General theFuncionGrupoDTO.FuncionGrupoCod = item.FuncionGrupoCod; theFuncionGrupoDTO.FuncionGrupoNombre = item.FuncionGrupoNombre; theFuncionGrupoDTO.FuncionGrupoTipo = item.FuncionGrupoTipo; theFuncionGrupoDTO.Funciones = new List <FuncionDTO>(); ///Carga Opciones de Menu y Configuracion de Negocio foreach (var opciones in item.Funciones) { theFuncionDTO = new FuncionDTO(); theFuncionDTO.FuncionGrupoCod = opciones.FuncionGrupoCod; theFuncionDTO.FuncionNombre = opciones.FuncionNombre; theFuncionDTO.FuncionTipoCod = opciones.FuncionTipoCod; theFuncionDTO.FuncionalidadNegocio = opciones.FuncionalidadNegocio; theFuncionDTO.Url = opciones.Url; theFuncionGrupoDTO.Funciones.Add(theFuncionDTO); } } theOperador.Usuario = theOperadorDTO.Usuario; theOperador.Nombres = theOperadorDTO.Nombres; theOperador.Paterno = theOperadorDTO.Paterno; theOperador.Materno = theOperadorDTO.Materno; theOperador.Grupo.Add(theFuncionGrupoDTO); operador.Add(theOperador); } else { throw new Exception("El usuario ingresado no pertenece a una comunidad"); } } catch (Exception eobjException) { throw new Exception(eobjException.Message); } return(operador); }