コード例 #1
0
 public object GetSummaryPanelData(TcmIds tcmIDs)
 {
     try
     {
         GetPublishedInfo getFinalPublishedInfo = new GetPublishedInfo();
         var         multipleListItems          = new List <ListItems>();
         XmlDocument doc = new XmlDocument();
         foreach (var tcmId in tcmIDs.IDs)
         {
             var listXml = Client.GetListXml(tcmId.ToString(), new RepositoryItemsFilterData
             {
                 ItemTypes   = new[] { ItemType.Component, ItemType.ComponentTemplate, ItemType.Category, ItemType.Page },
                 Recursive   = true,
                 BaseColumns = ListBaseColumns.Extended
             });
             if (listXml == null)
             {
                 throw new ArgumentNullException(nameof(listXml));
             }
             doc.LoadXml(listXml.ToString());
             multipleListItems.Add(TransformObjectAndXml.Deserialize <ListItems>(doc));
         }
         List <Item> finalList = new List <Item>();
         foreach (var publishedItem in getFinalPublishedInfo.FilterIsPublishedItem(multipleListItems))
         {
             foreach (var item in publishedItem)
             {
                 var publishInfo = Client.GetListPublishInfo(item.ID);
                 foreach (var item1 in getFinalPublishedInfo.ReturnFinalList(publishInfo, item))
                 {
                     finalList.Add(item1);
                 }
             }
         }
         IEnumerable <Analytics> analytics = finalList.GroupBy(x => new { x.PublicationTarget, x.Type }).Select(g => new Analytics {
             Count = g.Count(), PublicationTarget = g.Key.PublicationTarget, ItemType = g.Key.Type,
         });
         var tfilter = new TargetTypesFilterData();
         List <ItemSummary> itemssummary = getFinalPublishedInfo.SummaryPanelData(analytics, Client.GetSystemWideList(tfilter));
         return(itemssummary);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
コード例 #2
0
        public object GetAllPublishedItems(TcmIds tcmIDs)
        {
            GetPublishedInfo getFinalPublishedInfo = new GetPublishedInfo();
            var         multipleListItems          = new List <ListItems>();
            XmlDocument doc = new XmlDocument();

            try
            {
                foreach (var tcmId in tcmIDs.IDs)
                {
                    TCM.TcmUri iTcmUri = new TCM.TcmUri(tcmId.ToString());
                    XElement   listXml = null;
                    switch (iTcmUri.ItemType.ToString())
                    {
                    case CONSTANTS.PUBLICATION:
                        listXml = Client.GetListXml(tcmId.ToString(), new RepositoryItemsFilterData
                        {
                            ItemTypes   = new[] { ItemType.Component, ItemType.ComponentTemplate, ItemType.Category, ItemType.Page },
                            Recursive   = true,
                            BaseColumns = ListBaseColumns.Extended
                        });
                        break;

                    case CONSTANTS.FOLDER:
                        listXml = Client.GetListXml(tcmId.ToString(), new OrganizationalItemItemsFilterData
                        {
                            ItemTypes   = new[] { ItemType.Component, ItemType.ComponentTemplate },
                            Recursive   = true,
                            BaseColumns = ListBaseColumns.Extended
                        });
                        break;

                    case CONSTANTS.STRUCTUREGROUP:
                        listXml = Client.GetListXml(tcmId.ToString(), new OrganizationalItemItemsFilterData()
                        {
                            ItemTypes   = new[] { ItemType.Page },
                            Recursive   = true,
                            BaseColumns = ListBaseColumns.Extended
                        });
                        break;

                    case CONSTANTS.CATEGORY:
                        listXml = Client.GetListXml(tcmId.ToString(), new RepositoryItemsFilterData
                        {
                            ItemTypes   = new[] { ItemType.Category },
                            Recursive   = true,
                            BaseColumns = ListBaseColumns.Extended
                        });
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    if (listXml == null)
                    {
                        throw new ArgumentNullException(nameof(listXml));
                    }
                    doc.LoadXml(listXml.ToString());
                    multipleListItems.Add(TransformObjectAndXml.Deserialize <ListItems>(doc));
                }
                return(getFinalPublishedInfo.FilterIsPublishedItem(multipleListItems).SelectMany(publishedItem => publishedItem, (publishedItem, item) => new { publishedItem, item }).Select(@t => new { @t, publishInfo = Client.GetListPublishInfo(@t.item.ID) }).SelectMany(@t => getFinalPublishedInfo.ReturnFinalList(@t.publishInfo, @[email protected])).ToList());
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }