Ejemplo n.º 1
0
 void OnGetData(object inData)
 {
     if (inData is Exception)
     {
         Exception ex = (Exception)inData;
         CustomDebug.LogException("Custom Exception while getting data from webservice : " + ex.Message);
         "Some thing went wrong please check your internet connection and try later".ShowAsAlert();
         mLblTitle.text = "Failed to get data from Web";
     }
     else
     {
         try
         {
             string            json       = (string)inData;
             PlayerDataFromAPI playerData = JsonConvert.DeserializeObject <PlayerDataFromAPI>(json);
             mLblTitle.text = "Data From WebService";
             mLblId.text    = playerData.pId;
             mLblName.text  = playerData.pName;
             mLblEmail.text = playerData.pEmail;
         }
         catch (Exception ex)
         {
             CustomDebug.LogException("Custom exception while parsing data from webapi : " + ex.Message);
             mLblTitle.text = "Failed to show data";
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Saves data in persistent path as per given file name
 /// </summary>
 /// <param name="fileName">File name in which we want to save data</param>
 /// <param name="data">Data which we want to save</param>
 public static void SaveToPersistentFile(string fileName, string data)
 {
     try
     {
         CustomDebug.Log("Saving data to file : " + GetPersistentPath(fileName));
         File.WriteAllText(GetPersistentPath(fileName), data);
         "Data Saved".ShowAsAlert();
     }
     catch (Exception ex)
     {
         CustomDebug.LogException("Custom exception while saving data : " + ex.Message + " to file named " + fileName);
         ex.Message.ShowAsAlert();
     }
 }
Ejemplo n.º 3
0
 public void OnBtnLoadLastSavedClicked()
 {
     try
     {
         string json = FileUtility.GetDataFromPersistentFile(PLAYERDATAFILENAME);
         if (!string.IsNullOrEmpty(json))
         {
             PlayerData playerData = JsonConvert.DeserializeObject <PlayerData>(json);
             mIFFirstName.text    = playerData.pFirstName;
             mIFLastName.text     = playerData.pLastName;
             mIFEmail.text        = playerData.pEmail;
             mIFMobileNumber.text = playerData.pMobileNumber;
         }
         else
         {
             "No data saved currently please first save data".ShowAsAlert();
         }
     }
     catch (Exception ex)
     {
         CustomDebug.LogException("Custom exception while trying to load saved data : " + ex.Message);
         ex.Message.ShowAsAlert();
     }
 }