/// <summary> /// 根据答案内容确定ABCDE /// </summary> public IEnumerator GetOption() { JsonToXmlTool.getOption(); submitScore ss = new submitScore(); ss.uuid = AppOpera.myClass.rykjMemberId; ss.testpaperId = Question.LibId; ss.testpaperStudentScore = ScenceData.score; ss.studentId = ClassPanelControll.sin.id; ss.no = ClassPanelControll.sin.no; ss.classesId = ClassPanelControll.currentClassId; List <Option> datas = new List <Option>(); Debug.Log(JsonConvert.SerializeObject(QuestingPanel.selecteds)); foreach (Selected st in QuestingPanel.selecteds) { if (!st.isRight) { datas.Add(new Option(st.qid, st.option)); } } ss.data = datas.ToArray(); Debug.Log(JsonConvert.SerializeObject(ss)); KeyValue kv = new KeyValue("testpaperjson", JsonConvert.SerializeObject(ss)); WebServicesBase wsb = new WebServicesBase(); UnityWebRequest uw = wsb.PostWithParams(servelets.commitScore, kv); yield return(uw.Send()); Debug.Log(uw.downloadHandler.text); //servelets //string filePath = }
/// <summary> /// 发送注册参数 /// </summary> /// <returns></returns> public IEnumerator sendRegisterParams() { messagePanel.SetActive(true); message.text = "正在获取服务器数据······"; //Dictionary<string, string> tmp = new Dictionary<string, string>(); //MyArrays<KeyValue> myArrays = new MyArrays<KeyValue>(); //myArrays.Items = new KeyValue[RegisterParams.Length]; KeyValue[] kvs = new KeyValue[3 + RegisterParams.Length]; kvs[0] = new KeyValue("uuid", MemberId); kvs[1] = new KeyValue("phone", phoneNumber); kvs[2] = new KeyValue("email", email); //从注册表单获取数据代码,直接发送手机号邮箱和识别码,暂不用注册 int i = 3; foreach (Text tmpT in RegisterParams) { KeyValue kv = new KeyValue(); kv.key = tmpT.name.Trim(); kv.value = tmpT.name == "no" ? selectSchool + tmpT.text.Trim(): tmpT.text.Trim(); kvs[i++] = kv; //tmp.Add(tmpT.name,tmpT.text); //JsonUtility.FromJson<Serialization<String, bool>>(jsonStr).ToDictionary(); } string jsonData = JsonConvert.SerializeObject(kvs); Debug.Log(jsonData); UnityWebRequest uw = wsb.PostWithParams(servelets.studentRegister, kvs); yield return(uw.Send()); Debug.Log(uw.downloadHandler.text); if (!uw.isNetworkError) { Debug.Log(uw.downloadHandler.text); ResponseJson rj = new ResponseJson(); //ResponseJson rj = JsonConvert.DeserializeObject<ResponseJson>(uw.downloadHandler.text); //var v = JsonConvert.DeserializeObject<dynamic>(uw.downloadHandler.text); JObject jsonText = JObject.Parse(uw.downloadHandler.text); // get JSON result objects into a list rj.stateCode = jsonText["stateCode"].Value <string>(); rj.message = jsonText["result"].Value <string>(); Debug.Log(rj.stateCode); if (rj.stateCode == "500") { StartCoroutine(requestFailed("该学号已注册")); Debug.Log(rj.stateCode); } else if (rj.stateCode == WebServicesBase.GetEnumDescription(stateCode.access) && rj.message == "学生信息注册成功") { Debug.Log("注册成功!"); RegisterPanel.SetActive(false); RegisterInfoPanel.SetActive(false); refeshClass(); } else { StartCoroutine(requestFailed("注册失败,请重试")); } } else { StartCoroutine(requestFailed()); } //messagePanel.SetActive(false); //JsonConvert.DeserializeObject<Product>(output); }
/// <summary> /// 是否Mysql端注册 /// </summary> /// <returns></returns> public IEnumerator isMySqlRegister() { messagePanel.SetActive(true); message.text = "正在获取服务器数据······"; //当网络不可用时 if (Application.internetReachability == NetworkReachability.NotReachable) { //message.text = "网络不可达,请稍后再试。"; yield return(StartCoroutine(requestFailed())); Debug.Log("网络不可用!"); } else { KeyValue[] kv = new KeyValue[1]; kv[0] = new KeyValue("uuid", MemberId); UnityWebRequest uw = wsb.PostWithParams(servelets.isStudentExists, kv); yield return(uw.Send()); string jsonData = uw.downloadHandler.text; if (!uw.isNetworkError) { Debug.Log(uw.downloadHandler.text); ResponseJson rj = new ResponseJson(); //ResponseJson rj = JsonConvert.DeserializeObject<ResponseJson>(uw.downloadHandler.text); //var v = JsonConvert.DeserializeObject<dynamic>(uw.downloadHandler.text); try { rj = JsonConvert.DeserializeObject <ResponseJson>(uw.downloadHandler.text); //JObject jsonText = JObject.Parse(uw.downloadHandler.text); // get JSON result objects into a list // rj.stateCode = jsonText["stateCode"].Value<string>(); // rj.message = jsonText["result"].Value<bool>().ToString(); //List<Newtonsoft.Json.Linq.JToken> listJToken = googleSearch["responseData"]["results"].Children().ToList(); //Debug.Log(JsonConvert.SerializeObject(rj)); Debug.Log(rj.stateCode); Debug.Log(rj.message); Debug.Log(rj.stuInfo); Debug.Log(rj.result); if (rj.stateCode == WebServicesBase.GetEnumDescription(stateCode.access) && (rj.message == "True" || rj.result == "true")) { Debug.Log("用户存在====="); isReg = true; sin = rj.stuInfo[0]; Debug.Log(sin.no); StartCoroutine(getClassInfo()); } else if (rj.stateCode == "409") { messagePanel.SetActive(false); Debug.Log("开始注册协程"); //schoolListParent.DetachChildren(); clearToggle(); selectSchoolFlag = true; if (rj.school != null && rj.school.Length != 0) { foreach (schoolInfo tmpInfo in rj.school) { addSchoolListItem(tmpInfo.name, tmpInfo.code); } } else { addSchoolListItem("西安欧亚学院", "OYXY"); addSchoolListItem("西安培华学院", "PHXY"); } RegisterPanel.SetActive(true); //StartCoroutine(sendRegisterParams()); } else { StartCoroutine(requestFailed()); } } catch (Exception e) { Debug.Log(e.Message); Debug.Log(e.StackTrace); StartCoroutine(requestFailed()); } } else { StartCoroutine(requestFailed()); } } }