Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event not working

I am new to Tridion Event System. I have written a small code.

[TcmExtension("MyEventHandlerExtension")]
public class EH : TcmExtension
{
    public EH()
    {
        Subscribe();
    }
    public void Subscribe()
    {
        //EventSystem.Subscribe<Component, DeleteEventArgs>(HandlerForInitiated, EventPhases.Initiated);
        EventSystem.Subscribe<Tridion.ContentManager.CommunicationManagement.Page, Tridion.ContentManager.Extensibility.Events.PublishOrUnPublishEventArgs>(HandlerForCommitted, EventPhases.All);
    }

    private void HandlerForCommitted(IdentifiableObject subject, PublishOrUnPublishEventArgs args, EventPhases phase)
    {

        TDSE obj = new TDSE();
        Tridion.ContentManager.Interop.TDS.Publication pub = obj.GetPublication("tcm:0-150-1");
        Tridion.ContentManager.Interop.TDS.Page pubPage = obj.GetPage("tcm:150-12374-64", pub);
        pubPage.Publish("tcm:0-1-65538", false, true, false, default(DateTime), default(DateTime), default(DateTime));

    }
}

using this code i wanted to publish a page everytime when a publish and unpublish event occur. I build this code and register its path in tridion config file . But its not working.Please Help

like image 976
user1573378 Avatar asked Dec 01 '22 21:12

user1573378


1 Answers

Ok, first of all remove all your TDSE code, you should use TOM.NET. You can get session as subject.Session

Then make sure you have registered this extension in Tridion.ContentManager.config and restarted your system

And finally - if something doesn't work, just add simple code that will create a file in your HandlerForCommitted whenever event occurs, this way you will be able to see if your extension get executed.

like image 101
Andrey Marchuk Avatar answered Jan 22 '23 16:01

Andrey Marchuk