/// <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(); } } }
/// <summary> /// Metodo que retorna el rut /// </summary> public static string returnRut() { string rut = MascarasEditText.limpiaRut(txtUsername.Text); return(rut); }
public void OnTextChanged(ICharSequence s, int start, int before, int count) { if (tipoFormateador == TIPO_RUT) { textoFormateado = MascarasEditText.formatearRut(editText.Text); editText.RemoveTextChangedListener(this); // removemos el lister para no caer en loop infinito. editText.Text = textoFormateado; editText.AddTextChangedListener(this); editText.SetSelection(editText.Text.Length); // editText.SetRawInputType(InputTypes.NumberVariationNormal); //editText.InputType = Android.Text.InputTypes.TextVariationPassword; //| Android.Text.InputTypes.ClassNumber; editText.SetCursorVisible(true); } else if (tipoFormateador == TIPO_MONTO_PESOS) { textoFormateado = MascarasEditText.formatearMonto(editText.Text); editText.RemoveTextChangedListener(this); // removemos el lister para no caer en loop infinito. editText.Text = textoFormateado; editText.AddTextChangedListener(this); editText.SetSelection(editText.Text.Length); // editText.SetRawInputType(InputTypes.NumberVariationNormal); //editText.InputType = Android.Text.InputTypes.TextVariationPassword; //| Android.Text.InputTypes.ClassNumber; editText.SetCursorVisible(true); } else if (tipoFormateador == TIPO_MONTO_USD) { string dolar = editText.Text; if (dolar.Equals("0.0")) { dolar = "0,00"; } dolar = dolar.Replace(",", ""); if (dolar.Trim().Length >= 3) { dolar = dolar.Replace(".0", ""); int tam_var = dolar.Length; string decimalDolar = dolar.Substring((tam_var - 2), 2); dolar = dolar.Replace(dolar.Substring((tam_var - 2), 2), ""); dolar = dolar + "," + decimalDolar; montoDolar = dolar.Split(','); montoDolarEntero = montoDolar[0]; montoDolarDecimal = montoDolar[1]; if (!dolar.Contains(",")) { montoDolarEntero = dolar; } } else if (dolar.Trim().Length == 2) { dolar = dolar.Replace(".0", ""); dolar = dolar.Replace(",", ""); int tam_var = dolar.Length; string decimalDolar = dolar.Substring((tam_var - 1), 1); dolar = dolar.Replace(dolar.Substring((tam_var - 1), 1), ""); dolar = dolar + "," + decimalDolar; montoDolar = dolar.Split(','); montoDolarEntero = montoDolar[0]; montoDolarDecimal = montoDolar[1]; if (!dolar.Contains(",")) { montoDolarEntero = dolar; } } else if (dolar.Trim().Length == 1) { montoDolarDecimal = string.Empty; dolar = dolar.Replace(",", ""); dolar = dolar + string.Empty; if (!dolar.Contains(",")) { montoDolarEntero = dolar; } } else if (dolar.Trim().Length == 0) { montoDolarEntero = string.Empty; dolar = dolar + string.Empty; if (!dolar.Contains(",")) { montoDolarEntero = dolar; } } textoFormateado = MascarasEditText.formatearMontoDolar(montoDolarEntero, montoDolarDecimal); editText.RemoveTextChangedListener(this); // removemos el lister para no caer en loop infinito. editText.Text = textoFormateado; string editTextFormateado = editText.Text; string[] div; string montoDolarEnt = string.Empty; string montoDolarDec = string.Empty; editText.AddTextChangedListener(this); div = editTextFormateado.Split(','); montoDolarEnt = div[0]; montoDolarDec = div[1]; editText.SetSelection(editText.Text.Length); if (montoDolarDec.Trim().Length >= 3) { editText.SetSelection(editText.Text.Length - 3); } // editText.SetRawInputType(InputTypes.NumberVariationNormal); //editText.InputType = Android.Text.InputTypes.TextVariationPassword; //| Android.Text.InputTypes.ClassNumber; editText.SetCursorVisible(true); } }