91 lines
2.5 KiB
C#
91 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.Xml;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using LitJson;
|
|
using DataModel.Model;
|
|
|
|
public class ScoreManage : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 配置xml
|
|
/// </summary>
|
|
public static XmlDocument scoreXML;
|
|
|
|
public List<ScoreBase> scoreList;
|
|
|
|
public void Init()
|
|
{
|
|
//初始化所有socreobject
|
|
scoreList = GetComponentsInChildren<ScoreBase>(true).ToList();
|
|
scoreList.ForEach(a =>
|
|
{
|
|
if (LoadManage.Instance.psubjects.Any(b => a.transform.parent.name == b.Name))
|
|
{
|
|
a.Init(a.transform.parent.name, a.code);
|
|
}
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交总表成绩
|
|
/// </summary>
|
|
public void SubmitApprise(string subjectname)
|
|
{
|
|
practicesubject tmpps = LoadManage.Instance.psubjects.Find(a => a.Name == subjectname);
|
|
appraise appraise = new appraise
|
|
{
|
|
Id = LoadManage.Instance.currentPractice.Id,
|
|
PracticeId= LoadManage.Instance.currentPractice.Id,
|
|
SubjectId = tmpps.SubjectId,
|
|
PracticeSubjectId= tmpps.Id,
|
|
AppraiseName = tmpps.Name,
|
|
HardLevel= tmpps.HardLevel,
|
|
};
|
|
|
|
//提交数据库
|
|
string url = "http://" + MyNetMQClient.CallIP + "/Handler/Api_Appraise.ashx";
|
|
var tmp = new KeyValuePair<string, string>[2];
|
|
tmp[0] = new KeyValuePair<string, string>("action", "setScore");
|
|
tmp[1] = new KeyValuePair<string, string>("appraise", JsonMapper.ToJson(appraise));
|
|
StartCoroutine(MyNetMQClient.CallPost(url, tmp, result =>
|
|
{
|
|
var json = JsonMapper.ToObject<CallResultObject>(result);
|
|
if (json.state)
|
|
{
|
|
Debug.Log("上传总表:++++++++++++++++++++++++++++++" + JsonMapper.ToJson(appraise));
|
|
}
|
|
else
|
|
{
|
|
Debug.Log(json.message);
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 读xml
|
|
/// </summary>
|
|
/// <param name="text"></param>
|
|
public static void SetXml (string text)
|
|
{
|
|
scoreXML = new XmlDocument();
|
|
|
|
StringReader stringReader = new StringReader(text);
|
|
stringReader.Read();
|
|
string str = stringReader.ReadToEnd();
|
|
stringReader.Close();
|
|
|
|
scoreXML.LoadXml(str);
|
|
Debug.Log("考核xml加载成功");
|
|
}
|
|
}
|
|
|
|
public enum ScoreType
|
|
{
|
|
无序,
|
|
有序
|
|
}
|