123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- using ChivaXR;
- using ChivaXR.Op;
- using Org.BouncyCastle.Bcpg.OpenPgp;
- using QFramework;
- using Sirenix.OdinInspector;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEditor;
- using UnityEngine;
- public class PranticeManagerForPC : MonoBehaviour
- {
- public static PranticeManagerForPC instance;
- [BoxGroup("配分模块", CenterLabel = true, Order = 1)]
- /// <summary>
- /// 考试信息
- /// </summary>
- [TableList(MaxScrollViewHeight = 20)]
- public List<PranticeProcessElement> m_PranticeProcessElements;
- private ProcessElement currentProcessElement;
- [BoxGroup("场景配置模块", CenterLabel = true, Order = 0), GUIColor(0, 1, 0, 0.6f)]
- [Button("1.获取流程信息")]
- public void GetPranticeProcessElements()
- {
- List<ProcessElement> processElements = ProcessManagement.Instance.processes;
- //临时转存,用户数据恢复
- List<PranticeProcessElement> tmpExamProcessElements = m_PranticeProcessElements;
- //重建考试信息列表
- m_PranticeProcessElements = new List<PranticeProcessElement>();
- foreach (var item in processElements)
- {
- PranticeProcessElement examProcessElement = tmpExamProcessElements.Find(t => t.elementDescript == item.processBase.GetPBDescribe());
- if (examProcessElement != null)
- {
- m_PranticeProcessElements.Add(examProcessElement);
- }
- else
- {
- StepListProxy tmpProxy = DAL.Instance.Get<StepListProxy>();
- if (tmpProxy == null)
- {
- tmpProxy.ReadStepMsgInfoFromTable(OperateSetting.Instance.m_CourseName);
- }
- OperationStepDataInfo tmpInfo = tmpProxy.GetOpStepDataInfoById(item.stepID);
- m_PranticeProcessElements.Add(new PranticeProcessElement()
- {
- id = item.stepID,
- elementDescript = item.processBase.GetPBDescribe(),
- stepName = tmpInfo.stepName
- });
- }
- }
- }
- /// <summary>
- /// 练习开始时间
- /// </summary>
- public DateTime m_StartTime;
- /// <summary>
- /// 练习结束时间
- /// </summary>
- public DateTime m_EndTime;
- private void Awake()
- {
- instance = this;
- GetPranticeProcessElements();
- m_StartTime = DateTime.Now;
- }
- public void Init()
- {
- ProcessManagement.Instance.processElementActiveEvent += ProcessElementActive;
- ProcessManagement.Instance.processElementDisActiveEvent += ProcessElementDisActive;
- ProcessManagement.Instance.processFinishEvent += PranticeFinish;
- }
- /// <summary>
- /// 步骤进入
- /// </summary>
- /// <param name="element"></param>
- private void ProcessElementActive(ProcessElement element)
- {
- currentProcessElement = element;
- }
- /// <summary>
- /// 步骤退出
- /// </summary>
- /// <param name="element"></param>
- private void ProcessElementDisActive(ProcessElement element)
- {
- JianTouManager.instance.SetJianTouActive(false);
- PranticeProcessElement tmpElement = m_PranticeProcessElements.Find(t => t.elementDescript == currentProcessElement.processBase.GetPBDescribe());
- if (tmpElement.finish == false)
- {
- tmpElement.finish = true;
- if (tmpElement.errorReason == null)
- {
- tmpElement.result = true;
- }
- tmpElement.operationTime = DateTime.Now;
- }
- }
- /// <summary>
- /// 成绩展示
- /// </summary>
- public void PranticeFinish()
- {
- m_EndTime = DateTime.Now;
- UIKit.OpenPanel<PC_PranticeResultPanel>(new PC_PranticeResultPanelData() { pranticeProcessElementsData = m_PranticeProcessElements });
- }
- /// <summary>
- /// 记录操作错误
- /// </summary>
- /// <param name="processId"></param>
- public void RecordFault(int processId)
- {
- PranticeProcessElement tmpElement = m_PranticeProcessElements.Find(t => t.id == processId);
- if (tmpElement != null)
- {
- tmpElement.errorReason = "操作错误";
- tmpElement.result = false;
- string screenShotName = DateTime.UtcNow.Ticks.ToString();
- StartCoroutine(ScrrenCapture(new Rect(0, 0, Screen.width, Screen.height), 0, screenShotName, tmpElement));
- }
- }
- Texture2D screenShot;//保存截取的纹理
- IEnumerator ScrrenCapture(Rect rect, int a, string screenShotName, PranticeProcessElement pranticeProcessElement)
- {
- Debug.Log("截图:" + screenShotName);
- screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false);
- yield return new WaitForSeconds(0.5f);
- yield return new WaitForEndOfFrame();
- screenShot.ReadPixels(rect, 0, 0);
- screenShot.Apply();
- //推送
- //PushHelper.InitBasicData();
- //StartCoroutine(PushHelper.SendFileStreamPushRequest(screenShot, screenShotName, (result, msg, flag, cmnAttachId) =>
- // {
- // if (!result)
- // {
- // Debug.LogError(msg);
- // }
- // else
- // {
- // pranticeProcessElement.screenshotList.Add(cmnAttachId.data.cmnAttachId);
- // }
- // pranticeProcessElement.m_UpLoading.Remove(screenShotName);
- // }));
- pranticeProcessElement.m_UpLoading.Add(screenShotName);
- }
- /// <summary>
- /// 是否上传完成
- /// </summary>
- /// <returns></returns>
- public bool IsFinishUpLoad()
- {
- foreach (var item in m_PranticeProcessElements)
- {
- if (item.m_UpLoading.Count > 0)
- {
- return false;
- }
- }
- return true;
- }
- }
- [Serializable]
- public class PranticeProcessElement
- {
- [Sirenix.OdinInspector.ReadOnly]
- public int id;
- [Sirenix.OdinInspector.ReadOnly]
- public string elementDescript;
- /// <summary>
- /// 错误与否
- /// </summary>
- [Sirenix.OdinInspector.ReadOnly]
- public bool result;
- /// <summary>
- /// 是否完成
- /// </summary>
- [Sirenix.OdinInspector.ReadOnly]
- public bool finish = false;
- /// <summary>
- /// 错误截图
- /// </summary>
- public List<string> screenshotList = new List<string>();
- /// <summary>
- /// 操作时间
- /// </summary>
- public DateTime operationTime;
- /// <summary>
- /// 错误原因
- /// </summary>
- public string errorReason;
- /// <summary>
- /// 步骤名称
- /// </summary>
- public string stepName;
- /// <summary>
- /// 正在上传的任务
- /// </summary>
- public List<string> m_UpLoading = new List<string>();
- }
|