예제 #1
0
    // private bool _usuarioLogueado;
    // public bool usuarioLogueado
    // {
    //     get
    //     {
    //         return _usuarioLogueado;
    //     }
    //     set
    //     {
    //         _usuarioLogueado = value;
    //     }
    // }
    // private bool _logueoTerminado;
    // public bool logueoTerminado
    // {
    //     get
    //     {
    //         return _logueoTerminado;
    //     }
    //     set
    //     {
    //         _logueoTerminado = value;
    //     }
    // }

    // private bool _usuarioRegistrado;
    // public bool usuarioRegistrado
    // {
    //     get
    //     {
    //         return _usuarioRegistrado;
    //     }
    //     set
    //     {
    //         _usuarioRegistrado = value;
    //     }
    // }
    // private bool _registroTerminado;
    // public bool registroTerminado
    // {
    //     get
    //     {
    //         return _registroTerminado;
    //     }
    //     set
    //     {
    //         _registroTerminado = value;
    //     }
    // }
    public bool Logueo(string NombreUsuario, string Contrasena)
    {
        // string jsonPOST = "{" +
        //         "\"idtipologueologueo\":" + TiposLogueo.getIdTipoLogueo("Normal") + "," +
        //         "\"usuariologueo\": \"" + txt_usuario.text + "\"," +
        //         "\"contrasena\": \"" + txt_password.text + "\"" +
        //         "}";

        string respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/usuarios/" + NombreUsuario + "/" + Contrasena, "GET");

        if (respuesta == null)
        {
            Debug.Log("!!!Datos incorrectos");
            return(false);
        }
        JSONNode usuario = JSON.Parse(respuesta)["Usuario"];

        if (usuario != null)
        {
            Usuario.nombre            = usuario["Nombre"];
            Usuario.edad              = usuario["Edad"];
            Usuario.nombreUsuario     = usuario["Usuario"];
            Usuario.contrasenaUsuario = usuario["Contraseña"];
            Usuario.idUsuario         = usuario["Id"];
            Debug.Log("Usuario logueado: ");
            Debug.Log(usuario);
            return(true);
        }
        else
        {
            Debug.Log("!!!Datos incorrectos");
            return(false);
        }
    }
    private void AgregarRespuesta(int idRecorrido, int idPegunta, int respuestaPregunta)
    {
        string jsonPOST = "{" +
                          "\"IdRecorrido\":\"" + idRecorrido + "\"," +
                          "\"IdPregunta\":\"" + idPegunta + "\"," +
                          "\"Tiempo\":\"" + (int)Time.realtimeSinceStartup + "\"," +
                          "\"Respuesta\": " + respuestaPregunta +
                          "}";

        string respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/RespuestasTest", "POST", jsonPOST);

        if (respuesta == null)
        {
            Debug.Log("!!!Error creando respuesta");
        }
    }
예제 #3
0
    private string GetFTP()
    {
        String direccionFTP = _ftp;
        string respuesta    = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/ftp", "GET");

        if (respuesta != null)
        {
            JSONNode FTPJson = JSON.Parse(respuesta)["FTP"];
            if (FTPJson != null)
            {
                foreach (var ftp in FTPJson)
                {
                    direccionFTP = ftp.Value["Valor"];
                }
            }
        }

        return(direccionFTP);
    }
예제 #4
0
    public bool RegistrarUsuario(string NombreUsuario, string Contrasena, string Nombre, string Edad)
    {
        if (NombreUsuario == null || NombreUsuario == "" || Contrasena == null || Contrasena == "" ||
            Nombre == null || Nombre == "" || Edad == null || Edad == "")
        {
            Debug.Log("Para registrar no se pueden tener campos vacios");
            return(false);
        }
        string jsonPOST = "{" +
                          "\"Usuario\": \"" + NombreUsuario + "\"," +
                          "\"Contrasena\": \"" + Contrasena + "\"," +
                          "\"Nombre\": \"" + Nombre + "\"," +
                          "\"Edad\": \"" + Edad + "\"" +
                          "}";

        string respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/usuarios", "POST", jsonPOST);

        if (respuesta == null)
        {
            Debug.Log("!!!No se pudo hacer el registro");
            return(false);
        }

        JSONNode usuario = JSON.Parse(respuesta)["Usuario"];

        if (usuario != null)
        {
            Usuario.nombre            = usuario["Nombre"];
            Usuario.edad              = usuario["Edad"];
            Usuario.nombreUsuario     = usuario["Usuario"];
            Usuario.contrasenaUsuario = usuario["Contraseña"];
            Usuario.idUsuario         = usuario["Id"];
            Debug.Log("Usuario registrado: ");
            Debug.Log(usuario);
            return(true);
        }
        else
        {
            Debug.Log("!!!No se pudo hacer el registro");
            return(false);
        }
    }
예제 #5
0
    public bool CalificarImagen(int idImagen, int idRecorrido, int calificacion)
    {
        Debug.Log("Se calificará imagen " + idImagen + " del recorrido " + idRecorrido + " con calificacion " + calificacion);
        if (idImagen == 0 || idRecorrido == 0)
        {
            return(false);
        }
        string jsonPUT = "{" +
                         "\"IdRecorrido\": \"" + idRecorrido + "\"," +
                         "\"IdImagen\": \"" + idImagen + "\"," +
                         "\"Calificacion\": \"" + calificacion + "\"" +
                         "}";

        string respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/recorridos", "PUT", jsonPUT);

        if (respuesta == null)
        {
            Debug.Log("!!!No se pudo hacer la calificacion");
            return(false);
        }
        //Debug.Log(respuesta);
        return(true);
    }
예제 #6
0
    /// <summary>
    /// Se crea un recorrido nuevo en la base de datos con
    /// </summary>
    /// <returns></returns>
    public bool CrearNuevoRecorrido()
    {
        string respuesta = string.Empty;
        //Se debe obtener el nivel de violencia de preferencia para el usuarioy de acuerdo a este se le muestran las imágenes.
        //string nivelViolencia = "1";
        string nivelViolencia = string.Empty;

        //Si no se tiene un nivel de violencia de preferencia, se le muestran imágenes de cualquier nivel.
        if (!string.IsNullOrEmpty(nivelViolencia))
        {
            respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/imagenesRandom/" + cantidadImagenes + "/" + nivelViolencia, "GET");
        }
        else
        {
            respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/imagenesRandom/" + cantidadImagenes, "GET");
        }
        if (string.IsNullOrEmpty(respuesta))
        {
            Debug.Log("!!!Error creando el recorrido");
            return(false);
        }
        JSONNode listaImagenes     = JSON.Parse(respuesta)["Imagenes"];
        string   listaImagenesJSON = "[";

        if (listaImagenes != null)
        {
            foreach (var imagen in listaImagenes)
            {
                listaImagenesJSON += "\"" + imagen.Value["Id"] + "\"" + ",";
            }
            listaImagenesJSON  = listaImagenesJSON.TrimEnd(',');
            listaImagenesJSON += "]";

            int    idUsuario = Usuario.idUsuario;
            string jsonPOST  = "{" +
                               "\"IdUsuario\":\"" + idUsuario + "\"," +
                               "\"IdImagenes\": " + listaImagenesJSON +
                               "}";

            respuesta = ServicioREST.EjecutarOperacion(ServicioREST.direccionServicio + "/api/recorridos", "POST", jsonPOST);
            JSONNode recorrido = JSON.Parse(respuesta)["Recorrido"];
            Recorrido.fechaRecorrido = System.DateTime.Parse(recorrido["FechaRecorrido"]);
            Recorrido.id             = recorrido["Id"];
            JSONNode imagenes = recorrido["Imagenes"];
            if (Recorrido.listaImagenes == null)
            {
                Recorrido.listaImagenes = new List <Imagen>();
            }
            foreach (var imagen in imagenes)
            {
                Imagen img = new Imagen {
                    idImagen        = imagen.Value["IdImagen"],
                    direccionImagen = imagen.Value["DireccionImagen"],
                    nombreImagen    = imagen.Value["NombreImagen"],
                    calificacion    = imagen.Value["Calificacion"],
                };
                Recorrido.listaImagenes.Add(img);
            }
            return(true);
        }
        else
        {
            Debug.Log("!!!Error creando el recorrido");
            return(false);
        }
    }