Beispiel #1
0
 public async Task<Guid> UpdateMediaItemAsync(Guid parentDirectoryId, ResourcePath path, IEnumerable<MediaItemAspect> updatedAspects, bool isRefresh, ResourcePath basePath)
 {
   try
   {
     return await _contentDirectory.AddOrUpdateMediaItemAsync(parentDirectoryId, _localSystemId, path, updatedAspects);
   }
   catch (Exception)
   {
     throw new DisconnectedException();
   }
 }
Beispiel #2
0
        protected void UpdateMediaItem <T>(MediaItem mediaItem, MediaItemAspectMetadata.SingleAttributeSpecification attribute, T value)
        {
            if (mediaItem == null)
            {
                return;
            }

            T oldValue;

            if (MediaItemAspect.TryGetAttribute(mediaItem.Aspects, attribute, out oldValue))
            {
                if ((oldValue == null && value == null) || (oldValue != null && oldValue.Equals(value)))
                {
                    return;
                }
            }

            IContentDirectory cd = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;

            if (cd == null)
            {
                return;
            }
            var         rl = mediaItem.GetResourceLocator();
            List <Guid> parentDirectoryIds;

            if (!MediaItemAspect.TryGetAttribute(mediaItem.Aspects, ProviderResourceAspect.ATTR_PARENT_DIRECTORY_ID, out parentDirectoryIds))
            {
                return;
            }
            MediaItemAspect.SetAttribute(mediaItem.Aspects, attribute, value);
            cd.AddOrUpdateMediaItemAsync(parentDirectoryIds.First(), rl.NativeSystemId, rl.NativeResourcePath, MediaItemAspect.GetAspects(mediaItem.Aspects));
        }