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

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

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

  • 相关阅读:
    2021.5.16 Android聊天功能
    2021.5.15 Android Gestures示例
    2021.5.14 程序员修炼之路:从小工到专家阅读笔记02
    KL 散度和交叉熵
    UBOOT学习
    UCOSII学习
    cortex-M3/M4体系学习
    一步步写RTOS
    38 操作系统-中断处理与特权级转移
    MDK、IAR将变量定义到指定位置
  • 原文地址:https://www.cnblogs.com/virusswb/p/1370045.html
Copyright © 2011-2022 走看看