• SharePoint暂时禁用事件触发


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
     
    namespace DisableEventFiring
    {
       public classEventFiring : SPItemEventReceiver
        {
           public void DisableHandleEventFiring()
            {
               this.EventFiringEnabled =false;
            }
     
           public void EnableHandleEventFiring()
            {
               this.EventFiringEnabled =true;
            }
        }
    }
    
    //sample to use:
    using (SPSite site = new SPSite("https://serverName/sites/Vijai/"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists.TryGetList("Custom");
                        SPListItem item = list.GetItemById(34);
                        item["Title"] ="Updated Successfully";
                        EventFiring eventFiring = newEventFiring();
                        eventFiring.DisableHandleEventFiring();
                        item.Update();
                        eventFiring.EnableHandleEventFiring();
                        Console.WriteLine("Updated Successfully");
                        Console.ReadLine();
                    }
                }
    

    ref: http://www.c-sharpcorner.com/UploadFile/anavijai/programmatically-disable-event-firing-on-list-item-update-in/

  • 相关阅读:
    JS实现类似网页的测试考卷
    Following Orders(poj1270)
    1007
    Intervals(poj1201)
    LightOJ
    1002
    King's Order(hdu5642)
    Beautiful Walls
    A. Watchmen(Codeforces 650A)
    Shortest Path(hdu5636)
  • 原文地址:https://www.cnblogs.com/jianyi0115/p/4092819.html
Copyright © 2020-2023  润新知