Esempio n. 1
0
        /// <summary>
        /// Metodo que retorna el rut
        /// </summary>
        public static string returnRut()
        {
            string rut = MascarasEditText.limpiaRut(txtUsername.Text);

            return(rut);
        }
Esempio n. 2
0
        /// <summary>
        /// metodo el cual contiene el evento click del boton ingresar.
        /// </summary>
        private async void BtnIniciaSesion_Click(object sender, EventArgs e)
        {
            dialogoLoadingBcoSecurityActivity.mostrarViewLoadingSecurity();
            if (string.IsNullOrEmpty(txtUsername.Text) && string.IsNullOrEmpty(txtClave.Text))
            {
                lblMensaje.Text = "Error al ingresar los datos";
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (validarRut(txtUsername.Text) == false && txtUsername.Text.Trim().Length >= 1 && txtClave.Text.Trim().Length == 8)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lblMensaje.Text = "Error al ingresar los datos";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }

            else if (txtClave.Text.Trim().Length >= 1 && txtClave.Text.Trim().Length < 8 && validarRut(txtUsername.Text) == true)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Clave incorrecta";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (string.IsNullOrEmpty(txtClave.Text) && validarRut(txtUsername.Text) == true)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Clave incorrecta";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (string.IsNullOrEmpty(txtUsername.Text) && txtClave.Text.Trim().Length == 8)
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);

                lblMensaje.Text = "Error al ingresar los datos";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else if (txtClave.Text.Trim().Length <= 8 && !validarRut(txtUsername.Text))
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Error al ingresar los datos";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }

            else if (txtClave.Text.Trim().Length < 8 && validarRut(txtUsername.Text))
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                lblMensaje.Text = "Clave incorrecta";
                DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
            }
            else
            {
                lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.green);
                //lblMensaje.Text = "Cargando datos...";

                try
                {
                    idTokenFCM = MyFirebaseIIDService.SendRegistrationToServer();
                    var key = new Contenido()
                    {
                        Password = idTokenFCM
                    };

                    if (idTokenFCM != null)
                    {
                        DatabaseHelper.Insertar(ref key, ruta);
                    }
                    string    imei = this.getIMEI();
                    string    idDispositivoLogLogin   = parametriaLogUtil.getIdDispositivoParaLog(imei);
                    string    ipDisposiivoLogLogin    = ParametriaLogUtil.GetIpLocal();
                    JsonValue jsonResponseAccessToken = await WebServiceSecurity.ServiciosSecurity.CallRESTaccessToken();

                    JsonValue jt = jsonResponseAccessToken["access_token"];

                    string    rutServicio       = MascarasEditText.limpiaRut(txtUsername.Text);
                    JsonValue jsonResponseLogin = await WebServiceSecurity.ServiciosSecurity.CallRESTlogin(jt, rutServicio, txtClave.Text, SecurityEndpoints.userTypeWS_LOGIN, SecurityEndpoints.channelNameWS_LOGIN, idDispositivoLogLogin, ipDisposiivoLogLogin);

                    string jl = jsonResponseLogin["statusCode"];
                    if (jl.Equals("Success"))
                    {
                        string operationResult = jsonResponseLogin["operationResult"];
                        if (operationResult.Equals("Success_1"))
                        {
                            Intent i = new Intent(this, typeof(TerminoYCondicionesActivity));
                            StartActivity(i);
                        }
                        else if (operationResult.Equals("ErrorInvalidUser_4") ||
                                 operationResult.Equals("ErrorUserDeleted_7") ||
                                 operationResult.Equals("ErrorGenericError_8") ||
                                 operationResult.Equals("ErrorDocumentNumberWithInvalidFormat_9") ||
                                 operationResult.Equals("ErrorUserAndPasswordDoNotMatch_10") ||
                                 operationResult.Equals("InvalidChannel_11") ||
                                 operationResult.Equals("InvalidPassword_12") ||
                                 operationResult.Equals("NotMatchUserAndUserType_13") ||
                                 operationResult.Equals("ErrorCredentialNotAvailable_14") ||
                                 operationResult.Equals("SuccessPendingValidatePIN_15")
                                 )
                        {
                            CleaningEntryLogin();
                            DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
                            lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lblMensaje.Text = "Estimado cliente, usuario ingresado es invalido. Por favor ingréselo nuevamente.";
                        }
                        else if (operationResult.Equals("ErrorUserBlockedByPassword_5") ||
                                 operationResult.Equals("ErrorUserBlockedByAdministrator_6") ||
                                 operationResult.Equals("ErrorUserBlockedBySecurityQuestion_16") ||
                                 operationResult.Equals("ErrorUserBlockedByAttemptsPinActivation_17")
                                 )
                        {
                            CleaningEntryLogin();
                            DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
                            lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                            lblMensaje.Text = "Estimado Cliente, su clave se encuentra bloqueada. Por favor contáctese con el Servicio Atención Clientes Security +56 2 2222 2222.";
                        }
                        else
                        {
                            ExceptionGeneric();
                        }
                    }
                    else
                    {
                        lineTxtUsername.BackgroundTintList = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                        lineTxtClave.BackgroundTintList    = Android.Support.V4.Content.ContextCompat.GetColorStateList(ApplicationContext, Resource.Color.red);
                        lblMensaje.Text = "Error al ingresar los datos";
                        DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    ExceptionGeneric();
                }
            }
        }