I am migrating Tridion version 2009 to 2011. My existing event code of the EventSystem
in Tridion 2009 for event named OnPagePublishPost
is like below.
public void OnPagePublishPost(Tridion.ContentManager.Interop.TDS.Page page, IXMLDOMDocument2 publishResult, EventPhases phase)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(publishResult.xml);
XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
ns.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
string publishOrUnpublish;
publishOrUnpublish = doc.DocumentElement.SelectSingleNode("/tcm:PublishResponse/tcm:PublisherRequest/tcm:Instruction/@Title", ns).Value;
EventHelper.WriteEventToHTMLLog("publishOrUnpublish: " + publishOrUnpublish);
String pubTargUri = doc.DocumentElement.SelectSingleNode("/tcm:PublishResponse/tcm:PublisherRequest/tcm:PublicationTarget/@xlink:href", ns).Value;
EventHelper.WriteEventToHTMLLog("pubTargUri: " + pubTargUri);
string schemaID = Convert.ToString(page.ComponentPresentations[1].Component.Schema.ID;
}
Now when I subscribe this event using below code, shows me the error.
EventSystem.Subscribe<Tridion.ContentManager.CommunicationManagement.Page,
PublishEventArgs>(OnPagePublishPost, EventPhases.Processed);
Error Message
The best overloaded method match for 'Tridion.ContentManager.Extensibility.EventSystem.Subscribe<Tridion.ContentManager.CommunicationManagement.Page,Tridion.ContentManager.Extensibility.Events.PublishEventArgs>(Tridion.ContentManager.Extensibility.TcmEventHandler<Tridion.ContentManager.CommunicationManagement.Page,Tridion.ContentManager.Extensibility.Events.PublishEventArgs>, Tridion.ContentManager.Extensibility.EventPhases)' has some invalid arguments
I know something is going wrong with the parameter type IXMLDOMDocument2
, but not getting how to solve this problem.
OnPagePublishPost
code, then read the answer from @user978511, else I suggest you edit your question and add the rest of your 2011 event system code. – Bart Koopman Feb 26 '14 at 14:03