Beispiel #1
0
 public void Delete(IdPost fiche)
 {
     using (Conector.Fiche ficheConector = new Conector.Fiche())
     {
         ficheConector.DeleteFiche(fiche.id);
     }
 }
    /// <summary>
    /// This method sends a POST request to get the desired data to download and writes them in the created txt file
    /// Not usable in Web build
    /// </summary>
    /// <returns></returns>
    private IEnumerator Download()
    {
        dataMap   = new JsonMapObjects();
        dataMap.u = new List <string>();
        dataMap.w = new List <string>();
        dataMap.g = new List <string>();
        id        = 1;
        while (keepGoing)
        {
            var uwr = UnityWebRequest.Post(url, "POST");
            idObject = new IdPost(id.ToString());
            byte[] idToSend = new System.Text.UTF8Encoding().GetBytes(JsonUtility.ToJson(idObject));
            uwr.uploadHandler   = (UploadHandler) new UploadHandlerRaw(idToSend);
            uwr.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
            //uwr.SetRequestHeader("Content-Type", "application/json");

            //Send the request then wait here until it returns
            yield return(uwr.SendWebRequest());

            if (uwr.downloadHandler.text != "Id not existent")
            {
                Debug.Log(uwr.downloadHandler.text);
                gameDataMap        = JsonUtility.FromJson <MapReceived>(uwr.downloadHandler.text);
                gameDataMap.uknown = Regex.Replace(gameDataMap.uknown, @"[()]", "");
                gameDataMap.uknown = Regex.Replace(gameDataMap.uknown, @"[ ]", "");
                string[] u = gameDataMap.uknown.Split(',');
                uCell = new List <string>();
                if (u.Length >= 2) //just to be that two coordinates exists
                {
                    for (int i = 0; i < u.Length; i = i + 2)
                    {
                        //Debug.Log(positions[i] + " " + positions[i+1]);
                        uCell.Add(u[i] + "," + u[i + 1]);
                    }
                }
                gameDataMap.wall = Regex.Replace(gameDataMap.wall, @"[()]", "");
                gameDataMap.wall = Regex.Replace(gameDataMap.wall, @"[ ]", "");
                string[] w = gameDataMap.wall.Split(',');
                wCell = new List <string>();
                if (w.Length >= 2) // just to be sure that two coordinates exists
                {
                    for (int i = 0; i < w.Length; i = i + 2)
                    {
                        //Debug.Log(positions[i] + " " + positions[i+1]);
                        wCell.Add(w[i] + "," + w[i + 1]);
                    }
                }
                gameDataMap.goal = Regex.Replace(gameDataMap.goal, @"[()]", "");
                gameDataMap.goal = Regex.Replace(gameDataMap.goal, @"[ ]", "");
                string[] g = gameDataMap.goal.Split(',');
                gCell = new List <string>();
                if (g.Length >= 2) // just to be sure that two coordinates exists
                {
                    for (int i = 0; i < g.Length; i = i + 2)
                    {
                        gCell.Add(g[i] + "," + g[i + 1]);
                    }
                }
                dataMap.u = uCell;
                dataMap.w = wCell;
                dataMap.g = gCell;
                File.WriteAllText(downloadedContentPath + "/Result" + id.ToString() + "m.txt", JsonUtility.ToJson(dataMap));
                id++;
            }
            else
            {
                Debug.Log("Finished downloaded");
                keepGoing = false;
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// This method sends a POST request to get the desired data to download and writes them in the created txt file
    /// Not usable in Web build
    /// </summary>
    /// <returns></returns>
    private IEnumerator Download()
    {
        data           = new JsonRobotObjects();
        data.position  = new List <string>();
        data.rotationY = new List <float>();
        //data.time = new List<float>();
        //data.mapName = new List<string>();
        id = 1;
        while (keepGoing) //until there are other results to download
        {
            var uwr = UnityWebRequest.Post(url, "POST");
            idObject = new IdPost(id.ToString());
            byte[] idToSend = new System.Text.UTF8Encoding().GetBytes(JsonUtility.ToJson(idObject));
            uwr.uploadHandler   = (UploadHandler) new UploadHandlerRaw(idToSend);
            uwr.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
            //uwr.SetRequestHeader("Content-Type", "application/json");

            //Send the request then wait here until it returns
            yield return(uwr.SendWebRequest());

            if (uwr.downloadHandler.text != "Id not existent")
            {
                Debug.Log(uwr.downloadHandler.text);
                gameDataPos          = JsonUtility.FromJson <TrajectoryReceived>(uwr.downloadHandler.text);
                gameDataPos.position = Regex.Replace(gameDataPos.position, @"[()]", "");
                gameDataPos.position = Regex.Replace(gameDataPos.position, @"[ ]", "");
                string[] positions = gameDataPos.position.Split(',');
                pos = new List <string>();
                for (int i = 0; i < positions.Length; i = i + 2)
                {
                    pos.Add(positions[i] + "," + positions[i + 1]);
                }
                gameDataPos.rotation = Regex.Replace(gameDataPos.rotation, @"[()]", "");
                gameDataPos.rotation = Regex.Replace(gameDataPos.rotation, @"[ ]", "");
                string[] rotString = gameDataPos.rotation.Split(',');
                rot = new List <float>();
                for (int i = 0; i < rotString.Length; i++)
                {
                    rot.Add(float.Parse(rotString[i]));
                }
                gameDataPos.timerobot = Regex.Replace(gameDataPos.timerobot, @"[()]", "");
                gameDataPos.timerobot = Regex.Replace(gameDataPos.timerobot, @"[ ]", "");
                //string[] timeRob = gameDataPos.timerobot.Split(',');
                //time = new List<float>();
                //for (int i = 0; i < timeRob.Length; i++)
                //{
                //    time.Add(float.Parse(timeRob[i]));
                //}
                gameDataPos.mapname = Regex.Replace(gameDataPos.mapname, @"[()]", "");
                gameDataPos.mapname = Regex.Replace(gameDataPos.mapname, @"[ ]", "");
                //string[] name = gameDataPos.mapname.Split(',');
                //mName = new List<string>();
                //for (int i = 0; i < name.Length; i++)
                //{
                //    mName.Add(name[i]);
                //}
                data.position  = pos;
                data.rotationY = rot;
                data.time      = float.Parse(gameDataPos.timerobot);
                data.mapName   = gameDataPos.mapname;
                data.ip        = gameDataPos.ip;
                data.os        = gameDataPos.os;

                File.WriteAllText(downloadedContentPath + "/Result" + id.ToString() + "t.txt", JsonUtility.ToJson(data));

                WriteTupleLog(pos, rot, gameDataPos.mapname, id);

                id++;
            }
            else
            {
                Debug.Log("Finished download");
                keepGoing = false;
            }
        }
    }