Here is the code of the subscriptions. As said above, all other events are fired. Just not the move and copy ones.
using System;
using System.Configuration;
using Justitie.Tcm.EventHandlers.EventTypes;
using Justitie.Tcm.EventHandlers.HelperClasses;
using Tridion.ContentManager.CommunicationManagement;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;
namespace Justitie.Tcm.EventHandlers
{
[TcmExtension("EventsHandler")]
public class EventsHandler : TcmExtension, IDisposable
{
EventSubscription _subscription;
private JustitieEvents eventSystem = null;
private string exeConfigPath;
private Configuration config;
public EventsHandler()
{
exeConfigPath = this.GetType().Assembly.Location;
try
{
config = ConfigurationManager.OpenExeConfiguration(exeConfigPath);
}
catch (Exception ex)
{
Logger.WriteLog(LogLevelL4N.ERROR, "No Config file could be found. Errmsg: " + ex.Message);
}
Subscribe();
}
public void Subscribe()
{
//Component save events
_subscription = EventSystem.Subscribe<Component, SaveEventArgs>(HandlerForComponentPreSave, EventPhases.Initiated);
_subscription = EventSystem.Subscribe<Component, SaveEventArgs>(HandlerForComponentPostSave, EventPhases.Processed);
//Component Delete events
_subscription = EventSystem.Subscribe<Component, DeleteEventArgs>(HandlerForComponentPreDelete, EventPhases.Initiated);
_subscription = EventSystem.Subscribe<Component, DeleteEventArgs>(HandlerForComponentPostDelete, EventPhases.Processed);
//Component Publish Events
_subscription = EventSystem.Subscribe<Component, PublishEventArgs>(HandlerForComponentPrePublish, EventPhases.Initiated);
//Page save events
_subscription = EventSystem.Subscribe<Page, SaveEventArgs>(HandlerForPagePreSave, EventPhases.Initiated);
//Page Publish Events
/*_subscription = EventSystem.Subscribe<Page, SetPublishStateEventArgs>(HandlerForPageSetToPublish, EventPhases.Processed);
_subscription = EventSystem.Subscribe<Page, PublishEventArgs>(HandlerForPagePrePublish, EventPhases.Initiated);
_subscription = EventSystem.Subscribe<Page, PublishEventArgs>(HandlerForPagePostPublish, EventPhases.Processed);
_subscription = EventSystem.Subscribe<Page, UnPublishEventArgs>(HandlerForPagePostUnPublish, EventPhases.Processed);*/
//Folder PasteItem Events
_subscription = EventSystem.Subscribe<Folder, MoveEventArgs>(HandlerForFolderPostCutPaste, EventPhases.Processed);
_subscription = EventSystem.Subscribe<Folder, CopyEventArgs>(HandlerForFolderPostCopyPaste, EventPhases.Processed);
}
private void HandlerForComponentPreSave(Component subject, SaveEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnComponentSaveInitiatedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config));
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config), subject.Session, ref eventSystem);
eventSystem.ComponentSavePre(subject, args);
}
private void HandlerForComponentPostSave(Component subject, SaveEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnComponentSaveCommittedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config));
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config), subject.Session, ref eventSystem);
eventSystem.ComponentSavePost(subject, args);
}
private void HandlerForComponentPreDelete(Component subject, DeleteEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnComponentDeleteInitiatedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config));
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config), subject.Session, ref eventSystem);
eventSystem.ComponentPreDelete(subject);
}
private void HandlerForComponentPostDelete(Component subject, DeleteEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnComponentDeleteCommittedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config));
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config), subject.Session, ref eventSystem);
eventSystem.ComponentPostDelete(subject);
}
private void HandlerForComponentPrePublish(Component subject, PublishEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnComponentPublishInitiatedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config));
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config), subject.Session, ref eventSystem);
eventSystem.ComponentPrePublish(subject, args);
}
private void HandlerForPagePreSave(Page subject, SaveEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called PageSavePre " + phase.ToString() + " on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.PageSavePre(subject, args);
}
private void HandlerForPageSetToPublish(Page subject, SetPublishStateEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called PageSetToPublish " + phase.ToString() + " on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.PageSetPublishedToPost(subject, args);
}
private void HandlerForPagePrePublish(Page subject, PublishEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called PagePrePublish " + phase.ToString() + " on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.PagePrePublish(subject, args);
}
private void HandlerForPagePostPublish(Page subject, PublishEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called PagePostPublish " + phase.ToString() + " on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.PagePostPublish(subject, args);
}
private void HandlerForPagePostUnPublish(Page subject, UnPublishEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called PagePostUnPublish " + phase.ToString() + " on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.PagePostUnPublish(subject, args);
}
private void HandlerForFolderPostCutPaste(Folder subject, MoveEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnFolderPasteItemCommittedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.FolderPostCutPasteItem(subject, args);
}
private void HandlerForFolderPostCopyPaste(Folder subject, CopyEventArgs args, EventPhases phase)
{
Logger.WriteLog(LogLevelL4N.DEBUG, "Called OnFolderPasteItemCommittedEvent on Events: " + Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString());
Utilities.LoadEventSystem(exeConfigPath, Utilities.GetPubEventSystem(subject.OwningRepository.Title, config).ToString(), subject.Session, ref eventSystem);
eventSystem.FolderPostCopyPasteItem(subject, args);
}
public void Dispose()
{
_subscription.Unsubscribe();
}
}
}