Exemple #1
0
        /// <summary>
        /// Adds GPS destination location URL metadata item to the <see cref="IGalleryObject.MetadataItems" />
        /// collection of <paramref name="galleryObject" />. If the gallery object's metadata does not contain GPS data or the
        /// visibility of the GPS map link is turned off, no action is taken.
        /// </summary>
        /// <param name="galleryObject">The gallery object.</param>
        /// <param name="metadataDisplaySettings">The metadata display settings.</param>
        /// <remarks>The metadata item is added with <see cref="IGalleryObjectMetadataItem.HasChanges" /> = <c>false</c> to prevent it
        /// from getting persisted to the database. This allows the hyperlink to be regenerated from the template, thus incorporating the
        /// most recent template and other media object properties (such as title). Because the item is linked to the media object, it is
        /// automatically included in the cache of media objects.
        /// This function is identical to <see cref="AddGpsLocationWithMapLink" /> except it uses the primary (not destination) GPS settings.</remarks>
        private static void AddGpsDestLocationWithMapLink(IGalleryObject galleryObject, IMetadataDefinitionCollection metadataDisplaySettings)
        {
            if (!metadataDisplaySettings.Find(FormattedMetadataItemName.GpsDestLocationWithMapLink).IsVisible)
            {
                return;                 // The map link is disabled, so there is nothing to do.
            }
            IGalleryObjectMetadataItemCollection metadata = galleryObject.MetadataItems;
            IGalleryObjectMetadataItem           gpsLocation;

            if (metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsDestLocation, out gpsLocation) && (!metadata.Contains(FormattedMetadataItemName.GpsDestLocationWithMapLink)))
            {
                // We have a GPS location but have not yet created the URL'd version. Do so now and add it to the collection.
                IGalleryObjectMetadataItem latitude;
                IGalleryObjectMetadataItem longitude;
                bool foundLatitude  = metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsDestLatitude, out latitude);
                bool foundLongitude = metadata.TryGetMetadataItem(FormattedMetadataItemName.GpsDestLongitude, out longitude);

                if (foundLatitude && foundLongitude)
                {
                    string url = GetGpsMapUrl(galleryObject, latitude.Value, longitude.Value, gpsLocation.Value);

                    if (!String.IsNullOrEmpty(url))
                    {
                        // Add to meta collection. Specify false for HasChanges to prevent it from getting persisted back to the database.
                        galleryObject.MetadataItems.AddNew(int.MinValue, FormattedMetadataItemName.GpsDestLocationWithMapLink, Resources.GalleryServerPro.Metadata_GpsDestLocationWithMapLink, url, false);
                    }
                }
            }
        }
 /// <summary>
 /// Gets the collection of tag values having the specified <paramref name="tagName" />.
 /// </summary>
 /// <param name="metas">The metadata items.</param>
 /// <param name="tagName">Name of the tag.</param>
 /// <returns>Returns a collection of strings.</returns>
 private static IEnumerable<string> GetTagList(IGalleryObjectMetadataItemCollection metas, MetadataItemName tagName)
 {
     IGalleryObjectMetadataItem mdTag;
     if (metas.TryGetMetadataItem(tagName, out mdTag))
     {
         return mdTag.Value.ToListFromCommaDelimited();
     }
     else
         return new string[] { };
 }