Example #1
0
        public List <string> GetCounts(string tcmFolder)
        {
            try
            {
                List <ItemInfo> topItems = CoreServiceHelper.GetItemsByParentContainer(this.Clients.SessionAwareCoreServiceClient, "tcm:" + tcmFolder, false, new ItemType[] { ItemType.Folder, ItemType.Component });

                List <string> res = new List <string>();

                foreach (ItemInfo topItem in topItems)
                {
                    if (topItem.ItemType == ItemType.Folder)
                    {
                        int count = CoreServiceHelper.GetItemsByParentContainer(this.Clients.SessionAwareCoreServiceClient, topItem.TcmId, true, new ComponentType[] { ComponentType.Multimedia }).Count;
                        if (count > 0)
                        {
                            res.Add(topItem.TcmId.Replace("tcm:", ""));
                        }
                    }
                    else
                    {
                        res.Add(topItem.TcmId.Replace("tcm:", ""));
                    }
                }

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        private List <ItemInfo> GetAllowedSchemas(string tcmPublication)
        {
            ItemInfo topFolder = CoreServiceHelper.GetContainersByPublication(this.Clients.SessionAwareCoreServiceClient, tcmPublication).First(x => x.ItemType == ItemType.Folder);

            List <MultimediaTypeData> imageMimeTypes = CoreServiceHelper.GetMimeTypes(this.Clients.SessionAwareCoreServiceClient, new string[] { "image/jpeg", "image/png", "image/gif", "image/x-bmp" });

            List <ItemInfo> allMmSchemas = CoreServiceHelper.GetItemsByParentContainer(this.Clients.SessionAwareCoreServiceClient, topFolder.TcmId, true, new SchemaPurpose[] { SchemaPurpose.Multimedia });

            return(allMmSchemas.Where(item => ((SchemaData)CoreServiceHelper.ReadItem(this.Clients.SessionAwareCoreServiceClient, item.TcmId)).AllowedMultimediaTypes.Any(mtRef => imageMimeTypes.Any(mt => mt.Id.GetId() == mtRef.IdRef.GetId()))).ToList());
        }
Example #3
0
        private List <ItemInfo> GetMultimediaComponents(string tcmItem)
        {
            if (CoreServiceHelper.GetItemType(tcmItem) == ItemType.Folder)
            {
                List <ItemInfo> items = CoreServiceHelper.GetItemsByParentContainer(this.Clients.SessionAwareCoreServiceClient, tcmItem, true, new ComponentType[] { ComponentType.Multimedia });

                foreach (ItemInfo item in items)
                {
                    if (!item.IsLocal)
                    {
                        item.TcmId = CoreServiceHelper.GetBluePrintTopTcmId(this.Clients.SessionAwareCoreServiceClient, item.TcmId);
                    }
                }

                return(items);
            }

            if (CoreServiceHelper.GetItemType(tcmItem) == ItemType.Component)
            {
                ComponentData component = (ComponentData)CoreServiceHelper.ReadItem(this.Clients.SessionAwareCoreServiceClient, tcmItem);

                if (component.BluePrintInfo.IsShared == true)
                {
                    tcmItem   = CoreServiceHelper.GetBluePrintTopTcmId(this.Clients.SessionAwareCoreServiceClient, tcmItem);
                    component = (ComponentData)CoreServiceHelper.ReadItem(this.Clients.SessionAwareCoreServiceClient, tcmItem);
                }

                if (component.ComponentType == ComponentType.Multimedia)
                {
                    return(new List <ItemInfo> {
                        component.ToItem()
                    });
                }
                else
                {
                    List <string> used = CoreServiceHelper.GetUsedItems(this.Clients.SessionAwareCoreServiceClient, tcmItem, new ItemType[] { ItemType.Component });
                    return(used.Select(x => (ComponentData)CoreServiceHelper.ReadItem(this.Clients.SessionAwareCoreServiceClient, x)).Where(x => x.ComponentType == ComponentType.Multimedia).Select(x => x.ToItem()).ToList());
                }
            }

            return(new List <ItemInfo>());
        }