2
public void PublishComponent()
    {
        string domainName = System.Configuration.ConfigurationSettings.AppSettings["domainName"];
        string userName = System.Configuration.ConfigurationSettings.AppSettings["userName"];
        string passowrd = System.Configuration.ConfigurationSettings.AppSettings["passowrd"];
        timestamp = DateTime.Now.ToString("dd:MM:yy h:mm:ss tt").Replace(":", "_").Replace(" ", "");
        string content = string.Empty;
        client = CoreServiceClientFactory.GetClient();
        string[] pageList = System.IO.File.ReadAllLines(Environment.CurrentDirectory + "\\" + "pagepublish.txt");
        //string[] pageList = System.IO.File.ReadAllLines(Environment.CurrentDirectory + "\\" + "publish.txt");
        string[] publishTargets = new string[] {"live","preview" }; 
        int i = 1;
        int breakValue = 0;
        foreach (var tcmid in pageList)
        {
            string componenttcmid = tcmid;
            string[] page = new string[] { tcmid };
            Console.Write("Start- " + componenttcmid + " - " + i + " of " + pageList.Count());
            Console.WriteLine();

             PublishInstructionData publishInstructionData = new PublishInstructionData
            {
                RenderInstruction = new RenderInstructionData(),
                ResolveInstruction = new ResolveInstructionData()
            };
           if(breakValue == 10)
            {
                breakValue = 0;
                Thread.Sleep(5000);
            }
            try
            {
                client.Publish(page, publishInstructionData, publishTargets, PublishPriority.Normal, new ReadOptions());
                Console.WriteLine(componenttcmid + "Published");

                Console.WriteLine();

            }
            catch (Exception ex)
            {
                Log(componenttcmid+ " - " + ex.Message + ex.StackTrace, "publisherror");
                Log(componenttcmid, "failedpublish");
                //client.Update(ComponentContent, new ReadOptions());
                Console.WriteLine("Failed" + componenttcmid);
            }
            breakValue++;
            i++;
        }
    }

when i triggered publish in tridion core service, but i dont see them appearing in the publish queue/queue_consumers table. In the event log i observed following error:

No Publish Transactions created for (un-)publish action for Publication 'tcm:0-30-1'. Reason: unable to resolve Target Types for purposes: live, preview.

Component: Tridion.ContentManager.Publishing

1

As per your error message "tcm:30-158461-65 - Unexpected item type: 65", it is clear that the Page Id is not correct and it's type should be 64 inplace of 65.

Please check from where the page is coming and correct its type by updating the PageId to "tcm:30-158461-64"

| improve this answer | |
  • that thing got resolved. now newly am facing another issue in log its says published when i checked in tridion publishing queue nothing is there. checked in my server event logger its states No Publish Transactions created for (un-)publish action for Publication 'tcm:0-30-1'. Reason: unable to resolve Target Types for purposes: live, preview. Component: Tridion.ContentManager.Publishing can u help in this – Jeevitha Mar 17 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.