SharePoint【事件处理器】-- SPEventReceiver的一点总结
2013-02-21 08:50
344 查看
以下内容是对SPEventReceiver的一点总结
一、概述
五种事件处理器基类:
1、SPItemEventReceiver
2、SPListEventReceiver
3、SPEmailEventReceiver
4、SPWebEventReceiver
5、SPWorkflowEventReceiver
SPItemEventReceiver包含如下方法:
源文档 <http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver_methods.aspx>
每个方法都有一个SPItemEventProperties参数,包含很多关于提交记录的相关信息。
具体信息请参考MSDN文档 http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventproperties_members.aspx
二、结构分析(以SPItemEventReceiver为例):
View Code
五、事件接收器,返回错误信息的时候,界面不友好;我们可以自己写一个错误页;
方法:layouts下新建一个error页面,接收错误信息并显示。
转载:/article/5799259.html
一、概述
五种事件处理器基类:
1、SPItemEventReceiver
2、SPListEventReceiver
3、SPEmailEventReceiver
4、SPWebEventReceiver
5、SPWorkflowEventReceiver
SPItemEventReceiver包含如下方法:
Name | Description |
ContextEvent | This member is reserved for internal use and is not intended to be used directly from your code. |
DisableEventFiring | Obsolete. Prevents events from being raised. (Inherited from SPEventReceiverBase.) |
EnableEventFiring | Obsolete. Enables events to be raised. (Inherited from SPEventReceiverBase.) |
Equals | (Inherited from Object.) |
Finalize | (Inherited from Object.) |
GetHashCode | (Inherited from Object.) |
GetType | (Inherited from Object.) |
ItemAdded | Handles the asynchronous event that occurs after an item is added. |
ItemAdding | Handles the synchronous event that occurs before an item is added. |
ItemAttachmentAdded | Handles the asynchronous event that occurs after an attachment is added to an item. |
ItemAttachmentAdding | Handles the synchronous event that occurs before an attachment is added to an item. |
ItemAttachmentDeleted | Handles the asynchronous event that occurs after an attachment is removed from an item. |
ItemAttachmentDeleting | Handles the synchronous event that occurs before an attachment is removed from an item. |
ItemCheckedIn | Handles the asynchronous event that occurs after an item is checked in. |
ItemCheckedOut | Handles the asynchronous event that occurs after an item is checked out. |
ItemCheckingIn | Handles the synchronous event that occurs before an item is checked in. |
ItemCheckingOut | Handles the synchronous event that occurs before an item is checked out. |
ItemDeleted | Handles the asynchronous event that occurs after an item is deleted. |
ItemDeleting | Handles the synchronous event that occurs before an item is deleted. |
ItemFileConverted | Handles the asynchronous event that occurs after a file in a document library is converted from one type to another. |
ItemFileMoved | Handles the asynchronous event that occurs after a file is moved. |
ItemFileMoving | Handles the synchronous event that occurs before a file is moved. |
ItemUncheckedOut | Handles the asynchronous event that occurs after an item is unchecked out. |
ItemUncheckingOut | Handles the synchronous event that occurs before an item checkout is discarded. |
ItemUpdated | Handles the asynchronous event that occurs after an item is changed. |
ItemUpdating | Handles the synchronous event that occurs before an item is changed. |
ItemVersionDeleted | Occurs after an item or file version is deleted. |
ItemVersionDeleting | Occurs when an item or file version is being deleted. |
MemberwiseClone | (Inherited from Object.) |
ToString | (Inherited from Object.) |
SPItemEventProperties方法和属性说明 | |
方法和属性 | 说明 |
BeforeProperties | 获取事件发生前的数据 |
AfterProperties | 事件发生后的数据,AfterProperties类型是SPItemEventDataCollection,可以通过其ChangeedProperties属性在前处理事件中给列表赋值 |
AfterUrl | 事件发生后文件的URL |
EventType | 事件类型 |
ListItem | 列表项对象 |
ListItemId | 列表项Id |
ListTitle | 列表标题 |
CurrentUserId | 当前用户ID |
UserDisplayName | 当前用户名 |
UserLoginName | 当前用户登录名 |
RelativeWebUrl | 站点的相对url |
SiteId | 当前站点的ID |
WebUrl | 当前站点的url |
OpenWeb | 采用此方法打开当前的站点对象,站点对象打开之后需要用Dispose方法进行释放。或者用using |
ReceiverData | 事件处理器关联的数据 |
Cancel | 释放取消事件的执行。 |
ErrorMessage | 事件取消时显示的错误消息 |
每个方法都有一个SPItemEventProperties参数,包含很多关于提交记录的相关信息。
具体信息请参考MSDN文档 http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventproperties_members.aspx
二、结构分析(以SPItemEventReceiver为例):
View Code
public override void ItemUpdated(SPItemEventProperties properties) { this.EventFiringEnabled = false; properties.ListItem["Title"] = "Title"; properties.ListItem.SystemUpdate(); this.EventFiringEnabled = true; }
五、事件接收器,返回错误信息的时候,界面不友好;我们可以自己写一个错误页;
方法:layouts下新建一个error页面,接收错误信息并显示。
properties.Cancel = true; properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl; properties.RedirectUrl = "/_layouts/EventReceiverProject3/Error.aspx?error=" + SPHttpUtility.UrlKeyValueEncode("u are wrongs!");
转载:/article/5799259.html
相关文章推荐
- SharePoint 2010中, SPEventReceiverBase.EnableEventFiring和DisableEventFiring都已废弃(obsolete), 应使用SPEventReceiverBase.EventFiringEnabled
- 【sharepoint】SPEventReceiverStatus.CancelWithRedirectUrl 出错的请看这里
- 为incoming mail绑定事件,SPEmailEventReceiver
- Javascript's Event 的一点总结
- SharePoint中的EventReceiver 之二 绑定Event Receiver到列表类型或列表实例
- SharePoint中的EventReceiver 之二 绑定Event Receiver到列表类型或列表实例
- SharePoint 2010部署WCF续 - feature event receiver实现自动部署
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第7章节--打包并部署SP2013 Apps 总结
- SharePoint 2013 app 实战之 RemoteEventReceiver
- 对WF工作流异常(Event on interface type for instance id cannot be delivered)的一点总结.
- [SharePoint 2013] Create event receiver for external list
- SPEmailEventReceiver的使用(2)问题总结
- SharePoint对象模型操作SPWeb对象总结
- 每日总结:DIV弹层遮盖、DIV设置透明背景色、JS调用SharePoint 中的SP.UI.ModalDialog弹出遮盖层显示
- SharePoint对象模型操作SPWeb对象总结
- 每日总结:DIV弹层遮盖、DIV设置透明背景色、JS调用SharePoint 中的SP.UI.ModalDialog弹出遮盖层显示
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers 总结
- Javascript's Event 的一点总结 http://www.playes.net/Blog/242.asp
- 关于c++内存的一点总结20150603
- 2014-11-03 阅读源代码一点总结