惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
L
LangChain Blog
C
Check Point Blog
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
美团技术团队
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗
腾讯CDC
B
Blog
G
Google Developers Blog
The Cloudflare Blog
P
Proofpoint News Feed

博客园 - 张谊

[转]ubuntu下 手动安装 LAMP 和 JAVA环境 [转]ViewState的使用 [转]Working with user roles and permissions in SharePoint Object Model [原]SharePoint文档库上传文档 [转]ASP.NET缓存概念及其应用浅析 window.showModalDialog以及window.open用法简介 [原]欢迎加入QQ群 [原]如何在Silverlight中使用WebService绑定DataGrid [转]Silverlight中调用远程Web Service的权限问题 [转]BeanUtils接口和类 [原]Commons- BeanUtils学习笔记 [转]Apache+Tomcat负载均衡及Session绑定的实现 [原]基于Caché多维数据库的SSH实现 [原]关于支付宝API开发的一点心得 [原]Oracle中列自增的方法 [原]Java反射示例 [原]JavaSocket实现广播聊天室 [转]翻译 一些很酷的.Net技巧 《生命如一泓清水》
[原]SharePoint列表与文档库EventHandeler
张谊 · 2009-09-12 · via 博客园 - 张谊

列表的EventHandeler:

1.继承SPItemEventReceiver

2.将SPItemEventReceiver中的方法重写就可以了,但是删除的时候要记得是重写Deleting方法

3.部署将dll拷贝到GAC中

Code

实现步骤:
(1)类要继承   IListEventSink。
(2)重载事件
void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent listEvent) {
if (listEvent.Type == SPListEventType.Insert)//增加{}

if (listEvent.Type == SPListEventType.Delete)//删除{}
if (listEvent.Type == SPListEventType.Update )//修改{}
}
(3) 添加强命名

部署步骤:
(1)把EventHandler的DLL放在服务器里面的GAC里面.
(2)然后在文档库设置的高级设置里,把DLL的信息填入
(如果没有,请在管理中心->应用程序管理->Web 应用程序常规设置-> 向后兼容的事件处理程序->启用).
(3)重启IIS.

部署程序:

Eventhandler-Deploy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;namespace Deploy
{
    
class Program
    {
        
static void Main(string[] args)
        {
            
try
            {
                
using(SPSite site = new SPSite(SPContext.Current.Web.Url))
                {
                    
using(SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates 
= true;
                        site.AllowUnsafeUpdates 
= true;
                        SPList list 
= web.Lists["用户信息"];
                        
string assName = "xxx.xxx.xxx.xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ba17c498abfc3b38";
                        
string className = "xxx.xxx.xxx.xxx";

                        list.EventReceivers.Add(SPEventReceiverType.ItemUpdating,assName,className);
                        list.EventReceivers.Add(SPEventReceiverType.ItemDeleting,assName,className);
                        Console.WriteLine(

"部署已完成");
                        Console.ReadLine();
                    }

                }
            }

catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}