Handling events is similar to adding a button click on a page. Each event executor creates a copy of the content being executed. For the complete list of the In-Process event arguments please see In-Process API Event Arguments.
Before Create
This sample shows how to write an event log before a blog post is created.
public void Initialize() { PublicApi.Blogs.Events.BeforeCreate += new BlogBeforeCreateEventHandler(BlogEvent_BeforeCreate); } private void BlogEvent_BeforeCreate(BlogBeforeCreateEventArgs blog) { var message = string.Format("{0} is going to be created with {1} ID.", blog.Name, blog.Id); var options = new EventLogEntryWriteOptions { Category = "Samples" }; PublicApi.Eventlogs.Write(message, options); }
After Create
This sample shows how to write an event log after a blog post was created.
public void Initialize() { PublicApi.Blogs.Events.AfterCreate += new BlogAfterCreateEventHandler(BlogEvent_AfterCreate); } private void BlogEvent_AfterCreate(BlogAfterCreateEventArgs blog) { var message = string.Format("{0} was created with {1} ID.", blog.Name, blog.Id); var options = new EventLogEntryWriteOptions { Category = "Samples" }; PublicApi.Eventlogs.Write(message, options); }
Before Update
This sample shows how to write an event log before a blog post is updated.
public void Initialize() { PublicApi.Blogs.Events.BeforeUpdate += new BlogBeforeUpdateEventHandler(BlogEvent_BeforeUpdate); } private void BlogEvent_BeforeUpdate(BlogBeforeUpdateEventArgs blog) { var message = string.Format("{0} is going to be updated with {1} ID.", blog.Name, blog.Id); var options = new EventLogEntryWriteOptions { Category = "Samples" }; PublicApi.Eventlogs.Write(message, options); }
After Update
This sample shows how to write an event log after a blog post was updated.
public void Initialize() { PublicApi.Blogs.Events.AfterUpdate += new BlogAfterUpdateEventHandler(BlogEvent_AfterUpdate); } private void BlogEvent_AfterUpdate(BlogAfterUpdateEventArgs blog) { var message = string.Format("{0} was updated with {1} ID.", blog.Name, blog.Id); var options = new EventLogEntryWriteOptions { Category = "Samples" }; PublicApi.Eventlogs.Write(message, options); }
Before Delete
This sample shows how to write an event log before a blog post is deleted.
public void Initialize() { PublicApi.Blogs.Events.BeforeDelete += new BlogBeforeDeleteEventHandler(BlogEvent_BeforeDelete); } private void BlogEvent_BeforeDelete(BlogBeforeDeleteEventArgs blog) { var message = string.Format("{0} with {1} ID will be deleted.", blog.Name, blog.Id); var options = new EventLogEntryWriteOptions { Category = "Samples" }; PublicApi.Eventlogs.Write(message, options); }
After Delete
This sample shows how to write an event log after a blog post is deleted.
public void Initialize() { PublicApi.Blogs.Events.AfterDelete += new BlogAfterDeleteEventHandler(BlogEvent_AfterDelete); } private void BlogEvent_AfterDelete(BlogAfterDeleteEventArgs blog) { var message = string.Format("{0} with {1} ID was deleted.", blog.Name, blog.Id); var options = new EventLogEntryWriteOptions { Category = "Samples" }; PublicApi.Eventlogs.Write(message, options); }