/// <summary> /// 提交改卷请求 /// </summary> /// <param name="partName"></param> /// <param name="rid"></param> /// <param name="onOK"></param> /// <returns></returns> public IEnumerator PostCheakRequest(string partName, int rid, System.Action <bool, RequestPostOKClasses> onOK) { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/SOE/CheakRequestPoster.php?token=" + LoginToKaoShi.userLoginCallback.data.token + "&part=" + partName + "&rid=" + rid.ToString(); UnityWebRequest uwr = UnityWebRequest.Get(url); yield return(uwr.SendWebRequest()); try { RequestPostOKClasses rpoc = JsonUtility.FromJson <RequestPostOKClasses>(uwr.downloadHandler.text); if (rpoc.code == 0) { onOK?.Invoke(true, rpoc); } else { onOK?.Invoke(false, rpoc); } } catch { onOK?.Invoke(false, null); } dl.DestoryThisLoad(); }
//Grade/GetMyDoneExam.php?token= // Start is called before the first frame update IEnumerator GetMyDoneExams() { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/Grade/GetMyDoneExam.php?token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); yield return(uwr.SendWebRequest()); if (uwr.isHttpError || uwr.isNetworkError) { GlobalUIManager.guim.CreateNewDialogBox("获取信息时连接出现异常!" + uwr.error); } else { MyDoneExamClasses mdec = JsonUtility.FromJson <MyDoneExamClasses>(uwr.downloadHandler.text); CleanContent(); if (mdec.code == 0) { for (int i = 0; i < mdec.data.Length; i++) { MyDoneExamClasses.MyDoneExams myData = mdec.data[i]; GameObject gm = Instantiate(buttonObjs, targetContent); DoneExamItemCtrl deic = gm.GetComponent <DoneExamItemCtrl>(); deic.thisExam = myData; string cheakedText = ""; if (myData.grade != -2) { cheakedText = "<Color=Green>已批改</Color>"; deic.SetStatus(1); } else { cheakedText = "<Color=Red>未批改</Color>"; deic.SetStatus(0); } deic.descriptText.text = string.Format("试卷代号<Color=Orange>#{0}-模式{3}</Color>{5}\n{1}-{2}\n时间{4}{6}", myData.paperID, myData.paperName, myData.paperType, myData.paperMode, myData.uploadTime, cheakedText, myData.SoeAllow?"<Color=Green>机器改卷</Color>":"" ); } } else { GlobalUIManager.guim.CreateNewDialogBox("Code:" + mdec.code + "\n" + mdec.msg); } } dl.DestoryThisLoad(); }
IEnumerator GetFullResult() { DialogLoading dialogLoading= GlobalUIManager.guim.CreateNewLoading(); GlobalUIManager.guim.CreateNewDialogTie("分析数据下载中..."); string url = GetPermisson.GetServerAddress + "/Grade/GetFullResult.php?ID="+baseExamId+"&token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); yield return uwr.SendWebRequest(); if (uwr.isHttpError || uwr.isNetworkError) { ReloadTip("获取信息时网络出现异常!是否重试?"); } else { try { FullResultData frd = JsonUtility.FromJson<FullResultData>(uwr.downloadHandler.text); if (frd.code == 0) { partAClip=WavUtility.ToAudioClip(CheakerTools.Base64_Decode(frd.data.audioPartA),0,"PartA"); fullResultData = frd; // var soe = SOEWork.GetMyGrade(frd.data.audioPartA, frd.data.keywordPartA); if (string.IsNullOrWhiteSpace(frd.data.jsonPartA)) { GlobalUIManager.guim.CreateNewSelectBox("当前试卷并未批改,是否立即批改?", delegate(bool ok) { if (ok) { cheakingRequestPoster.GoCheak(); } else { SceneManager.LoadScene(1);//退出 } }); } else { CheakingRespondData.ResultClass resultClass = JsonUtility.FromJson<CheakingRespondData.ResultClass>(frd.data.jsonPartA); analyzeManager.LoadAnalyze(resultClass); } } else { ReloadTip(frd.msg+"是否重试?"); } } catch (Exception err) { ReloadTip("未知异常!是否重试?\n" + err.Message); Debug.LogError(err.ToString()); } } dialogLoading.DestoryThisLoad(); }
private IEnumerator GetMyWordTask() { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/Word/GetPlan.php?token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); yield return(uwr.SendWebRequest()); if (!uwr.isHttpError && !uwr.isNetworkError) { try { GetWordPlanRespondData gwprd = JsonUtility.FromJson <GetWordPlanRespondData>(uwr.downloadHandler.text); if (gwprd.code == 0) { // GlobalUIManager.guim.CreateNewDialogBox("成功!"); wordsTaskData = gwprd; LoadList(); newPlan.SetActive(false); wordPlane.SetActive(true); } else if (gwprd.code == 10000) { wordsTaskData = gwprd; GlobalUIManager.guim.CreateNewDialogBox("您已经完成所有任务啦!当前内容为该计划的全部单词~"); LoadList(); newPlan.SetActive(false); wordPlane.SetActive(true); } else { GlobalUIManager.guim.CreateNewDialogTie(gwprd.msg); newPlan.SetActive(true); wordPlane.SetActive(false); } } catch (System.Exception err) { GlobalUIManager.guim.CreateNewDialogBox("解析消息数据包失败!"); Debug.Log(uwr.downloadHandler.text); Debug.Log(err); } } else { GlobalUIManager.guim.CreateNewDialogTie("服务器未响应!"); } dl.DestoryThisLoad(); }
private IEnumerator GoCheaking(int ID) { DialogLoading loading = GlobalUIManager.guim.CreateNewLoading(); GlobalUIManager.guim.CreateNewDialogTie("服务器正在批改~请等待~等待时间不会超过120秒~"); string url = GetPermisson.GetServerAddress + "/SOE/AudioReadCheaker.php?ID=" + ID + "&token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); uwr.timeout = 360; yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { GlobalUIManager.guim.CreateNewDialogBox("网络异常!"); Debug.LogError(uwr.error); // Debug.LogError(uwr.downloadHandler.text); } else { try { CheakingRespondData crd = JsonUtility.FromJson <CheakingRespondData>(uwr.downloadHandler.text); if (crd.code == 0) { analyzeManager.LoadAnalyze(crd.data.res); GlobalUIManager.guim.CreateNewDialogBox(crd.msg); } else { GlobalUIManager.guim.CreateNewDialogBox(crd.msg); SceneManager.LoadScene(1); } } catch (Exception err) { GlobalUIManager.guim.CreateNewDialogBox("数据包解析异常!请联系管理员!"); Debug.LogError(err); SceneManager.LoadScene(1); } } loading.DestoryThisLoad(); }
//服务器地址/Paper/GetAllPaper.php public IEnumerator LoadAllPaper() { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/Paper/GetAllPaper.php?token=" + UnityWebRequest.EscapeURL(LoginToKaoShi.userLoginCallback.data.token); UnityWebRequest uwr = UnityWebRequest.Get(url); //Debug.Log(LoginToKaoShi.userLoginCallback.data.token); //Debug.Log(url); yield return(uwr.SendWebRequest()); if (uwr.error == "" || uwr.error == null) { try { allPaper = JsonUtility.FromJson <AllPaper>(uwr.downloadHandler.text); // Debug.Log(uwr.downloadHandler.text); switch (allPaper.code) { case 0: PutContent(); break; default: GlobalUIManager.guim.CreateNewDialogBox(allPaper.msg); break; } } catch (System.Exception e) { GlobalUIManager.guim.CreateNewDialogBox("数据包解析错误!请联系开发者!" + e.Message); } } else { GlobalUIManager.guim.CreateNewDialogBox(uwr.error); } dl.DestoryThisLoad(); }
private IEnumerator SendJoinPlanDataToServer() { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/Word/NewPlan.php?token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); yield return(uwr.SendWebRequest()); if (!uwr.isHttpError && !uwr.isNetworkError) { try { WordPlanRespondData wprd = JsonUtility.FromJson <WordPlanRespondData>(uwr.downloadHandler.text); if (wprd.code == 0) { GlobalUIManager.guim.CreateNewDialogBox("加入计划成功!"); LoadPlan(); } else { GlobalUIManager.guim.CreateNewDialogBox(wprd.msg); } } catch (System.Exception err) { GlobalUIManager.guim.CreateNewDialogBox("解析消息数据包失败!"); Debug.Log(uwr.downloadHandler.text); Debug.Log(err); } } else { GlobalUIManager.guim.CreateNewDialogTie("服务器未响应!"); } dl.DestoryThisLoad(); }
private IEnumerator GetMyHashCode() { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/User/GetMyQQBindCode.php?token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { GlobalUIManager.guim.CreateNewDialogTie("获取失败!服务器未响应!"); } else { try { HashCodeRecData hcrd = JsonUtility.FromJson <HashCodeRecData>(uwr.downloadHandler.text); if (hcrd.code == 0) { GUIUtility.systemCopyBuffer = "BindMyAccountByRandomCode:" + hcrd.hcode;//剪切板 GlobalUIManager.guim.CreateNewDialogTie("此条内容已复制到剪切板!"); } else { GlobalUIManager.guim.CreateNewDialogTie(hcrd.msg); } } catch { Debug.Log(uwr.downloadHandler.text); GlobalUIManager.guim.CreateNewDialogTie("未知异常!请联系管理员!"); } } dl.DestoryThisLoad(); }
IEnumerator GetMyMessage() { DialogLoading dl = GlobalUIManager.guim.CreateNewLoading(); string url = GetPermisson.GetServerAddress + "/Home/GetHomeMessage.php?token=" + LoginToKaoShi.userLoginCallback.data.token; UnityWebRequest uwr = UnityWebRequest.Get(url); yield return(uwr.SendWebRequest()); CleanContent(); if (uwr.error == "" || uwr.error == null) { try { UserMessageClass umc = JsonUtility.FromJson <UserMessageClass>(uwr.downloadHandler.text); if (umc.code == 0) { //开始读取 for (int i = 0; i < umc.data.Length; i++) { UserMessageClass.Data data = umc.data[i]; // Debug.Log(data.message); try { MessageFormat mf = JsonUtility.FromJson <MessageFormat>(data.message); GameObject gm = Instantiate(buttonObjs, targetContent); HomeMessageItemCtrl hmic = gm.GetComponent <HomeMessageItemCtrl>(); hmic.mf = mf; hmic.umcData = data; switch (mf.type) { case MessageFormat.MessageType.Text: if (data.isRead) { hmic.iconImg.color = Color.white; hmic.SetItem(1); } else { hmic.iconImg.color = Color.yellow; hmic.SetItem(0); } hmic.SetText(mf.title); break; case MessageFormat.MessageType.Link: if (data.isRead) { hmic.iconImg.color = Color.white; hmic.SetItem(3); } else { hmic.iconImg.color = Color.yellow; hmic.SetItem(2); } hmic.SetText(mf.title); break; default: Destroy(gm); GlobalUIManager.guim.CreateNewDialogBox("消息类型(Type)识别错误."); break; } } catch (System.Exception err) { GlobalUIManager.guim.CreateNewDialogBox("消息类型解析失败"); Debug.Log(err.StackTrace); // Debug.Log(JsonUtility.ToJson( new MessageFormat() { type=0,messageBody="111"})); } } } else { GlobalUIManager.guim.CreateNewDialogBox(umc.msg); } } catch (System.Exception err) { GlobalUIManager.guim.CreateNewDialogBox("解析消息数据包失败!"); Debug.Log(uwr.downloadHandler.text); Debug.Log(err); } } dl.DestoryThisLoad(); }