Content events

From Sense/Net Wiki
Jump to: navigation, search
  •  
  •  
  •  
  •  
  • 100%
  • 6.3
  • Enterprise
  • Community
  • Planned

Overview

The main building blocks of Sense/Net Content Repository are Content. When you manage your repository, you create content, modify or move them around. Many Sense/Net features create content in the background too (e.g. when you post something on the Workspace wall). You as a developer may expect to be notified about these content changes to be able to create smart solutions for a wide variety of business problems. In this article you can learn about the technologies that make this possible.

Events

In this section we list all the content events that you can attach to and execute your custom code. You will learn about the different technologies in the subsequent sections.

Content events
Method name Description Fired on Cancellable
Creating Saving a new content. every item Ok-icon4.png
Created A new content has been saved. every item
Modifying Saving a content. only on the subtree root Ok-icon4.png
Modified A content has been saved. only on the subtree root
Deleting A content is being deleted. CURRENTLY NOT AVAILABLE
Deleted A content has been deleted. CURRENTLY NOT AVAILABLE
DeletingPhysically A content is being deleted avoiding the trash only on the subtree root Ok-icon4.png
DeletedPhysically A content has been deleted avoiding the trash only on the subtree root
Copying A content is being copied every item Ok-icon4.png
Copied A content has been copied every item
Moving A content is being moved only on the subtree root Ok-icon4.png
Moved A content has been moved only on the subtree root
Permission changing Content permissions are being changed only on the subtree root Ok-icon4.png
Permission changed Content permissions have changed only on the subtree root

Please note that currently the Deleting and Deleted events are not fired. Please use the DeletingPhysically/DeletedPhysically (when deleting the content permanently) or the Moving/Moved events (when deleting to the Trash) respectively.

Handle content events of multiple content types with node observer

The NodeObserver technology lets you execute code when any content changes in the system. We recommend using it when you do not have access to the content handler or you want to address multiple types of content.

Handle content events of one content type with its content handler

The Content Handler is the 'codebehind' file for a specific Content Type. If you want to execute custom logic that is related to only this content type, you can place your event handler code into the content handler. You can handle events by overriding the following methods:

protected virtual void OnCreating(object sender, Storage.Events.CancellableNodeEventArgs e);
protected virtual void OnCreated(object sender, Storage.Events.NodeEventArgs e);
protected virtual void OnModifying(object sender, Storage.Events.CancellableNodeEventArgs e);
protected virtual void OnModified(object sender, Storage.Events.NodeEventArgs e);
protected virtual void OnDeleting(object sender, Storage.Events.CancellableNodeEventArgs e);
protected virtual void OnDeleted(object sender, Storage.Events.NodeEventArgs e);
protected virtual void OnDeletingPhysically(object sender, Storage.Events.CancellableNodeEventArgs e);
protected virtual void OnDeletedPhysically(object sender, Storage.Events.NodeEventArgs e);
protected virtual void OnCopying(object sender, Storage.Events.CancellableNodeOperationEventArgs e);
protected virtual void OnCopied(object sender, Storage.Events.NodeOperationEventArgs e);
protected virtual void OnMoving(object sender, Storage.Events.CancellableNodeOperationEventArgs e);
protected virtual void OnMoved(object sender, Storage.Events.NodeOperationEventArgs e);
protected virtual void OnPermissionChanging(object sender, Storage.Events.CancellableNodeEventArgs e);
protected virtual void OnPermissionChanged(object sender, Storage.Events.NodeEventArgs e);

Multistep save

When you upload a large file, the flow of events may not be obvious. In this situation, there is a long-running save operation, and the content events are fired in the following way:

  • initial save: OnCreating/OnModifying event is fired
  • uploading chunks of binary data: no events are fired for chunks
  • finalize content: OnCreated/OnModified event is fired

For more information about a long-running save operation, visit the Multistep saving article.

Related links

References

There are no related external articles for this article.