static public void RevertToNormal(IllDatalistRoot checkIllDatalist) { for (int i = 0; i < checkIllDatalist.data.Count; i++) { IllNessData ind = new IllNessData(); DataItem di = checkIllDatalist.data[i]; ind.ID = di.case_id; ind.title = di.title; try { ind.protector_shape = (IllNessData.ProtectorShape)Enum.Parse(typeof(IllNessData.ProtectorShape), di.protector_shape); } catch (Exception) { ind.protector_shape = IllNessData.ProtectorShape.Long; } ind.position = (IllNessData.Direction)Enum.Parse(typeof(IllNessData.Direction), di.position.ToUpper()); ind.injury_position = di.injury_position; ind.note = di.note; ind.description = di.description; ind.illcreatetime = di.created_at; illnesslist.Add(ind); } if (null != callback) { callback(illnesslist); } }
/// <summary> /// 服务器发送来的数据,转化为用户列表 /// </summary> /// <param name="checkIllDatalist"></param> /// <param name="Call"></param> public void RevertToNormal(IllDatalistRoot checkIllDatalist, Action <List <PlayerData> > Call) { for (int i = 0; i < checkIllDatalist.data.Count; i++) { PlayerData ind = new PlayerData(); DataItem di = checkIllDatalist.data[i]; ind.ID = di.case_id; ind.title = di.title; try { ind.protector_shape = (PlayerData.ProtectorShape)Enum.Parse(typeof(PlayerData.ProtectorShape), di.protector_shape); } catch (Exception) { ind.protector_shape = PlayerData.ProtectorShape.Long; } ind.position = di.potsition ? PlayerData.Direction.Right : PlayerData.Direction.Left; ind.note = di.note; ind.description = di.description; ind.illcreatetime = di.created_at; ind.injury_position = di.injury_position; playerDatalist.Add(ind); } Call.InvokeGracefully(playerDatalist); }
protected override void OnShow() { //Get请求服务器 获取数据刷新 string url = Tool.illnessdatasimplepath; QMsg msg = new WebMsg { EventID = (int)Web_E.GET, url = Tool.illnessdatasimplepath, callback = (success, str) => { if (success) { //json解析 IllDatalistRoot cd = JsonHelper.ParseJsonToNeed <IllDatalistRoot>(str); //根据还原的数据进行本地还原,刷新到UI上 PlayerDataCenter.Instance.RevertToNormal(cd, CallbackRefresh); } else { Log.E("-->>firstpage get erro-->> " + str); } } }; SendMsg(msg); }
public override void Refresh() { //Get请求服务器 获取数据刷新 string url = Tool.illnessdatasimplepath; MyWebRequest.Instance.Get(url, (success, str) => { if (success) { //json解析 IllDatalistRoot cd = JsonHelper.ParseJsonToNeed <IllDatalistRoot>(str); //根据还原的数据进行本地还原,刷新到UI上 PlayerDataCenter.RevertToNormal(cd); // ClosePage<UINotice>(); } else { ShowPage <UINotice>(str); } }); }