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
{
///
/// 配置xml
///
public static XmlDocument scoreXML;
public List scoreList;
public void Init()
{
//初始化所有socreobject
scoreList = GetComponentsInChildren(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);
}
});
}
///
/// 提交总表成绩
///
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[2];
tmp[0] = new KeyValuePair("action", "setScore");
tmp[1] = new KeyValuePair("appraise", JsonMapper.ToJson(appraise));
StartCoroutine(MyNetMQClient.CallPost(url, tmp, result =>
{
var json = JsonMapper.ToObject(result);
if (json.state)
{
Debug.Log("上传总表:++++++++++++++++++++++++++++++" + JsonMapper.ToJson(appraise));
}
else
{
Debug.Log(json.message);
}
}));
}
///
/// 读xml
///
///
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
{
无序,
有序
}