You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.2 KiB
87 lines
3.2 KiB
using UnityEngine; |
|
using AX.Network.Protocols; |
|
using AX.NetworkSystem; |
|
using System.Collections.Generic; |
|
using System; |
|
|
|
public class ANSWER_SAVE_REPLY : NetworkMessageBehaviour { |
|
//public static event EventHandler ExamOverEvent; |
|
private List<AnswerInfo> answerList = new List<AnswerInfo>(); |
|
protected override void Execute(BinaryMessage message) |
|
{ |
|
var answer = message.Body.Deserialize<AnswerInfo>(); |
|
if (answer.ExaminationID == GetComponent<ExamItemManager>().Exam.ID) |
|
{ |
|
answerList.Add(answer); |
|
|
|
if(answerList.Count== BaseItemManager.AnswerList.Count) |
|
{ |
|
UpLoadFiles(); |
|
} |
|
|
|
} |
|
|
|
|
|
} |
|
|
|
private void UpLoadFiles() |
|
{ |
|
var filelist = new List<string>(); |
|
for (int i = 0; i < answerList.Count; i++) |
|
{ |
|
var filename = "Answers/" + answerList[i].ID + "/" + answerList[i].FilePath;//// |
|
filelist.Add(filename); |
|
} |
|
string[] files = filelist.ToArray(); |
|
|
|
//上传文件 |
|
if (files.Length > 0) |
|
{ |
|
if (GameObject.Find("FileTransTipWindow"))//如果已经存在文件传输窗口,不再相应 |
|
return; |
|
GameObject FileTransTipWin = Instantiate(Resources.Load<GameObject>("UIPrefab/FileTransTipWin")); |
|
FileTransTipWin.GetComponent<FileTransTipWinManager>().SetWindow( |
|
"UpLoad", files, TransferType.Upload); |
|
|
|
|
|
FileTransTipWinManager.task.TransferTaskCompleted += Task_TransferTaskCompleted; |
|
} |
|
|
|
} |
|
|
|
private void Task_TransferTaskCompleted() |
|
{ |
|
FileTransTipWinManager.task.TransferTaskCompleted -= Task_TransferTaskCompleted; |
|
for(int i = 0; i < answerList.Count; i++) |
|
{ |
|
NetworkManager.Default.SendRequestAsync("ANSWER_INSERTORUPDATE_REQUEST", answerList[i]);//数据库插入答案记录的请求 |
|
} |
|
BaseItemManager.AnswerList.Clear();//清空待上传答案列表 |
|
answerList.Clear(); |
|
ExamOver(); |
|
} |
|
public void ExamOver() |
|
{ |
|
transform.Find("StartAnswerQuestionButton").gameObject.SetActive(false);//.GetComponent<Button>().interactable = false; |
|
transform.Find("CheckQuestionButton").gameObject.SetActive(false);//.GetComponent<Button>().interactable = false; |
|
transform.Find("SubmitExamButton").gameObject.SetActive(false);//.GetComponent<Button>().interactable = false; |
|
transform.Find("ExamTip").gameObject.SetActive(false); |
|
transform.Find("ExamOverTip").gameObject.SetActive(true); |
|
transform.Find("StartDownloadQuestionButton").gameObject.SetActive(false); |
|
transform.GetComponent<ExamItemManager>().ExamOver = true; |
|
//ExamItemManager.StartExam = false; |
|
if (transform.parent.GetComponent<ExamManager>().AutoBackToLastSceneFlag) |
|
{ |
|
BaseItemManager.CurExam = null; |
|
BaseItemManager.CurQues = null; |
|
BaseItemManager.CurExamID = 0; |
|
BaseItemManager.CurQuestionID = 0; |
|
TimeManager.CurExam = null; |
|
TimeManager.CurQues = null; |
|
TimeManager.RemainSeconds = -10; |
|
|
|
MySceneManager.BackToLastScene(); |
|
|
|
} |
|
} |
|
}
|
|
|