Ejemplo n.º 1
0
 public override Task <bool> IsAvailableAsync(MediaItem mediaItem)
 {
     try
     {
         MediaItemMatchModel mimm = ServiceRegistration.Get <IWorkflowManager>().GetModel(MediaItemMatchModel.MODEL_ID_MIMATCH) as MediaItemMatchModel;
         return(Task.FromResult(mimm?.IsValidMediaItem(mediaItem) ?? false));
     }
     catch (Exception)
     {
         return(Task.FromResult(false));
     }
 }
Ejemplo n.º 2
0
        public override async Task <AsyncResult <ContentDirectoryMessaging.MediaItemChangeType> > ProcessAsync(MediaItem mediaItem)
        {
            // If the MediaItem was loaded from ML, remove it there as well.
            if (IsManagedByMediaLibrary(mediaItem))
            {
                IContentDirectory cd = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;
                if (cd == null)
                {
                    return(new AsyncResult <ContentDirectoryMessaging.MediaItemChangeType>(false, ContentDirectoryMessaging.MediaItemChangeType.None));
                }

                MediaItemMatchModel           mimm    = ServiceRegistration.Get <IWorkflowManager>().GetModel(MediaItemMatchModel.MODEL_ID_MIMATCH) as MediaItemMatchModel;
                IEnumerable <MediaItemAspect> aspects = await mimm.OpenSelectMatchDialogAsync(mediaItem).ConfigureAwait(false);

                if (aspects != null)
                {
                    await cd.ReimportMediaItemMetadataAsync(mediaItem.MediaItemId, aspects);

                    //After refresh is completed on server a change message will be fired
                    return(new AsyncResult <ContentDirectoryMessaging.MediaItemChangeType>(true, ContentDirectoryMessaging.MediaItemChangeType.None));
                }
            }
            return(new AsyncResult <ContentDirectoryMessaging.MediaItemChangeType>(false, ContentDirectoryMessaging.MediaItemChangeType.None));
        }