zoukankan      html  css  js  c++  java
  • sharepoint中eventhandler的ItemUpdated Virus

    最近在开发Sharepoint的EventHandler的时候发现一个问题,更新事件的接受处理程序的特殊性,要被调用很多次,会达不到我们想要的效果,需要用 this.DisableEventFiring();来关闭事件监听器,在写完更新事件的代码之后要用  this.EnableEventFiring();来开启事件监听器。这个我也是在网上找到的。


    using
     System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;

    namespace CorpTrendEventDemo
    {
        
    public class IitemList : SPItemEventReceiver
        {

            
    public override void ItemUpdated(SPItemEventProperties properties)
            {

                    SPListItem item 
    = properties.ListItem;
                    SPWeb web 
    = item.Web;
                    SPSite site 
    = web.Site;



                    
    this.DisableEventFiring();
                    //修改审批状态
                     item["_ModerationStatus"] = (int)SPModerationStatusType.Approved; 
                     item.Update();
                   

                    item.CopyTo(properties.WebUrl 
    + "/"+properties.OpenWeb().Lists["未发布动态"].RootFolder.Url+"/"+ item.Name);
                    item.Delete();
                    
    this.EnableEventFiring();

             
            }
        }
    }

    【Blog】http://virusswb.cnblogs.com/

    【MSN】jorden008@hotmail.com

    【说明】转载请标明出处,谢谢

    反馈文章质量,你可以通过快速通道评论:

  • 相关阅读:
    记录PHP的执行时间
    Mysql数据字典导出
    PHP用post来进行Soap请求
    laravel(lumen)配置读写分离后,强制读主(写)库数据库,解决主从延迟问题
    使用vagrant构建你们团队的开发环境
    Lumen框架使用Redis与框架Cache压测比较
    使用php-cs-fixer格式化你的代码
    Javascript下拉导航
    jsf2.0视频
    jsf2入门视频 教程
  • 原文地址:https://www.cnblogs.com/virusswb/p/1370045.html
Copyright © 2011-2022 走看看