internal static int CountMediaItems(IOwinContext context, ISet <Guid> necessaryMIATypes, IFilter filter = null)
        {
            Guid?   user         = ResourceAccessUtils.GetUser(context);
            IFilter searchFilter = ResourceAccessUtils.AppendUserFilter(user, filter, necessaryMIATypes);

            return(MediaLibrary.CountMediaItems(necessaryMIATypes, searchFilter, false, false));
        }
        internal static HomogenousMap GetGroups(IOwinContext context, ISet <Guid> necessaryMIATypes, AttributeSpecification attribute, IFilter filter = null)
        {
            Guid?   user         = ResourceAccessUtils.GetUser(context);
            IFilter searchFilter = ResourceAccessUtils.AppendUserFilter(user, filter, necessaryMIATypes);

            return(MediaLibrary.GetValueGroups(attribute, filter, ProjectionFunction.None, necessaryMIATypes, searchFilter, true, false));
        }
        internal static IList <MediaItem> Search(IOwinContext context, ISet <Guid> necessaryMIATypes, ISet <Guid> optionalMIATypes, IFilter filter, uint?limit = null)
        {
            Guid?          user         = ResourceAccessUtils.GetUser(context);
            IFilter        searchFilter = ResourceAccessUtils.AppendUserFilter(user, filter, necessaryMIATypes);
            MediaItemQuery searchQuery  = new MediaItemQuery(necessaryMIATypes, optionalMIATypes, searchFilter)
            {
                Limit = limit
            };

            return(MediaLibrary.Search(searchQuery, false, user, false));
        }
Exemplo n.º 4
0
        internal static async Task <IList <IChannelGroup> > GetGroupsAsync(IOwinContext context)
        {
            Guid?user = ResourceAccessUtils.GetUser(context);
            List <IChannelGroup> groups = new List <IChannelGroup>();
            var channelGroups           = await ChannelAndGroupInfo.GetChannelGroupsAsync();

            if (channelGroups.Success)
            {
                groups.AddRange(channelGroups.Result);
            }
            ResourceAccessUtils.FilterGroups(user, groups);
            return(groups);
        }
        internal static bool Delete(IOwinContext context, MediaItem item)
        {
            Guid?user = ResourceAccessUtils.GetUser(context);
            IList <MultipleMediaItemAspect> providerResourceAspects;

            if (MediaItemAspect.TryGetAspects(item.Aspects, ProviderResourceAspect.Metadata, out providerResourceAspects))
            {
                foreach (var res in providerResourceAspects.Where(p => p.GetAttributeValue <int>(ProviderResourceAspect.ATTR_TYPE) == ProviderResourceAspect.TYPE_PRIMARY))
                {
                    var systemId        = res.GetAttributeValue <string>(ProviderResourceAspect.ATTR_SYSTEM_ID);
                    var resourcePathStr = res.GetAttributeValue <string>(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH);
                    var resourcePath    = ResourcePath.Deserialize(resourcePathStr.ToString());
                    MediaLibrary.DeleteMediaItemOrPath(systemId, resourcePath, true);
                }
            }
            return(true);
        }