public UserData buildUser(string jsonDatos) { UserData temporal; temporal = JsonUtility.FromJson <UserData> (dataAsJson); temporal.medal_data = new MedalData[9]; for (int i = 0; i < temporal.medal_data.Length; i++) { string servicio_id = requestMedallas + "getMedallas/" + temporal.userHash + "/" + (i + 1); WWW www = new WWW(servicio_id, null, headerInfo); while (!www.isDone) { //se espera a que la descarga se salga } if (!string.IsNullOrEmpty(www.error)) { //Aquí sería regresar a la página de persistent, o algo mas Debug.LogError("Cannot load game data!"); Application.Quit(); } else { Debug.Log("DATOS MEDALLAS CARGADOS EXITOSAMENTE"); dataAsJson = www.text; MedalData loadedData = JsonUtility.FromJson <MedalData> (dataAsJson); temporal.medal_data [i] = loadedData; } } return(temporal); }
private void LoadMedalData() { string filepath = Path.Combine(Application.streamingAssetsPath, medalDataFileName); if (File.Exists(filepath)) { string dataAsJson = File.ReadAllText(filepath); medalData = JsonUtility.FromJson <MedalData> (dataAsJson); } else { medalData = new MedalData(); } }
public void LoadMedalData(int nivel) { //Aqui debo llamar el webservice de las medallas del ultimo nivel string servicio_id = requestMedallas + "getMedallas/" + userData.userHash + "/" + nivel; WWW www = new WWW(servicio_id, null, headerInfo); while (!www.isDone) { //se espera a que la descarga se salga } if (!string.IsNullOrEmpty(www.error)) { //Aquí sería regresar a la página de persistent, o algo mas Debug.LogError("Cannot load game data!"); Application.Quit(); } else { Debug.Log("DATOS MEDALLAS CARGADOS EXITOSAMENTE"); dataAsJson = www.text; MedalData loadedData = JsonUtility.FromJson <MedalData> (dataAsJson); medalData = loadedData; } }
protected void Page_Load(object sender, EventArgs e) { this.customization.DataSource = MedalData.GetMedalList(); }
public void loginRequest(string username, string password) { bool foundError = false; string dataAsJson; string hashP = hashFunc(password); WWW www = new WWW(DataController.requestsUrlUser + "login/" + username + "/" + hashP, null, dataController.headerInfo); while (!www.isDone) { //se espera a que la descarga se salga } if (!string.IsNullOrEmpty(www.error) || string.IsNullOrEmpty(www.text)) { stopLoading(); Debug.Log(hashP); Debug.LogError(www.error); errorDialog.SetActive(true); } else { string hashId = www.text; hashToBeSaved = www.text; www = new WWW(DataController.requestsUrlUser + "find/" + hashId, null, dataController.headerInfo); while (!www.isDone) { //se espera a que la descarga se salga } if (!string.IsNullOrEmpty(www.error) || string.IsNullOrEmpty(www.text)) { stopLoading(); errorDialog.SetActive(true); foundError = true; Destroy(loadingPanelInstance); } else { dataAsJson = www.text; user = JsonUtility.FromJson <UserData> (dataAsJson); user.medal_data = new MedalData[9]; for (int i = 0; i < user.medal_data.Length; i++) { string servicio_id = DataController.requestMedallas + "getMedallas/" + user.userHash + "/" + (i + 1); Debug.Log(DataController.requestMedallas + "getMedallas/" + user.userHash + "/" + (i + 1)); www = new WWW(servicio_id, null, dataController.headerInfo); while (!www.isDone) { //se espera a que la descarga se salga } if (!string.IsNullOrEmpty(www.error) || string.IsNullOrEmpty(www.text)) { stopLoading(); errorDialog.SetActive(true); foundError = true; Destroy(loadingPanelInstance); } else { Debug.Log("DATOS MEDALLAS CARGADOS EXITOSAMENTE"); dataAsJson = www.text; MedalData loadedData = JsonUtility.FromJson <MedalData> (dataAsJson); user.medal_data [i] = loadedData; } } if (!foundError) { stopLoading(); if (user.avatar > -1) { dataController.SetUserData(user); string filepath = Path.Combine(savepath, userDataFileName); File.WriteAllText(filepath, hashToBeSaved); //creates or overwrite //DataRL.saveDataToDisk (user); SceneManager.LoadScene("MenuScreen"); } else { toAvatarScreen(); } } } } }
/// <summary> /// 获取某个用户勋章 /// </summary> /// <returns></returns> public RspMedalLog GetUserMedal(ReqMedalLog _reqData) { RspMedalLog _rspData = new RspMedalLog(); //验证用户ID格式 if (_reqData.userId < 0) { _rspData.header.status = ERequestResult.faild; _rspData.header.statusCode = Error.MOBILE_ERROR_CODE.MOBILE_PARAMS_ERROR; return(_rspData); } //检查是否登录状态 if (Common.Common.CheckLogin(_reqData.userId, _reqData.userKey) == 0) { _rspData.header.status = ERequestResult.faild; _rspData.header.statusCode = Error.MOBILE_ERROR_CODE.SYS_USER_NOLOGIN; return(_rspData); } //获取勋章列表 string strWhere = string.Empty; string strOrder = " order by AddTime desc"; strWhere += "UsId = " + _reqData.userId; if (_reqData.medalId > 0) { strWhere += " and ID<" + _reqData.medalId; //因为是倒序显示,所以是< } DataSet _ds = new BCW.BLL.Medalget().GetList("TOP 10 ID,Types,UsId,MedalId,Notes,AddTime", strWhere + strOrder); if (_ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < _ds.Tables[0].Rows.Count; i++) { MedalData _medalData = new MedalData(); _medalData.medalId = int.Parse(_ds.Tables[0].Rows[i]["ID"].ToString()); _medalData.userId = int.Parse(_ds.Tables[0].Rows[i]["UsId"].ToString()); _medalData.userName = new BCW.BLL.User().GetUsName(_medalData.userId); _medalData.content = Out.SysUBB(_ds.Tables[0].Rows[i]["Notes"].ToString()); _medalData.addTime = Common.Common.GetLongTime(DateTime.Parse(_ds.Tables[0].Rows[i]["AddTime"].ToString())); _rspData.lstMedal.Add(_medalData); //检查是否到底 if (i == _ds.Tables[0].Rows.Count - 1) { if (strWhere.Contains("1=1") == false) { strWhere += " and 1=1"; } DataSet _dsCheck = new BCW.BLL.Medalget().GetList(" TOP 10 ID,Types,UsId,MedalId,Notes,AddTime ", strWhere.Replace("1=1", "ID<" + _reqData.medalId) + strOrder); _rspData.isFinish = _dsCheck.Tables[0].Rows.Count <= 0; } } } _rspData.serverTime = Common.Common.GetLongTime(DateTime.Now); _rspData.header.status = ERequestResult.success; return(_rspData); }