async void btnLogin_Clicked(object sender, EventArgs e)
        {
            try
            {
                Loading(true);
                var foto = await ServicioImagen.TomarFoto();

                if (foto != null)
                {
                    imagen.Source = ImageSource.FromStream(foto.GetStream);

                    var faceId = await ServicioFace.DetectarRostro(foto.GetStream());

                    var personId = await ServicioFace.IdentificarEmpleado(faceId);

                    if (personId != Guid.Empty)
                    {
                        var bd      = new ServicioBaseDatos();
                        var usuario = await bd.ObtenerUsuario(personId.ToString());

                        usuario.FotoActual = foto.Path;

                        var emocion = await ServicioFace.ObtenerEmocion(foto);

                        usuario.EmocionActual = emocion.Nombre;
                        usuario.ScoreActual   = emocion.Score;
                        var update = await bd.ActualizarUsuario(usuario);

                        await DisplayAlert("Correcto", $"Bienvenido {usuario.Nombre}", "OK");

                        await Navigation.PushAsync(new PaginaBienvenido(usuario));
                    }
                    else
                    {
                        await DisplayAlert("Error", "Persona no identificada", "OK");
                    }
                }
                else
                {
                    await DisplayAlert("Error", "No se pudo tomar la fotografía.", "OK");
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                Loading(false);
            }
        }
예제 #2
0
 public void GuardarCambios()
 {
     try
     {
         string[] valores = FORMULARIO.NOMBREEMPLEADO.Split('-');
         FORMULARIO.IDEMPLEADO = Int32.Parse(valores[0]);
         if (ACCION == Modo.Insertar)
         {
             bbdd.InsertarUsuario(FORMULARIO);
         }
         else
         {
             bbdd.ActualizarUsuario(FORMULARIO);
         }
         FORMULARIO = new Usuario();
         USUARIOS   = bbdd.ObtenerUsuarios(false);
     }
     catch (Exception e)
     {
         throw new MisExcepciones(e.Message);
     }
 }