예제 #1
0
        static void Main()
        {
            SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient("netTcp_2013");

            ContentManager cm = new ContentManager(client);
            List<Source> sources = cm.GetSources();
            foreach (var source in sources)
            {
                List<Article> articles = cm.GetArticlesForSource(source);
                foreach (Article article in articles)
                {
                    string id = article.Id.ToString().Replace("tcm:4", "tcm:5");
                    if(!client.IsPublished(id, "tcm:0-2-65537", true))
                        cm.Publish(new []{id}, "tcm:0-2-65537");
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient("netTcp_2013");

            ContentManager cm = new ContentManager(client);
            List<Source> sources = cm.GetSources();

            foreach (Source source in sources)
            {

                List<Article> articles = cm.GetArticlesForSource(source);
                Console.WriteLine("Checking {0} articles for source {1}", articles.Count, source.Title);
                foreach (Article article in articles)
                {
                    if(cm.IsArticleInPage(article))
                        continue;
                    Console.WriteLine("Article {0} was not in any page... adding.", article.Title);
                    string sg = cm.GetStructureGroup(source.Title, cm.ResolveUrl(Constants.RootStructureGroup));
                    string yearSg = cm.GetStructureGroup(article.Date.Year.ToString(CultureInfo.InvariantCulture), sg);
                    cm.AddToPage(yearSg, article);
                }

            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            const string titleOfSourceToRemove = "Meet John Song";
            SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient("netTcp_2013");

            ContentManager cm = new ContentManager(client);
            List<Source> sources = cm.GetSources();
            Source sourceToRemove = sources.FirstOrDefault(source => source.Title == titleOfSourceToRemove);
            if (sourceToRemove == null)
            {
                Console.WriteLine("Could not find source with name " + titleOfSourceToRemove);
                return;
            }

            // find all usages of the source
            // Delete all pages for the source
            // Unpublish all pages & Components
            // Delete
            List<Article> articles = cm.GetArticlesForSource(sourceToRemove);
            List<string> ids = new List<string>();
            List<string> pageIds = new List<string>();
            foreach (Article article in articles)
            {
                ids.Add(article.Id);
                string pageId = cm.GetPageIdForArticle(article);
                if (pageId != null)
                {
                    pageIds.Add(pageId);
                }
            }

            // need pages
            cm.Unpublish(ids.ToArray(), "tcm:0-2-65537");
            cm.Unpublish(pageIds.ToArray(), "tcm:0-2-65537");
            Console.WriteLine("Wait for unpublish to finish...");
            Console.Read();
            // Must delete pages first

            foreach (string pageId in pageIds)
            {
                try
                {
                    if(client.IsExistingObject(pageId))
                        client.Delete(pageId);
                }
                catch (Exception ex)
                { Console.WriteLine("Could not delete item with ID: " + pageId + ex.ToString()); }

            }

            foreach (string id in ids)
            {
                try
                {
                    if(client.IsExistingObject(id))
                        client.Delete(id);
                }
                catch(Exception ex)
                { Console.WriteLine("Could not delete item with ID: " + id + ex.ToString());}

            }
        }