Esempio n. 1
0
 /// <summary>
 /// Send the unsent locations to the server.
 /// </summary>
 /// <param name="user">the user whose location data is to be sent</param>
 /// <returns>true if successful</returns>
 public async Task<bool> SendLocations(ParseUser user)
 {
     Queue<GeoPosition<GeoCoordinate>> temp = new Queue<GeoPosition<GeoCoordinate>>();
     if (QueueSize() == 0)
         return true;
     try
     {
         await user.FetchIfNeededAsync();
         while (QueueSize() > 0)
         {
             GeoPosition<GeoCoordinate> last = Dequeue();
             temp.Enqueue(last);
             Utilities.SaveLocationToParseUser(user, last);
         }
         await user.SaveAsync();
     }
     catch (Exception e)
     {
         Debug.WriteLine("Failed to send the unsent locations");
         Debug.WriteLine(e.ToString());
         while (temp.Count > 0)
         {
             Enqueue(temp.Dequeue());
         }
         Save();
         return false;
     }
     Save();
     return true;
 }