IEnumerator SavePaper() { tempPaper.id = classPaper.id; uploadHandle.infoText.text = "正在处理录音数据..."; string rootPath = classPaper.path + "/Memory"; PaperManager.CreatePath(rootPath); string fileName = "TempPaperCELSTWhen" + System.DateTime.Now.ToString("TyyyyMMddhhmmss") + "Random" + Random.Range(-23333, 23333) + ".lhirin"; tempPath = rootPath + "/" + fileName; string partA_b64 = ""; if (pac.scucess) { uploadHandle.infoText.text = "正在处理-PartA"; yield return(new WaitForEndOfFrame()); partA_b64 = CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PA)); tempPaper.partA = partA_b64; } string partBA_b64 = ""; string partBB_b64 = ""; if (pbc.scucess) { for (int i = 0; i < PB_P1.Count; i++) { uploadHandle.infoText.text = "正在处理-PartB问题" + (i + 1).ToString(); yield return(new WaitForEndOfFrame()); partBA_b64 += CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PB_P1[i])); if (i != PB_P1.Count - 1) { partBA_b64 += "|"; } } tempPaper.partBA = partBA_b64; for (int i = 0; i < PB_P2.Count; i++) { uploadHandle.infoText.text = "正在处理-PartB回答" + (i + 1).ToString(); yield return(new WaitForEndOfFrame()); partBB_b64 += CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PB_P2[i])); if (i != PB_P2.Count - 1) { partBB_b64 += "|"; } } tempPaper.partBB = partBB_b64; } string partC_b64 = ""; if (pcc.scucess) { uploadHandle.infoText.text = "正在处理-PartC"; yield return(new WaitForEndOfFrame()); partC_b64 = CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PA)); tempPaper.partC = partC_b64; } tempPaper.isUpload = false; uploadHandle.infoText.text = "正在创建缓存..."; yield return(new WaitForEndOfFrame()); PaperManager.SaveFile(tempPath, JsonUtility.ToJson(tempPaper)); UserMemoryManager.InsertIntoList(new UserMemoryList.Common { dataPath = tempPath, time = System.DateTime.Now.ToString(), type = UserMemoryList.MemoryType.GD_CELST }); uploadHandle.infoText.text = "缓存创建完毕!"; GlobalUIManager.guim.CreateNewSelectBox("缓存完毕,是否上传音频呢?\n如果需要机器改卷或他人协助必须上传到服务器.", delegate(bool ok) { if (ok) { StartCoroutine(CheakPaper()); } else { uploadHandle.gradeObj.SetActive(true); uploadHandle.gradeText.text = "用户取消上传!请点击关闭回到大厅进行自评或进行其他操作!"; } }); //PlayerPrefs.SetString("tempPaper", JsonUtility.ToJson(tempPaper)); //PlayerPrefs.Save(); }
IEnumerator CheakPaper() { tempPaper.id = classPaper.id; uploadHandle.infoText.text = "正在处理录音数据..."; //string rootPath = classPaper.path + "/TEMP/Exam" + System.DateTime.Now.ToString("TyyyyMMddhhmmss"); // PaperManager.CreatePath(rootPath); //rootPath += "/"; string partA_b64 = ""; if (pac.scucess) { uploadHandle.infoText.text = "正在处理-PartA"; yield return(new WaitForEndOfFrame()); partA_b64 = CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PA)); tempPaper.partA = partA_b64; } string partBA_b64 = ""; string partBB_b64 = ""; if (pbc.scucess) { for (int i = 0; i < PB_P1.Count; i++) { uploadHandle.infoText.text = "正在处理-PartB问题" + (i + 1).ToString(); yield return(new WaitForEndOfFrame()); partBA_b64 += CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PB_P1[i])); if (i != PB_P1.Count - 1) { partBA_b64 += "|"; } } tempPaper.partBA = partBA_b64; for (int i = 0; i < PB_P2.Count; i++) { uploadHandle.infoText.text = "正在处理-PartB回答" + (i + 1).ToString(); yield return(new WaitForEndOfFrame()); partBB_b64 += CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PB_P2[i])); if (i != PB_P2.Count - 1) { partBB_b64 += "|"; } } tempPaper.partBB = partBB_b64; } string partC_b64 = ""; if (pcc.scucess) { uploadHandle.infoText.text = "正在处理-PartC"; yield return(new WaitForEndOfFrame()); partC_b64 = CheakerTools.Base64_Encode(WavUtility.FromAudioClip(PA)); tempPaper.partC = partC_b64; } tempPaper.isUpload = false; uploadHandle.infoText.text = "正在创建缓存..."; yield return(new WaitForEndOfFrame()); PlayerPrefs.SetString("tempPaper", JsonUtility.ToJson(tempPaper)); PlayerPrefs.Save(); uploadHandle.infoText.text = "正在上传..."; yield return(new WaitForEndOfFrame()); StartCoroutine(UploadVoiceHandle.Uploader(classPaper.id, partA_b64, partBA_b64, partBB_b64, partC_b64, delegate(ulong size, float process) { uploadHandle.process.fillAmount = process; uploadHandle.processText.text = "(" + GetFileSize(size) + "/" + GetFileSize((ulong)(float.Parse(size.ToString()) / process)) + ")" + Mathf.CeilToInt(process * 100).ToString() + "%"; }, OnUploadDone )); }