Ejemplo n.º 1
0
    IEnumerator getActivities()
    {
        cont++;

        WWWForm form = new WWWForm();

        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("header-name", "header content");


        using (UnityWebRequest www = UnityWebRequest.Get("http://localhost:8000/api/getRehabprocessActivities/" + Manager.GetInstance().processRequests[cont].id))
        {
            www.SetRequestHeader("Authorization", Manager.GetInstance().userToken);
            www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            www.SetRequestHeader("Accept", "application/json");

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);

                //Manager.GetInstance().activitiesRequests.Clear();

                activitiesRootObject stringToken = JsonUtility.FromJson <activitiesRootObject>(www.downloadHandler.text);

                foreach (activitiesRequestSuccess request in stringToken.data)
                {
                    foreach (activitiesList activity in request.activities)
                    {
                        if (activity.date == System.DateTime.Now.ToString("yyyy-MM-dd") && activity.state == "Active")
                        {
                            contTodayActivities++;
                            contTotalActivities++;
                        }
                        else if (activity.date == System.DateTime.Now.ToString("yyyy-MM-dd") && activity.state != "Active")
                        {
                            contDoneActivities++;
                            contTotalActivities++;
                        }
                    }
                }

                if (cont == Manager.GetInstance().processRequests.Count - 1)
                {
                    setTexts();
                }
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator getActivities()
    {
        WWWForm form = new WWWForm();

        Dictionary <string, string> headers = new Dictionary <string, string>();

        headers.Add("header-name", "header content");


        using (UnityWebRequest www = UnityWebRequest.Get("http://localhost:8000/api/getRehabprocessActivities/" + Manager.GetInstance().processRequests[process.listPosition].id))
        {
            www.SetRequestHeader("Authorization", Manager.GetInstance().userToken);
            www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            www.SetRequestHeader("Accept", "application/json");

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);
                Manager.GetInstance().activitiesRequests.Clear();

                activitiesRootObject stringToken = JsonUtility.FromJson <activitiesRootObject>(www.downloadHandler.text);

                foreach (activitiesRequestSuccess request in stringToken.data)
                {
                    Manager.GetInstance().activitiesRequests.Add(request);
                }
                SceneManager.LoadScene("ActivityScreen");
            }
        }
    }