示例#1
0
    private IEnumerator corout_SendEncuesta()
    {
        Dictionary <string, string> headers = new Dictionary <string, string> ();

        headers.Add("Content-Type", "application/json");
        headers.Add("Cookie", "Interceramic");
        headers.Add("Authorization", "Bearer " + token.Token);
        headers.Add("pClaveApp", claveApp);

        RespuestaJ resp = new RespuestaJ();

        resp.contacto_id    = PlayerPrefs.GetInt("UserId");
        resp.claveApp       = claveApp;
        resp.detencuesta_id = encuesta.DETENCUESTA_ID;
        RespuestasArrJ[] respuestas = new RespuestasArrJ[PreguntasRef.Count];
        for (int i = 0; i < PreguntasRef.Count; i++)
        {
            respuestas[i] = new RespuestasArrJ();
            if (PreguntasRef[i].GetComponent <Comentario> () != null)
            {
                respuestas[i].preg_id      = PreguntasRef[i].GetComponent <Comentario> ().Id;
                respuestas[i].detopcion_id = PreguntasRef[i].GetComponent <Comentario> ().detopcion_id;
                respuestas[i].comentario   = PreguntasRef[i].GetComponent <Comentario> ().comentario;
            }
            else
            {
                respuestas[i].preg_id      = PreguntasRef[i].GetComponent <OpcionMultiple> ().Id;
                respuestas[i].detopcion_id = PreguntasRef[i].GetComponent <OpcionMultiple> ().detopcion_id;
            }
        }
        resp.respuestas = respuestas;

        string SData = JsonUtility.ToJson(resp);

        byte[] JData = Encoding.ASCII.GetBytes(SData.ToCharArray());

        WWW www = new WWW(SendEncuestaURL, JData, headers);

        yield return(www);

        Andre.Log("Encuesta resp: " + www.text);

        MainCanvas.hidePopUp(2);
        MainCanvas.popUps [2].GetComponent <LoadingManager> ().stopSpinning();

        MainCanvas.GetComponent <LogIn> ().logInNotSuccess("Agradecemos tus comentarios");
        MainCanvas.GetComponent <ViewsManager> ().esconderEncuesta();
    }