Beispiel #1
0
        /// <summary>
        /// Retrieves the list of locations as <see cref="RTMLocationItem"/>s from the RTM server.
        /// </summary>
        public static void UpdateLocations()
        {
            lock (location_lock) {
                if (!IsAuthenticated && !TryConnect())
                {
                    return;
                }

                Locations rtmLocations;
                try {
                    rtmLocations = rtm.LocationsGetList();
                } catch (RtmException e) {
                    Log <RTM> .Debug(AddinManager.CurrentLocalizer.GetString("An error happend when updating RTM locations: {0}"), e.Message);

                    rtmLocations = null;
                    return;
                }

                locations.Clear();
                if (rtmLocations.locationCollection.Length > 0)
                {
                    foreach (Location rtmLocation in rtmLocations.locationCollection)
                    {
                        locations.Add(new RTMLocationItem(rtmLocation.ID, rtmLocation.Name,
                                                          rtmLocation.Address, rtmLocation.Longitude, rtmLocation.Latitude));
                    }
                }
            }
            Log <RTM> .Debug("Received {0} locations.", locations.ToArray().Length);
        }