using SGUnitySDK.Etys; using SGUnitySDK.Services.SGStartParams; using SGUnitySDK; using System.Collections; using System.Collections.Generic; using UnityEngine; using NPOI.OpenXml4Net.OPC.Internal; using Newtonsoft.Json; using SGUnitySDK.Services.HTTP; using SGUnitySDK.Utils; using System; public class MyManage : MonoBehaviour { public static MyManage instance; /// /// 平台人员信息 /// public MyUserData userData; /// /// 启动信息 /// public SGAppStartMode startMode; /// /// 模式 /// public PlayModeEnum playModeEnum; private void Awake() { instance = this; //初始化 SGUConfig config = new SGUConfig(); SGUSdk.GetInstance().InitSDK(config); startMode = SGUSdk.GetInstance().GetAppStartMode(); //获取用户信息 HttpAuthService getUserInfo = new HttpAuthService(); ResponObject responObject1 = getUserInfo.GetUserInfo(); if(responObject1.code=="200") { string data1 = responObject1.data.ToString(); Debug.Log("GetUserInfo:" + data1); userData = JsonConvert.DeserializeObject(data1); //判断模式 if (startMode.examId > 0) { //考试 playModeEnum = PlayModeEnum.考试; HttpExamService getPractiseInfo = new HttpExamService(); ResponObject responObject = getPractiseInfo.PrepareExam(startMode.examId, userData.id); if(responObject.code=="200") { string data = responObject.data.ToString(); Debug.Log("考生获取考试题目" + data); } else { Debug.LogError("获取考试失败:" + responObject.msg); } } else if (startMode.practiseId > 0) { //练习 playModeEnum = PlayModeEnum.练习; HttpPractiseService getPractiseInfo = new HttpPractiseService(); ResponObject responObject = getPractiseInfo.GetPractiseInfo(startMode.practiseId); if(responObject.code=="200") { string data = responObject.data.ToString(); Debug.Log("GetPractiseInfo:" + data); } else { Debug.LogError("获取练习失败:" + responObject.msg); } } } else { Debug.LogError("获取用户失败:" + responObject1.msg); return; } } /// /// 开始练习 /// /// /// /// public void GetStartPractise() { //try { HttpPractiseService getPractiseInfo = new HttpPractiseService(); ResponObject responObject = getPractiseInfo.StartPractise(startMode.practiseId, userData.id, DateTime.Now.ToString()); if(responObject.code=="200") { string data = responObject.data.ToString(); Debug.Log("返回" + data); } else { Debug.LogError(responObject.msg); } } //catch (System.Exception e) //{ // throw; //} } /// /// 提交练习 /// /// /// /// public void GetUploadPracticeAnswer(List answerList) { HttpPractiseService getPractiseInfo = new HttpPractiseService(); ResponObject responObject = getPractiseInfo.UploadAnswer(startMode.practiseId, userData.id, answerList); string data = responObject.data.ToString(); } /// /// 提交练习 /// /// /// /// public void GetEndPractise() { HttpPractiseService getPractiseInfo = new HttpPractiseService(); ResponObject responObject = getPractiseInfo.EndPractise(startMode.practiseId, userData.id, DateTime.Now.ToString()); } /// /// 开始考试 /// /// /// public void GetStartExam() { HttpExamService getPractiseInfo = new HttpExamService(); ResponObject responObject = getPractiseInfo.StartExam(startMode.examId, userData.id); string data = responObject.data.ToString(); Debug.Log("开始考试" + data); } /// /// 提交考试 /// /// /// /// public void GetUploadExamAnswer(List answerList) { HttpExamService getPractiseInfo = new HttpExamService(); ResponObject responObject = getPractiseInfo.UploadAnswer(startMode.examId, userData.id, answerList); string data = responObject.data.ToString(); Debug.Log("提交答题数据" + data); } /// /// 结束考试 /// /// /// public void GetEndExam() { HttpExamService getPractiseInfo = new HttpExamService(); ResponObject responObject = getPractiseInfo.EndExam(startMode.examId, userData.id); string data = responObject.data.ToString(); Debug.Log("结束考试" + data); } } /// /// 模式 /// public enum PlayModeEnum { 练习, 考试 }