Ejemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (ValidateUser(txtUsuario.Text, txtContraseña.Text))
            {
                try
                {
                    using (CobranzasDataContext db = new CobranzasDataContext())
                    {
                        //if (txtUsuario.Text != ((WindowsIdentity)User.Identity).Name.Split('\\').Last()) { Sesion.Impersonando = true; }
                        Entidades.Operadores Op = db.Operadores.Single(x => x.Login == txtUsuario.Text);
                        if (!Op.Activo)
                        {
                            UI.Mensaje("Sistema de Cobranzas", "Usuario Inactivo, diríjase a su Supervisor", "", Page);
                            return;
                        }

                        //DataTable dt = new DataTable();
                        //IPHostEntry host;
                        //string localIP = "";
                        //host = Dns.GetHostEntry(Dns.GetHostName());
                        //foreach (IPAddress ip in host.AddressList)
                        //{
                        //    if (ip.AddressFamily.ToString() == "InterNetwork")
                        //    {
                        //        localIP = ip.ToString();
                        //    }
                        //}

                        //dt = Negocios.EstadoSesion(Op.idOperador, localIP);

                        //if (int.Parse((dt.Rows[0]).ItemArray[0].ToString()) == 0)
                        //{
                        //    UI.Mensaje("Sistema de Cobranzas", "Ya hay una sesion activa con este usuario", "", Page);
                        //    return;
                        //}



                        Sesion.Llenar(Op);

                        //if (!Sesion.Impersonando)
                        //{
                        //    Sesion.Actividad("LI");
                        //}
                    }
                    Response.Redirect("Gestion.aspx", true);
                }
                catch (Exception Ex)
                {
                    //Response.Write(Ex.Message);
                    //Ex.Registrar();
                    UI.Mensaje("Sistema de Cobranzas", "No se pudo iniciar sesión, usuario incorrecto o inexistente" + Ex.InnerException, "", Page);
                }
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        }
Ejemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (ValidateUser(txtUsuario.Text, txtContraseña.Text))
            {
                try
                {
                    using (CobranzasDataContext db = new CobranzasDataContext())
                    {
                        //if (txtUsuario.Text != ((WindowsIdentity)User.Identity).Name.Split('\\').Last()) { Sesion.Impersonando = true; }
                        Entidades.Operadores Op = db.Operadores.Single(x => x.Login == txtUsuario.Text);
                        if (!Op.Activo)
                        {
                            UI.Mensaje("Sistema de Cobranzas", "Usuario Inactivo, diríjase a su Supervisor", "", Page);
                            return;
                        }

                        Sesion.Llenar(Op);
                        if (!Sesion.Impersonando)
                        {
                            Sesion.Actividad("LI");
                        }
                    }
                    Response.Redirect("Gestion.aspx", true);
                }
                catch (Exception Ex)
                {
                    //Response.Write(Ex.Message);
                    //Ex.Registrar();
                    UI.Mensaje("Sistema de Cobranzas", "No se pudo iniciar sesión, usuario incorrecto o inexistente", "", Page);
                }
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        }