예제 #1
0
        protected void btnlogin_Click(object sender, EventArgs e)
        {
            this.liScript.Text  = string.Empty;
            this.sError.Visible = false;
            base.ResolveUrl("~");
            this.login = this.AF_Login.Text;
            //Modificado 24/08/2018 por Liliana Guerra clave mayuscula
            //this.password = this.txtAF_Password.Text;
            this.password = this.txtAF_Password.Text.ToUpper();
            string empty = string.Empty;
            string str   = "~/frame.aspx";

            this.sError.Text = "Error en Usuario y/o Clave Personal";

            try
            {
                if (this.login.Trim().Length == 0)
                {
                    throw new Exception("El Código de usuario no puede ser blanco o nulo.");
                }
                if (this.password.Trim().Length == 0)
                {
                    throw new Exception("Debe ingresar la Clave");
                }
                this.oAfiliado = HelperAfiliado.AutenticarAfiliado(this.login, this.password, WebUtils.GetClientIP(this));
                if (this.oAfiliado != null)
                {
                    if (this.oAfiliado.AF_FechaPassword == new DateTime(2000, 1, 1))
                    {
                        this.Context.Items.Add("Afiliado", this.oAfiliado);
                        this.Context.Items.Add("type", "0");
                        base.Server.Transfer("~/pages/IB/Claves/CaducoClave.aspx");
                    }
                    else if ((this.oAfiliado.AF_DiasPassword == 0 ? false : DateAndTime.DateDiff(DateInterval.Day, this.oAfiliado.AF_FechaPassword, DateTime.Now) >= (long)this.oAfiliado.AF_DiasPassword))
                    {
                        this.Context.Items.Add("Afiliado", this.oAfiliado);
                        this.Context.Items.Add("type", "1");
                        base.Server.Transfer("~/pages/IB/Claves/CaducoClave.aspx");
                    }
                    SessionAfiliado sessionAfiliado = new SessionAfiliado();
                    try
                    {
                        sessionAfiliado = HelperSession.SA_CreateSession(this.oAfiliado.nAF_Id);
                    }
                    catch (IBException bException)
                    {
                        base.Response.Redirect("~/forcelogout.aspx", false);
                        return;
                    }
                    empty = "redirect.aspx";
                    this.oAfiliado.sIP = WebUtils.GetClientIP(this);
                    this.Session.Add("SessionID", sessionAfiliado.Sesion);
                    string[] strArrays = IBBAVConfiguration.SessionTimeOut.Split(new char[] { ':' });
                    int      num       = int.Parse(strArrays[0]) * 60 + int.Parse(strArrays[1]);
                    this.Session.Timeout = num / 60;
                    this.Session.Add("Afiliado", this.oAfiliado);
                    this.sError.Text = string.Empty;
                }
            }
            catch (IBException bException2)
            {
                IBException bException1 = bException2;
                this.txtAF_Password.Text = string.Empty;
                if (bException1.ReturnCode == "1000")
                {
                    StringBuilder stringBuilder = new StringBuilder(50);
                    stringBuilder.Append("<script language='javascript' type='text/javascript'>");
                    stringBuilder.Append("var w = window.open('pages/IB/Claves/RecuperarClave.aspx?restore=','restorepass','width=1100,height=768,menubar=0,resizable=0,toolbar=0,left=300,top=150');");
                    stringBuilder.Append("w.focus(); ");
                    stringBuilder.Append("</script>");
                    this.liScript.Text = stringBuilder.ToString();
                }
                else
                {
                    this.sError.Text    = bException1.IBMessage;
                    this.sError.Visible = true;
                    this.divmsg.Visible = true;
                    return;
                }
            }
            catch (Exception exception)
            {
                this.sError.Text    = exception.Message;
                this.sError.Visible = true;
                return;
            }
            if (!empty.Equals(string.Empty))
            {
                this.LogLoginSuccessfull();
                base.Response.Redirect(str);
            }
        }