コード例 #1
0
ファイル: GetPhpData.cs プロジェクト: IamDantt/Sumar
    IEnumerator login(string studentcode)
    {
        WWWForm form = new WWWForm();

        form.AddField("code_estudiante", studentcode);

        using (UnityWebRequest www = UnityWebRequest.Post("https://campus.eduriot.com/php/enviar_actividades.php", form))
        {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                SfxManager.sfxInstance.Audio.PlayOneShot(SfxManager.sfxInstance.Alert);
                Debug.Log(www.error);
                info.text = "Error de acceso";
            }
            else
            {
                jsonData jsnData = JsonUtility.FromJson <jsonData>("https://campus.eduriot.com/php/enviar_actividades.php");

                Debug.Log(www.downloadHandler.text);

                foreach (ActividadesList x in jsnData.actividades)
                {
                    Debug.Log("Nombre Actividad " + x.nombre);
                    Debug.Log("Disponibilidad " + x.disponible);
                    Debug.Log("Calificación " + x.calificacion);
                }
                //DrawUI();
                //NameUser.text = studentcode.ToString();
            }
        }
    }
コード例 #2
0
ファイル: PreguntasJson.cs プロジェクト: IamDantt/Sumar
    private void processJsonData(string _url)
    {
        GameObject buttonTemplate = transform.GetChild(0).gameObject;
        GameObject g;


        jsonData jsnData = JsonUtility.FromJson <jsonData>(_url);



        foreach (ActividadesList x in jsnData.actividades)
        {
            g = Instantiate(buttonTemplate, transform);
            // g.transform.GetChild(0).GetComponent<Text>().text = x.nombre;


            for (int d = 0; d < x.nombre.Length; d++)
            {
                for (int j = 0; j < x.preguntas.Count; j++)
                {
                    g.transform.GetChild(j + 1).GetComponent <Text>().text = x.preguntas[j];
                }
            }
        }
        Destroy(buttonTemplate);
    }
コード例 #3
0
    IEnumerator getTmg(string _url)
    {
        jsonData jsnData = JsonUtility.FromJson <jsonData>(_url);

        //GameObject buttonTemplate = transform.GetChild(0).gameObject;
        //GameObject g;


        //Debug.Log(_url);

        foreach (ActividadesList x in jsnData.actividades)
        {
            Debug.Log("Nombre " + x.nombre);



            for (int i = 0; i < x.url_img.Count; i++)
            {
                Debug.Log("url" + x.url_img.Count);
                //g = Instantiate(buttonTemplate, transform);
                //for (int j = 0; j < x.img.Count; j++)
                //{


                // GameObject InObject = new GameObject();
                // Image image = InObject.AddComponent<Image>();



                UnityWebRequest req = UnityWebRequestTexture.GetTexture(x.url_img[i]);
                yield return(req.SendWebRequest());

                if (req.isNetworkError || req.isHttpError)
                {
                    Debug.Log(req.error);
                }
                else
                {
                    Texture2D img = ((DownloadHandlerTexture)req.downloadHandler).texture;
                    image.sprite = Sprite.Create(img, new Rect(0, 0, img.width, img.height), Vector2.zero);
                    image.transform.GetComponent <Image>().sprite = image.sprite;
                    //g.transform.GetChild(0).GetComponent<Image>().sprite = image.sprite;
                }



                // }

                //Debug.Log("URL" + x.img[i]);
            }
        }

        // Destroy(buttonTemplate);
    }
コード例 #4
0
ファイル: PreguntasManager.cs プロジェクト: IamDantt/Sumar
    private void processJsonData(string _url)
    {
        jsonData jsnData = JsonUtility.FromJson <jsonData>(_url);

        GameObject buttonTemplate2 = transform.GetChild(0).gameObject;
        GameObject B;



        foreach (ActividadesList x in jsnData.actividades)
        {
            for (int j = 0; j < x.preguntas.Count; j++)
            {
                B = Instantiate(buttonTemplate2, transform);
            }
            Destroy(buttonTemplate2);
        }
    }
コード例 #5
0
ファイル: StationJson.cs プロジェクト: EricTaiwan/CGI2020
        public List <jsonData> GetStatonPIEs(string jsonFilePath)
        {
            // 1. 讀取路徑內檔案
            DirectoryInfo dir = new DirectoryInfo(jsonFilePath);

            FileInfo[] files = dir.GetFiles("*", SearchOption.AllDirectories);

            List <jsonData> stationjasonData = new List <jsonData>();

            // 2. 讀取 staion 資料
            foreach (FileInfo file in files)
            {
                // 2. read 所有設定
                using (StreamReader r = new StreamReader(file.FullName))
                {
                    string   json2  = r.ReadToEnd();
                    jsonData items2 = JsonConvert.DeserializeObject <jsonData>(json2);
                    stationjasonData.Add(items2);
                }
            }

            return(stationjasonData);
        }
コード例 #6
0
        /// <summary>
        /// 最新的 查询文件
        /// </summary>
        /// <param name="monitorFileName"></param>
        /// <param name="monitorServerID"></param>
        /// <param name="dirname"></param>
        /// <param name="pindex"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public ActionResult Search_new(string monitorFileName, string monitorServerID, int pindex)
        {
            string result = string.Empty;

            //判断用户是否登陆
            if (Session["LoginId"] == null)
            {
                result = "-99";
            }
            else
            {
                #region 根据条件查询 并 拼凑html (xiecongwen 20141203
                object loginId  = Session["LoginId"];
                string username = loginId as string;
                //save
                try
                {
                    //get the pagesize
                    int pagesize = 20;
                    //max entry count that should be search
                    int maxSize = 200;

                    #region 根据条件查询
                    //get the result match the condition
                    FileDownloadService fds = new FileDownloadService();
                    budbackup.Models.DownloadSearchResult ds = null;
                    //check session
                    object dsr = Session["DownloadSearchResult"];
                    if (dsr != null)
                    {
                        budbackup.Models.DownloadSearchResult dstemp = dsr as budbackup.Models.DownloadSearchResult;
                        if (dstemp.SearchPattern.Equals(monitorFileName) && dstemp.MonitorServerID.Equals(monitorServerID))
                        {
                            ds = dstemp;
                        }
                    }

                    //get from db
                    if (ds == null)
                    {
                        ds = fds.GetMatchList(monitorFileName, monitorServerID, maxSize, username);
                        //save into session
                        if (ds != null && ds.Count > 0)
                        {
                            ds.SearchPattern   = monitorFileName;
                            ds.MonitorServerID = monitorServerID;
                            Session["DownloadSearchResult"] = ds;
                        }
                    }
                    #endregion

                    #region 拼凑html语句
                    jsonData jd = new jsonData();

                    StringBuilder tableTR = new StringBuilder();
                    if (ds != null && ds.Count > 0)
                    {
                        string fileTRFormat = "<tr>" +
                                              "           <td class=\"cel1\" style=\"text-align:center;line-height:28px;\"><input type=\"checkbox\" value='{0}' class=\"filePath\" name=\"monitorFileLocalPath[]\" title=\"{4}\"/></td>" +
                                              "           <td class=\"cel2\">{1}</td>" +
                                              "           <td class=\"cel2\">{2}</td>" +
                                              "           <td class=\"cel3\">{3}</td>" +
                                              //"           <td class=\"cel4\">{4}</td>" +
                                              "       </tr>";
                        #region resolve get the page

                        int min = (pindex - 1) * pagesize;
                        int max = pindex * pagesize - 1;

                        int folderListCount = ds.FolderInfoList.Count;
                        //folder フォルダー
                        while (folderListCount > min)
                        {
                            if (min > max)
                            {
                                break;
                            }

                            budbackup.Models.DFolderInfo dfi = ds.FolderInfoList[min];
                            //dfi.MacPath.Replace(@"\", @"\\") escape
                            tableTR.Append(string.Format(fileTRFormat, dfi.WinPath.Replace(@"\", @"\\"), "フォルダー", dfi.Name, dfi.MacPath.Replace(@"\", @"\\"), min));

                            min++;
                        }

                        //file ファイル
                        if (max > folderListCount)
                        {
                            min -= folderListCount;
                            max -= folderListCount;
                            while (ds.FileInfoList.Count > min)
                            {
                                if (min > max)
                                {
                                    break;
                                }

                                budbackup.Models.DFileInfo dfi = ds.FileInfoList[min];

                                tableTR.Append(string.Format(fileTRFormat, dfi.WinPath.Replace(@"\", @"\\"), "ファイル", dfi.Name, dfi.MacPath.Replace(@"\", @"\\"), min + folderListCount));

                                min++;
                            }
                        }
                        //page element
                        int pageCount = (ds.Count + pagesize - 1) / pagesize;
                        jd.Add("logList", tableTR.ToString())
                        .Add("pageCount", pageCount)
                        .Add("pindex", pindex)
                        .Add("totalCount", ds.Count);

                        #endregion
                    }
                    else
                    {
                        tableTR.Append("<tr><td colspan=\"5\" style=\"text-align:center;line-height:28px;\">データがありません。</td></tr>");
                        jd.Add("logList", tableTR.ToString())
                        .Add("pageCount", 0)
                        .Add("pindex", pindex)
                        .Add("totalCount", 0);
                    }


                    result = jd.ToString();

                    #endregion
                }
                catch (Exception ex)
                {
                    result = "-10";
                    logger.Error(ex.Message);
                }
                #endregion
            }

            Response.Write(result);
            Response.End();

            return(null);
        }
コード例 #7
0
        public ActionResult Search(string monitorFileName, string monitorServerID, string dirname, int pindex, int pagesize)
        {
            string result = string.Empty;

            //session
            if (Session["LoginId"] == null)
            {
                result = "-99";
            }
            else
            {
                //save
                try
                {
                    //特殊字符转为全角再检索——2014-8-29 wjd add
                    monitorFileName = this.ConvertToDoubleByteChar(monitorFileName);

                    //whether download file from local machine.
                    string localIP = Common.CommonUtil.GetLocalIP();

                    CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;
                    //IList<MonitorFileListen> MonitorFileListens = msSerivice.GetMonitorFileListenList(monitorFileListen.monitorFileName, Convert.ToInt32(monitorFileListen.monitorServerID));
                    //folder
                    IList <MonitorFileListen> MonitorFileFolderListens = msSerivice.GetMonitorFileListenListByPage(monitorFileName, monitorServerID, "1", pindex, pagesize);
                    int    foldertotalCount = msSerivice.GetMonitorFileListenListCount(monitorFileName, monitorServerID, "1");
                    int    folderpageCount  = (int)Math.Ceiling((double)foldertotalCount / pagesize) == 0 ? 1 : (int)Math.Ceiling((double)foldertotalCount / pagesize);
                    int    filetotalCount   = msSerivice.GetMonitorFileListenListCount(monitorFileName, monitorServerID, "0");
                    int    totalCount       = foldertotalCount + filetotalCount;
                    int    pageCount        = (int)Math.Ceiling((double)totalCount / pagesize);
                    string tableTR          = "";
                    if ((foldertotalCount > 0 && foldertotalCount < pindex * pagesize) || (foldertotalCount >= pindex * pagesize))
                    {
                        if (MonitorFileFolderListens.Count > 0)
                        {
                            string fileTR = "";
                            fileTR = "<tr>" +
                                     "           <td class=\"cel1\" style=\"text-align:center;line-height:28px;\"><input type=\"checkbox\" value='@monitorFileLocalPath' class=\"filePath\" name=\"monitorFileLocalPath[]\" title=\"@id\"/></td>" +
                                     "           <td class=\"cel2\">フォルダー</td>" +
                                     "           <td class=\"cel2\">@monitorFileName</td>" +
                                     "           <td class=\"cel3\">@monitorFileFullPath</td>" +
                                     "           <td class=\"cel4\">@updateDate</td>" +
                                     "       </tr>";
                            string tr;
                            //用于处理重复消息 (当更新文件内容时,会产生多个消息)
                            var knownKeys = new HashSet <string>();
                            for (int i = 0; i < MonitorFileFolderListens.Count; i++)
                            {
                                string monitorFileDirectory = "\\\\" + MonitorFileFolderListens[i].monitorServerIP + "\\" + MonitorFileFolderListens[i].sharePoint + MonitorFileFolderListens[i].monitorFileRelativeDirectory;
                                string monitorFileFullPath  = "\\\\" + MonitorFileFolderListens[i].monitorServerIP + "\\" + MonitorFileFolderListens[i].sharePoint + MonitorFileFolderListens[i].monitorFileRelativeFullPath;
                                //2014-06-04 wjd modified
                                string monitorLocalPath = MonitorFileFolderListens[i].monitorLocalPath + MonitorFileFolderListens[i].monitorFileRelativeFullPath;

                                //folder name
                                int startIndex = Compare.LastIndexOf(monitorFileDirectory, "\\" + monitorFileName, CompareOptions.IgnoreCase);
                                //int startIndex = MonitorFileFolderListens[i].monitorFileDirectory.IndexOf("\\"+monitorFileName);
                                string name     = monitorFileDirectory.Substring(startIndex).Trim('\\');
                                int    endIndex = name.IndexOf("\\") == -1 ? name.Length : name.IndexOf("\\");
                                MonitorFileFolderListens[i].monitorFileName = name.Substring(0, endIndex);
                                //folder local path
                                monitorLocalPath = monitorLocalPath.Replace("\\", "\\\\");
                                startIndex       = Compare.LastIndexOf(monitorLocalPath, "\\" + monitorFileName, CompareOptions.IgnoreCase);
                                //startIndex = MonitorFileFolderListens[i].monitorFileLocalPath.IndexOf("\\" + monitorFileName);
                                monitorLocalPath = monitorLocalPath.Substring(0, startIndex);
                                monitorLocalPath = monitorLocalPath + "\\" + MonitorFileFolderListens[i].monitorFileName;

                                if (!knownKeys.Add(monitorLocalPath))
                                {
                                    continue;
                                }

                                //folder full path
                                monitorFileFullPath = monitorFileFullPath.Replace("\\", "\\\\");
                                startIndex          = Compare.LastIndexOf(monitorFileFullPath, "\\" + monitorFileName, CompareOptions.IgnoreCase);
                                //startIndex = MonitorFileFolderListens[i].monitorFileFullPath.IndexOf("\\" + monitorFileName);
                                monitorFileFullPath = monitorFileFullPath.Substring(0, startIndex);
                                monitorFileFullPath = monitorFileFullPath + "\\" + MonitorFileFolderListens[i].monitorFileName;
                                tr = fileTR;
                                tr = tr.Replace("@updateDate", MonitorFileFolderListens[i].updateDate);
                                tr = tr.Replace("@monitorFileFullPath", monitorFileFullPath);
                                tr = tr.Replace("@monitorFileName", MonitorFileFolderListens[i].monitorFileName);

                                //非本地时,路径为:DBServerIP + monitorLocalPath中的最后目录(已共享的目录)+ monitorFileRelativeFullPath
                                tr = tr.Replace("@monitorFileLocalPath", localIP.Equals(MonitorFileFolderListens[i].DBServerIP) ? monitorLocalPath : MonitorFileFolderListens[i].DBServerIP
                                                + (MonitorFileFolderListens[i].monitorLocalPath.Substring(MonitorFileFolderListens[i].monitorLocalPath.LastIndexOf("\\")) + MonitorFileFolderListens[i].monitorFileRelativeDirectory).Replace("\\", "\\\\"));

                                tr      = tr.Replace("@id", MonitorFileFolderListens[i].id);
                                tr      = tr.Replace("@monitorServerID", MonitorFileFolderListens[i].monitorServerID);
                                tableTR = tableTR + tr;
                            }
                        }
                    }
                    if (filetotalCount > 0 && foldertotalCount < pindex * pagesize)
                    {
                        int pindex2 = pindex - folderpageCount + 1;
                        pagesize = pagesize - MonitorFileFolderListens.Count;
                        //file
                        IList <MonitorFileListen> MonitorFileListens = msSerivice.GetMonitorFileListenListByPage(monitorFileName, monitorServerID, "0", pindex2, pagesize);
                        if (MonitorFileListens.Count > 0)
                        {
                            string fileTR = "";
                            fileTR = "<tr>" +
                                     "           <td class=\"cel1\" style=\"text-align:center;line-height:28px;\"><input type=\"checkbox\" value='@monitorFileLocalPath' class=\"filePath\" name=\"monitorFileLocalPath[]\" title=\"@id\"/></td>" +
                                     "           <td class=\"cel2\">ファイル</td>" +
                                     "           <td class=\"cel2\">@monitorFileName</td>" +
                                     "           <td class=\"cel3\">@monitorFileFullPath</td>" +
                                     "           <td class=\"cel4\">@updateDate</td>" +
                                     "       </tr>";
                            string tr;
                            for (int i = 0; i < MonitorFileListens.Count; i++)
                            {
                                string monitorFileDirectory = "\\\\" + MonitorFileListens[i].monitorServerIP + "\\" + MonitorFileListens[i].sharePoint + MonitorFileListens[i].monitorFileRelativeDirectory;
                                //2014-06-04 wjd modified
                                string monitorFileFullPath = "\\\\" + MonitorFileListens[i].monitorServerIP + "\\" + MonitorFileListens[i].sharePoint + MonitorFileListens[i].monitorFileRelativeFullPath;
                                string monitorLocalPath    = MonitorFileListens[i].monitorLocalPath + MonitorFileListens[i].monitorFileRelativeFullPath;

                                monitorLocalPath    = monitorLocalPath.Replace("\\", "\\\\");
                                monitorFileFullPath = monitorFileFullPath.Replace("\\", "\\\\");
                                tr = fileTR;
                                tr = tr.Replace("@updateDate", MonitorFileListens[i].updateDate);
                                tr = tr.Replace("@monitorFileFullPath", monitorFileFullPath);
                                tr = tr.Replace("@monitorFileName", MonitorFileListens[i].monitorFileName);

                                //非本地时,路径为:DBServerIP + monitorLocalPath中的最后目录(已共享的目录)+ monitorFileRelativeFullPath
                                tr = tr.Replace("@monitorFileLocalPath", localIP.Equals(MonitorFileListens[i].DBServerIP) ? monitorLocalPath : MonitorFileListens[i].DBServerIP
                                                + (MonitorFileListens[i].monitorLocalPath.Substring(MonitorFileListens[i].monitorLocalPath.LastIndexOf("\\")) + MonitorFileListens[i].monitorFileRelativeFullPath).Replace("\\", "\\\\"));

                                tr      = tr.Replace("@id", MonitorFileListens[i].id);
                                tr      = tr.Replace("@monitorServerID", MonitorFileListens[i].monitorServerID);
                                tableTR = tableTR + tr;
                            }
                        }
                    }
                    jsonData jd = new jsonData();
                    if (tableTR == "")
                    {
                        tableTR = "<tr><td colspan=\"5\" style=\"text-align:center;line-height:28px;\">データがありません。</td></tr>";
                    }
                    jd.Add("logList", tableTR)
                    .Add("pageCount", pageCount)
                    .Add("pindex", pindex)
                    .Add("totalCount", totalCount);
                    result = jd.ToString();
                    //result = JsonHelper.GetJson(MonitorFileListens);
                }
                catch (Exception ex)
                {
                    result = "-10";
                    logger.Error(ex.Message);
                }
            }
            Response.Write(result);
            Response.End();
            return(null);
        }
コード例 #8
0
 public static void Main()
 {
     string   s   = "{ \"10v_module\": 1, \"core_module\": 2 }";
     jsonData obj = JsonConvert.DeserializeObject <jsonData>(s);
 }
コード例 #9
0
ファイル: LogController.cs プロジェクト: hst-bridge/BBS
        public ActionResult ReadConLog(int pindex, int pagesize, string groupId, string dtStart, string dtEnd, string tmStart, string tmEnd, int displayFlg, int transferFlg, int stateFlg, int logFlg, string name)
        {
            string              strResult       = string.Empty;
            IList <Log>         logList         = new List <Log>();
            IList <TransferLog> transferLogList = new List <TransferLog>();

            try
            {
                tmStart = startTimeFormat(tmStart);
                tmEnd   = endTimeFormat(tmEnd);
                if (logFlg == 0)
                {
                    //logList = logService.GetLogListByProc(groupId, dtStart, dtEnd, tmStart, tmEnd, displayFlg, transferFlg, stateFlg, logFlg);
                    logList = logService.GetLogListByProc(pindex, pagesize, groupId, dtStart, dtEnd, tmStart, tmEnd, displayFlg, transferFlg, stateFlg, logFlg, name);
                    int totalCount = 0;
                    foreach (Log l in logList)
                    {
                        totalCount = l.totalCount;
                        break;
                    }
                    if (logList != null && logList.Count > 0)
                    {
                        string tableTR = "";
                        string logTR   = "";
                        logTR = "<tr><td class=\"cel1\">@trId</td>" +
                                "           <td class=\"cel2\"><div style=\"width:200px;word-break:break-all; word-wrap:break-word;overflow: auto;\">@backupServerFileName</div></td>" +
                                "           <td class=\"cel3\"><div style=\"width:400px;word-break:break-all; word-wrap:break-word;overflow: auto;\">@backupServerFilePath</div></td>" +
                                "           <td class=\"cel4\">@backupServerFileSize Byte</td>" +
                                //"           <td class=\"cel5\">@copyStartTime</td>" +
                                //"           <td class=\"cel6\">@copyEndTime</td>" +
                                "           <td class=\"cel7\">@backupStartTime</td>" +
                                //"           <td class=\"cel8\">@backupEndTime</td>" +
                                "           <td class=\"cel9\" style=\"display: none;\">@backupTime秒</td>" +
                                "           <td class=\"cel10\">@state</td>" +
                                "           <td class=\"cel11\">@status</td>" +
                                "       </tr>";
                        string tr;
                        for (int i = 0; i < logList.Count; i++)
                        {
                            logList[i].monitorFilePath = logList[i].monitorFilePath.Replace("\\", "\\\\");
                            tr = logTR;
                            tr = tr.Replace("@backupServerFileSize", logList[i].backupServerFileSize);
                            //tr = tr.Replace("@copyStartTime", logList[i].copyStartTime);
                            //tr = tr.Replace("@copyEndTime", logList[i].copyEndTime);
                            tr = tr.Replace("@backupStartTime", logList[i].backupStartTime);
                            //tr = tr.Replace("@backupEndTime", logList[i].backupEndTime);
                            tr      = tr.Replace("@backupTime", logList[i].backupTime);
                            tr      = tr.Replace("@trId", (i + 1 + (pindex - 1) * pagesize).ToString());
                            tr      = tr.Replace("@state", logList[i].backupFlg == 1 ? "OK" : "NG");
                            tr      = tr.Replace("@backupServerFileName", logList[i].monitorFileName);
                            tr      = tr.Replace("@backupServerFilePath", logList[i].monitorFilePath);
                            tr      = tr.Replace("@status", logList[i].monitorFileStatus);
                            tableTR = tableTR + tr;
                        }

                        //strResult = JsonHelper.GetJson<IList<Log>>(logList);
                        int      pageCount = (int)Math.Ceiling((double)totalCount / pagesize);
                        Object   obj       = new Object();
                        jsonData jd        = new jsonData();
                        jd.Add("logList", tableTR)
                        .Add("pageCount", pageCount)
                        .Add("pindex", pindex)
                        .Add("totalCount", totalCount);

                        strResult = jd.ToString();
                    }
                }
                else
                {
                    transferLogList = transferLogService.GetTransferLogListByProc(pindex, pagesize, groupId, dtStart, dtEnd, tmStart, tmEnd, displayFlg, transferFlg, stateFlg, logFlg, name);
                    if (transferLogList != null && transferLogList.Count > 0)
                    {
                        strResult = JsonHelper.GetJson <IList <TransferLog> >(transferLogList);
                    }
                }
            }

            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            Response.Write(strResult);
            Response.End();
            return(null);
        }
コード例 #10
0
    //867849521

    private void processJsonData(string _url)
    {
        jsonData jsnData = JsonUtility.FromJson <jsonData>(_url);

        //Debug.Log(_url);

        //Debug.Log(jsnData.nombre + " " + jsnData.apellido);
        nombre.text = jsnData.nombre.ToString() + " " + jsnData.apellido.ToString();

        //Debug.Log(jsnData.descripcion);

        foreach (ActividadesList x in jsnData.actividades)
        {
            //Debug.Log("nombre actividad " + x.nombre); //Para poner nombre al boton de la actividad
            NombreActividad.text = x.nombre.ToString();
            //Debug.Log("Evaluada " + x.evaluada);
            //Debug.Log("nombre disponibilidad " + x.disponibilidad);

            for (int i = 0; i < x.preguntas.Count; i++)
            {
                //Debug.Log("Pregunta " + x.preguntas[i]);
            }
            for (int i = 0; i < x.respuestas.Count; i++)
            {
                //Debug.Log("Respuestas " + x.respuestas[i]);
            }
        }

        //1062527980



        /*
         * GameObject buttonTemplate = transform.GetChild(0).gameObject;
         * GameObject g;
         *
         *
         * jsonData jsnData = JsonUtility.FromJson<jsonData>(_url);
         *
         * idper.text = jsnData.id_persona.ToString();
         * puntuacin.text =  jsnData.puntuacion.ToString();
         *
         * foreach (ActividadesList x in jsnData.actividades)
         * {
         *
         *  g = Instantiate(buttonTemplate, transform);
         *  g.transform.GetChild(0).GetChild(0).GetComponent<Text>().text = x.nombre;
         *
         *
         *  //g.transform.GetChild(4).GetComponent<Text>().text = "8D";
         *
         *  switch (x.disponible)
         *  {
         *      case "1":
         *          g.transform.GetChild(0).GetComponent<Image>().color = MyGreenColor;
         *          break;
         *      case "0":
         *          g.transform.GetChild(0).GetComponent<Image>().color = MyRedColor;
         *          break;
         *
         *  }
         *
         *  for (int d = 0; d < x.nombre.Length; d++)
         *  {
         *
         *      for (int j = 0; j < x.preguntas.Count; j++)
         *      {
         *
         *          var lol = j + 1;
         *
         *          switch (x.respuestas[j])
         *          {
         *              case "1":
         *                  g.transform.GetChild(j+1).GetChild(0).GetComponent<Image>().color = MyGreenColor;
         *                  break;
         *              case "0":
         *                  g.transform.GetChild(j+1).GetChild(0).GetComponent<Image>().color = MyRedColor;
         *                  break;
         *
         *          }
         *
         *          g.transform.GetChild(j + 1).GetComponent<Text>().text = x.preguntas[j];
         *
         *          //TextoPregunta.text = x.preguntas[j];
         *          //g.GetComponent<Button>().onClick.AddEventListener(ItemClicked);
         *      }
         *      for (int i = 0; i < x.respuestas.Count; i++)
         *      {
         *          var lol2 = i + 1;
         *      }
         *
         *
         *
         *  }
         *
         * // dispo.text ="disponibilidad " + x.disponible.ToString();
         *  //calificacion.text = "Calificacion " + x.calificacion.ToString();
         *
         * }
         * Destroy(buttonTemplate);
         */
    }
コード例 #11
0
ファイル: BotonDinamico.cs プロジェクト: IamDantt/Sumar
    // Start is called before the first frame update


    private void processJsonData(string _url)
    {
        jsonData jsnData = JsonUtility.FromJson <jsonData>(_url);

        Nick.text = "Hola! " + jsnData.nombre.ToString() + " " + jsnData.apellido.ToString();

        Debug.Log(_url);
        GameObject buttonTemplate = transform.GetChild(0).gameObject;
        GameObject g;


        //Debug.Log(jsnData.descripcion);

        foreach (ActividadesList x in jsnData.actividades)
        {
            //Debug.Log("Estas son las oipcioens" + x.opciones);

            ContActi = +1;



            g = Instantiate(buttonTemplate, transform);
            g.transform.GetChild(1).GetComponent <Text>().text = x.nombre.ToString();
            g.transform.GetChild(2).GetComponent <Text>().text = jsnData.descripcion.ToString();
            //g.transform.GetChild(5).GetComponent<Text>().text = x.preguntas[1];


            for (int j = 0; j < x.preguntas.Count; j++)
            {
                g.transform.GetChild(4).GetChild(0).GetComponent <Text>().text = x.preguntas[j];

                /*g = Instantiate(buttonTemplate, transform);
                 * g.transform.GetChild(1).GetChild(1).GetComponent<Text>().text = x.preguntas[1];
                 *
                 * g.transform.GetChild(4).GetChild(0).GetChild(0).GetComponent<Text>().text = x.preguntas[1];
                 */
            }

            /* for (int j = 0; j < x.opciones.Count; j++)
             * {
             *  Debug.Log("Estas son las opciones " + x.opciones.ToString());
             * }
             */
            for (int i = 0; i < ContActi; i++)
            {
                g.GetComponent <Button>().AddEvenListener(i, ItenClicked);
            }


            //_______________________________Disponibilidad__________________________________//
            switch (x.disponibilidad)
            {
            case "1":
                g.transform.GetChild(3).GetComponent <Image>().color = MyGreenColor;
                break;

            case "0":
                g.transform.GetChild(3).GetComponent <Image>().color = MyRedColor;
                break;
            }
            //________________________________________________________________________________//

            /* for (int i = 0; i < ContActi; i++)
             * {
             *   g.GetComponent<Button>().AddEvenListener(i, ItenClicked);
             * }*/


            for (int i = 0; i < x.preguntas.Count; i++)
            {
                //Debug.Log("Pregunta " + x.preguntas[i]);
            }
            for (int i = 0; i < x.respuestas.Count; i++)
            {
                //Debug.Log("Respuestas " + x.respuestas[i]);
            }
        }
        Destroy(buttonTemplate);
    }