public void OnStartClick() { if (!selectMode) { PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; if (hdci != null) { PollsConfig.selectedDepartment = hdci; } PollsConfig.SerializeData(); this.gameObject.SetActive(false); IntroPage.gameObject.SetActive(true); } else { PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; if (hdci != null) { PollsConfig.selectedDepartment = hdci; } PollsConfig.SerializeData(); AnswerPageController.previewMode = false; this.gameObject.SetActive(false); answerPage.gameObject.SetActive(true); } }
IEnumerator webGetQuestionsID(DepartmentCell dc, int departmentid) { WWWForm form = new WWWForm(); form.AddField("UserID", PollsConfig.netUserID); form.AddField("Token", PollsConfig.netUserToken); form.AddField("DepartmentID", departmentid); WWW www = new WWW("http://47.106.71.112/api/getquestionnaires.aspx", form); yield return(www); if (www.isDone && www.error == null && www.text != "") { var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; retWithoutData ret = JsonConvert.DeserializeObject <retWithoutData>(www.text, settings); if (ret.ret == 1) { getQidRetWithData data = JsonConvert.DeserializeObject <getQidRetWithData>(www.text, settings); //get dci by name PollsConfig.DepartmentCellInfo dci = PollsConfig.GetDepartmentCellInfoByName(data.data[0].vcDepartmentName); if (dci != null) { dci.title = data.data[0].Title; if (!PollsConfig.QuestionMap.ContainsKey(data.data[0].iQuestionnaireID.ToString())) { needDownload++; loadingPanel.SetActive(true); yield return(StartCoroutine(webLoadQuestions(dc, data.data[0].vcDepartmentName, data.data[0].iQuestionnaireID))); } else { //PollsConfig.DepartmentCellInfo dci = PollsConfig.GetDepartmentCellInfoByName(data.data[0].vcDepartmentName); dci.questions = PollsConfig.QuestionMap[data.data[0].iQuestionnaireID.ToString()]; dci.qusetionLoaded = true; dci.questionID = data.data[0].iQuestionnaireID.ToString(); dc.SetToReadyStage(); PollsConfig.SerializeData(); } } else { Toast.ShowToast("获取科室绑定问卷失败."); Debug.LogError("webGetQuestionsID failed. " + data.data[0].vcDepartmentName); } } else { Toast.ShowToast(ret.info); } www.Dispose(); } else { Debug.Log("There no questions in department " + departmentid); } }
public void OnLoadQuestion() { // EditorUtility.OpenFilePanel("sss", "\\", ".json"); fileChooser.setup(FileChooser.OPENSAVE.OPEN, "json"); fileChooser.openSaveButton.GetComponentInChildren <Text>().text = "打开"; fileChooser.TextTopic.text = "请选择需要打开的题目文件"; fileChooser.callbackYes = delegate(string filename, string fullname) { //first hide the filechooser fileChooser.gameObject.SetActive(false); Debug.Log("select " + fullname); /* * if (PollsConfig.QuestionMap.ContainsKey(fullname)) * { * if (hotDepartmentCell != null) * { * PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; * if (hdci != null) * { * hdci.qusetionLoaded = true; * hdci.questionPath = fullname; * } * PollsConfig.selectedDepartment = hdci; * btnPreview.interactable = true; * btnStart.interactable = true; * PollsConfig.SerializeData(); * } * } * else * { * //jsonPath = fullname; * //jsonName = filename; * //StartCoroutine(LoadWWW()); * }*/ if (hotDepartmentCell != null) { PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; if (hdci != null) { hdci.qusetionLoaded = true; hdci.questionID = fullname; } PollsConfig.selectedDepartment = hdci; btnPreview.interactable = selectMode ? false : true; btnStart.interactable = true; btnLoad.interactable = false; PollsConfig.SerializeData(); } }; fileChooser.callbackNo = delegate() { fileChooser.gameObject.SetActive(false); }; }
public void OnPreviewClick() { PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; if (hdci != null) { PollsConfig.selectedDepartment = hdci; } AnswerPageController.previewMode = true; //this.gameObject.SetActive(false); AnswerPage.gameObject.SetActive(true); }
private DepartmentCell AddNewCell(string name, bool load = false) { PollsConfig.DepartmentCellInfo dci = PollsConfig.GetDepartmentCellInfoByName(name); if (selectMode && !dci.qusetionLoaded) { return(null); } GameObject newone = Instantiate(Resources.Load("ui/DepartmentCell") as GameObject); if (newone != null) { newone.transform.SetParent(grid.transform); newone.transform.localScale = Vector3.one; newone.transform.position = Vector3.zero; RectTransform rti = newone.GetComponent <RectTransform>(); rti.anchoredPosition3D = new Vector3(rti.anchoredPosition3D.x, rti.anchoredPosition3D.y, 0); if (dci != null) { DepartmentCell dc = newone.GetComponent <DepartmentCell>(); dc.controller = this; dc.textName.text = dci.name; if (dci.qusetionLoaded) { dc.SetToReadyStage(); } else { dc.SetToNormalStage(); } DepartmentCellMap.Add(dc, dci); if (!load) { PollsConfig.SerializeData(); } Invoke("_refreshList", 0.1f); return(dc); } return(null); } else { Debug.Log("Instantiate DepartmentCell failed."); #if UNITY_ANDROID Toast.ShowToast("未知错误,请退出后重试"); #endif return(null); } }
public void OnClickCell(DepartmentCell cell) { if (DepartmentCellMap.ContainsKey(cell)) { PollsConfig.DepartmentCellInfo dci = DepartmentCellMap[cell]; textNumPeople.text = "已完成" + dci.numPeople + "人次"; textDepartmentSelected.text = "已选择 :" + dci.name; textDepartmentSelected.color = Color.blue; if (!PollsConfig.isOfflineMode) { textQuestion.text = dci.title; } else { textQuestion.text = ""; } if (hotDepartmentCell == null) { hotDepartmentCell = cell; hotDepartmentCell.SetToSelectedStage(); } else { PollsConfig.DepartmentCellInfo hdci = DepartmentCellMap[hotDepartmentCell]; if (hdci != null) { if (hdci.qusetionLoaded) { hotDepartmentCell.SetToReadyStage(); } else { hotDepartmentCell.SetToNormalStage(); } hotDepartmentCell = cell; hotDepartmentCell.SetToSelectedStage(); } } btnDelete.interactable = selectMode ? false : true; btnStart.interactable = dci.qusetionLoaded; btnPreview.interactable = selectMode ? false : dci.qusetionLoaded; btnLoad.interactable = selectMode ? false : !dci.qusetionLoaded; } }
IEnumerator webLoadQuestions(DepartmentCell dc, string departmentname, int id) { WWWForm form = new WWWForm(); form.AddField("UserID", PollsConfig.netUserID); form.AddField("Token", PollsConfig.netUserToken); form.AddField("QuestionnaireID", id); WWW www = new WWW("http://47.106.71.112/api/getquestionnaire.aspx", form); yield return(www); if (www.isDone && www.error == null) { var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; retWithoutData ret = JsonConvert.DeserializeObject <retWithoutData>(www.text, settings); if (ret.ret == 1) { needDownload--; if (needDownload == 0) { loadingPanel.SetActive(false); } getQRetWithData data = JsonConvert.DeserializeObject <getQRetWithData>(www.text, settings); parseJson(id.ToString(), data.data); PollsConfig.DepartmentCellInfo dci = PollsConfig.GetDepartmentCellInfoByName(departmentname); dci.questions = PollsConfig.QuestionMap[id.ToString()]; dci.qusetionLoaded = true; dci.questionID = id.ToString(); dc.SetToReadyStage(); PollsConfig.SerializeData(); } else { Toast.ShowToast(ret.info); } www.Dispose(); } }
IEnumerator webLoadQuestions(QuestionBlockCell qbc) { WWW www = new WWW("http://47.106.71.112:8080/api/Questions?questionname=" + qbc.questionGuid); yield return(www); if (www.isDone && www.error == null) { downloaded++; if (downloaded == grid.transform.childCount) { loadingPanel.SetActive(false); } parseJson(qbc.questionGuid, www.text); //add hospital PollsConfig.AddHospitals(qbc.hospitalNameText.text, 0); PollsConfig.AddDepartment(qbc.departmentNameText.text, 0, PollsConfig.GetHospitalCellInfoByName(qbc.hospitalNameText.text)); PollsConfig.DepartmentCellInfo dci = PollsConfig.GetDepartmentCellInfoByName(qbc.departmentNameText.text, PollsConfig.GetHospitalCellInfoByName(qbc.hospitalNameText.text)); dci.questions = PollsConfig.QuestionMap[qbc.questionGuid]; dci.qusetionLoaded = true; www.Dispose(); } }