-2

Our requirement is to schedule content publishing of a content page to run in recurring intervals in Tridion CMS application. We are currently using Tridion 2009 SP1 version.

As per the suggestion from the experts as in: Tridion 2009 SP1: How to schedule a content page for a recurring publishing? we have created a simple C# console application that has referenced Triond Interop .dll's as below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.TDSDefines;
using Tridion.ContentManager.Interop.msxml4;
using System.Configuration;

namespace SchedulePublish
{
class Program
{        
    static void Main(string[] args)
    {
        //Please use your system related corresponding webdav url's and tcm id's where ever required. Below are just sample :)
        TDSE tdse = new TDSE();
        //Give some identity that has access rights on tridion UI
        string Identity = @"Domain Name\Username";
        tdse.Impersonate(Identity);
        tdse.Initialize();

        string targetTypeId = "tcm:0-1-65537";
        Publication Pub_Obj = (Publication)tdse.GetPublication("/webdav/30%20DIRECTV%20sites");
        XMLReadFilter Filter = new XMLReadFilter();
        Component CompObj = (Component)tdse.GetObject("/webdav/30%20DIRECTV%20sites/Home/System/xml/Knavigation.xml",
                                    EnumOpenMode.OpenModeView, Pub_Obj.ID, Filter);
        DateTime schedulePublishDate = Convert.ToDateTime(ConfigurationManager.AppSettings["SharedPath"].ToString());
        CompObj.Publish(targetTypeId, false, false, false, schedulePublishDate, DateTime.MinValue, DateTime.Now, true, EnumPublishPriority.High, false, 3);
    }
}
}

As we are new, please provide pointers to implement the below steps:

1.Tridion CMS servers do not have Visual studio installed so please suggest a way to run this application and verify if we are able to publish the content as required.

2.Host this application in the Tridion CMS Server and schedule it to run at the desired intervals every week.

Community
  • 1
  • 1
raniworld
  • 45
  • 1
  • Perhaps you can include your App.config - ConfigurationManager.AppSettings["SharedPath"] seems like an odd way to set a scheduled date. I also pointed to the answer here - http://stackoverflow.com/a/14885307/1088449 – Chris Summers Mar 06 '13 at 04:53

1 Answers1

6

You don't need Visual Studio to run your new console app, simply compile it and copy the files to the CMS server.

If you run the application, you should see items appearing in your Publication Queue, if you don't see your items added to the Publish Queue, I would recommend adding some logging calls to your application so you can see where the code is failing (consider using Log4J.NET if you have not done logging before).

Once you have validated that it works as desired, the easiest way to schedule it is to create a task using the Windows Task Scheduler. There is no way to run such a task from within the CMS. Alternatively you could convert your console app to a windows service, but I think this would be overkill in this case.

Chris Summers
  • 10,153
  • 1
  • 21
  • 46
  • Thanks Chris but when we are trying to run compiled code in the CMS Server, we are stuck with the below error: “Unable to cast COM object of type 'Tridion.ContentManager.Interop.TDS.TDSEClass' to interface type 'Tridion.ContentManager.Interop.TDS._TDSE'.” Could you please suggest. – raniworld Mar 06 '13 at 20:09
  • Does your code run on your development machine? Make sure you have referenced all of the interop files from the PIA folder, and that you compiledyour code against the same verion of the DLL as you intend to use on the actual CMS server. I can't test this now, but I will try to try your code out on my server this evening. – Chris Summers Mar 06 '13 at 21:40
  • 1
    Replacing correct version DLLs helped resolving the above error. Am now getting an error as: "Unable to cast COM object of type 'System.__ComObject' to interface type 'Tridio n.ContentManager.Interop.TDS.Component'. This operation failed because the Query Interface call on the COM component for the interface with IID '{77928509-4894-4 2C7-A08B-56DE59D05439}' failed due to the following error: No such interface sup ported (Exception from HRESULT:0x80004002(E_NOINTERFACE)). at AutoPublish_app.Program.Main(String[] args) in D:\AutoPublish\AutoPublish_ app\AutoPublish_app\Program.cs:line 35" – raniworld Mar 07 '13 at 05:34
  • This was resolved when we started using the PageObj in place of ComObj in the above code and now we are able to publish successfully to the specified publication. Now am in need of pointers on how we can publish to child publications as well within the same code ? – raniworld Mar 08 '13 at 17:30
  • Look at the API for the Publish() method - But the first Boolean value in your call is for activateBluePrinting - Set that to true, and it will publish the children also – Chris Summers Mar 08 '13 at 18:16
  • Awesome... all the issues are resolved and its working as intended through Task Scheduler :) Thanks for the help Chris ! – raniworld Mar 13 '13 at 21:00