Esempio n. 1
0
        private static string GetPagesUsedByAPageTemplate(string pageTemplateTcmId, out int pagesFound)
        {
            XElement pages = core.GetListXml(pageTemplateTcmId, new UsingItemsFilterData {
                ItemTypes = new[] { ItemType.Page }
            });

            StringBuilder sbPages = new StringBuilder();

            foreach (var page in pages.Elements())
            {
                sbPages.AppendFormat("- Page '{0}' with ID {1}", page.Attribute("Title").Value, page.Attribute("ID").Value).Append(Environment.NewLine);
            }
            pagesFound = pages.Elements().Count();
            return(sbPages.ToString());
        }
Esempio n. 2
0
        public static bool bluePrintInfo(CoreServiceClient client)
        {
            client.ClientCredentials.Windows.ClientCredential.Domain   = ConfigurationSettings.AppSettings["Domain"];
            client.ClientCredentials.Windows.ClientCredential.UserName = ConfigurationSettings.AppSettings["User"];
            client.ClientCredentials.Windows.ClientCredential.Password = ConfigurationSettings.AppSettings["PWD"];
            UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
            {
                ItemTypes = new[] { ItemType.PublicationTarget, ItemType.Publication, ItemType.Component, ItemType.Page, ItemType.Keyword }
                ,
                IncludeLocalCopies = true,
                BaseColumns        = ListBaseColumns.Extended,
            };

            PublicationsFilterData filter = new PublicationsFilterData
            {
                BaseColumns = ListBaseColumns.IdAndTitle
            };
            XElement publications = client.GetSystemWideListXml(filter);


            XElement elist = client.GetListXml("tcm:3-1973", usingItemsFilterData);

            List <Result> lstRS = new List <Result>();

            IEnumerable <XElement> usingXML1 = (from el in elist.Elements()
                                                //where (string)el.Attribute("IsPublished").Value == "true"
                                                select el);


            return(true);
        }
    public static IEnumerable <string> ItemURIsInOrganizationalItem(this CoreServiceClient client, string organizationalItemId)
    {
        var filter = new OrganizationalItemItemsFilterData();
        var comps  = client.GetListXml(organizationalItemId, filter);

        return(comps.Descendants().Select(itemElement => itemElement.Attribute("ID").Value));
    }
Esempio n. 4
0
    public static IEnumerable <string> ComponentURIsInFolder(this CoreServiceClient client, string folderId, string schemaId = null)
    {
        var filter = new OrganizationalItemItemsFilterData();

        filter.ItemTypes = new ItemType[] { ItemType.Component };
        if (schemaId != null)
        {
            filter.BasedOnSchemas = new[] { new LinkToSchemaData {
                                                IdRef = schemaId
                                            } }
        }
        ;
        var comps = client.GetListXml(folderId, filter);

        return(comps.Descendants().Select(itemElement => itemElement.Attribute("ID").Value));
    }
    public static IEnumerable <XElement> ItemsInFolder(this CoreServiceClient client, string folderId, string schemaId = null)
    {
        var filter = new OrganizationalItemItemsFilterData {
            ItemTypes = new [] { ItemType.Component }
        };

        if (schemaId != null)
        {
            filter.BasedOnSchemas = new[] { new LinkToSchemaData {
                                                IdRef = schemaId
                                            } }
        }
        ;
        var comps = client.GetListXml(folderId, filter);

        return(comps.Descendants());
    }
Esempio n. 6
0
        public static bool listComponent(CoreServiceClient client, string path)
        {
            try
            {
                client.ClientCredentials.Windows.ClientCredential.Domain   = ConfigurationSettings.AppSettings["Domain"];
                client.ClientCredentials.Windows.ClientCredential.UserName = ConfigurationSettings.AppSettings["User"];
                client.ClientCredentials.Windows.ClientCredential.Password = ConfigurationSettings.AppSettings["PWD"];//


                XElement elist = client.GetListXml(ConfigurationSettings.AppSettings["FolderTCM_ID"].ToString(), new OrganizationalItemItemsFilterData
                {
                    ItemTypes   = new[] { ItemType.Component },
                    Recursive   = true,
                    BaseColumns = ListBaseColumns.Default
                });

                List <Result>         lstRS = new List <Result>();
                System.Data.DataTable dt    = new System.Data.DataTable();
                Stopwatch             watch = new Stopwatch();
                TimeSpan timeSpan           = new TimeSpan();

                watch.Start();
                IEnumerable <XElement> elist1 = (from el in elist.Elements()
                                                 //where (string)el.Attribute("IsPublished").Value == "true"
                                                 select el);
                foreach (var x in elist1.ToArray())
                {
                    Result rs = new Result();
                    try
                    {
                        UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
                        {
                            ItemTypes = new[] { ItemType.PublicationTarget, ItemType.Publication, ItemType.Component, ItemType.Page, ItemType.Keyword }
                            ,
                            IncludeLocalCopies = true
                        };

                        XElement usingXML = client.GetListXml(x.FirstAttribute.Value, usingItemsFilterData);
                        #region Comment
                        //BluePrintChainFilterData filter = new BluePrintChainFilterData();
                        //filter.Direction = BluePrintChainDirection.Down;
                        //XElement result = client.GetListXml(x.FirstAttribute.Value, filter);
                        //IEnumerable<XElement> result1 = (from el in result.Elements()
                        //                                     //where (string)el.Attribute("IsPublished").Value == "true"
                        //                                 select el);
                        //StringBuilder sbBlueChain = new StringBuilder();
                        //StringBuilder sbLocal = new StringBuilder();
                        //foreach (var z in result1.ToArray())
                        //{
                        //    sbBlueChain.Append(z.FirstAttribute.Value + " ; ");
                        //    if (z.Attribute("FromPub") != null)
                        //    {
                        //        sbLocal.Append(z.Attribute("FromPub").Value + " ; ");
                        //    }

                        //}
                        //rs.Blueprint_Chain_TCM_ID = sbBlueChain.ToString();
                        // rs.LocalCopy = sbLocal.ToString();
                        #endregion
                        IEnumerable <XElement> usingXML1 = (from el in usingXML.Elements()
                                                            select el);
                        StringBuilder sbComponent          = new StringBuilder();
                        StringBuilder sbKeyword            = new StringBuilder();
                        StringBuilder sbPage               = new StringBuilder();
                        StringBuilder sbPublicationNameWL  = new StringBuilder();
                        StringBuilder sbPublicationNameWOL = new StringBuilder();
                        if (usingXML1.ToArray().Count() < 2 && usingXML1.ToArray().Count() != 0)
                        {
                            rs.TCM_ID = x.FirstAttribute.Value;
                            rs.Title  = x.Attribute("Title").Value;
                            foreach (var y in usingXML1.ToArray())
                            {
                                if (y.Attribute("Type").Value == "16" && y.Attribute("CommentToken") != null)
                                {
                                    sbComponent.Append(y.FirstAttribute.Value + " ; ");
                                    sbPublicationNameWL.Append(y.Attribute("Publication").Value + " ; ");
                                }
                                if (y.Attribute("Type").Value == "16" && y.Attribute("CommentToken") == null)
                                {
                                    sbComponent.Append(y.FirstAttribute.Value + " ; ");
                                    sbPublicationNameWOL.Append(y.Attribute("Publication").Value + " ; ");
                                    #region Demote
                                    //Demote Logic
                                    //string strPubID = string.Empty;
                                    //strPubID = lookUpPublication(y.Attribute("Publication").Value);
                                    //OperationInstruction instruction = new OperationInstruction { Mode = OperationMode.FailOnError };
                                    //OperationResultDataOfRepositoryLocalObjectData result = client.Promote(x.FirstAttribute.Value, strPubID, instruction, new ReadOptions());

                                    //if (result.ValidationWarnings.Length > 0)
                                    //{
                                    //    Console.WriteLine("Validation warnings:");
                                    //    foreach (ValidationWarningData warning in result.ValidationWarnings)
                                    //    {
                                    //        Console.WriteLine("\tMessage:{0} | Source:{1} | Location:{2}",
                                    //            warning.Message, warning.Source, warning.Location);
                                    //    }
                                    //}

                                    #endregion
                                }

                                //if (y.Attribute("Type").Value == "64")
                                //{
                                //    sbPage.Append(y.FirstAttribute.Value + " ; ");
                                //    sbPublicationNameWL.Append(y.Attribute("Publication").Value + " ; ");
                                //}
                            }
                            rs.Using_Component_Tcm_ID = (string.IsNullOrEmpty(sbComponent.ToString())) ? "NA" : sbComponent.ToString();
                            rs.using_Page_tcm_id      = (string.IsNullOrEmpty(sbPage.ToString())) ? "NA" : sbPage.ToString();
                            // rs.using_keyword_tcm_id = (string.IsNullOrEmpty(sbKeyword.ToString())) ? "NA" : sbKeyword.ToString();
                            rs.Using_Publication_name_With_Local    = (string.IsNullOrEmpty(sbPublicationNameWL.ToString())) ? "NA" : sbPublicationNameWL.ToString();
                            rs.Using_Publication_name_Without_Local = (string.IsNullOrEmpty(sbPublicationNameWOL.ToString())) ? "NA" : sbPublicationNameWOL.ToString();
                            if (rs.TCM_ID != null)
                            {
                                lstRS.Add(rs);
                                rs = null;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ExcelUtility.WriteLog(ex, "elist1");
                        rs = null;
                    }
                    timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(watch.Elapsed.TotalSeconds));
                    Console.Write(timeSpan.ToString("c"));
                    Console.Write('\r');
                }

                lstRS        = lstRS.AsEnumerable().ToList();
                dt           = ToDataTable(lstRS);
                dt.TableName = "REPORT";



                ExcelUtility.WriteDataTableToExcel(dt, @"Report.xlsx");
                Console.WriteLine("Total Records Are " + lstRS.Count() + System.Environment.NewLine);
                Console.WriteLine("Total Time Taken " + timeSpan.Hours + ":" + timeSpan.Minutes + ":" + timeSpan.Seconds + ":" + timeSpan.Milliseconds);
                //var x= elist.Descendants().Count();
                return(true);
            }
            catch (Exception ex)
            {
                ExcelUtility.WriteLog(ex, "MainFunction");
                return(false);
            }
        }
Esempio n. 7
0
 public XElement GetListXml(string id, SubjectRelatedListFilterData filter)
 {
     return(_client.GetListXml(id, filter));
 }