Public override void featureactivated (spfeaturereceiverproperties properties)
{
Try
{
Using (spsite site = new spsite (spsite) properties. feature. Parent). url ))
{
String shortename = "demetersoft. kipformoss. workflow. feature. eventhandler, version = 1.0.0.0, culture = neutral, publickeytoken = 486e336fb7c97750 ";
String eventhandlernamespace = "demetersoft. kipformoss. workflow. feature. eventhandler .";
String hqreceivedoclib_itemupdatedname = "hqreceivedoclib_eventhandler ";
String hqissuedoclib_itemupdatedname = "hqissuedoclib_eventhandler ";
Splist hqreceivedoclib = site. rootweb. Lists ["headquarters receiving library"];
Splist hqissuedoclib = site. rootweb. Lists ["headquarters development library"];
For (INT I = 0; I {
Speventreceiverdefinition extends ER = hqissuedoclib. eventreceivers [I];
If (Explorer. Class. Equals (eventhandlernamespace + hqreceivedoclib_itemupdatedname ))
{
Explorer. Delete ();
}
}
For (INT I = 0; I {
Speventreceiverdefinition extends ER = hqissuedoclib. eventreceivers [I];
If (Explorer. Class. Equals (eventhandlernamespace + hqissuedoclib_itemupdatedname ))
{
Explorer. Delete ();
}
}
Hqreceivedoclib. eventreceivers. Add (speventreceivertype. itemupdated, incluename, eventhandlernamespace + hqreceivedoclib_itemupdatedname );
Hqissuedoclib. eventreceivers. Add (speventreceivertype. itemupdated, incluename, eventhandlernamespace + hqissuedoclib_itemupdatedname );
}
}
Catch (exception ex)
{
// Exception Handling
Return;
}
}
First, we need to clear that there may be multiple identical events and they all run
It is best to delete the speventreceiverdefinition. class with the Assembly + class name.
Because you may deploy multiple identical time handles to prevent accidental deletion of other
Console test master code
Public static void actiontofeaturereceiver (spsite site)
{
Using (spweb rootweb = site. rootweb)
{
Splist hqdispatchlist = rootweb. Lists ["mytestfolder"];
Speventreceiverdefinitioncollection receivercol = hqdispatchlist. eventreceivers;
String shortename = "demetersoft. kipformoss. workflow. feature. eventhandler, version = 1.0.0.0, culture = neutral, publickeytoken = 486e336fb7c97750 ";
String eventhandlernamespace = "demetersoft. kipformoss. workflow. feature. eventhandler .";
String hqreceivedoclib_itemupdatedname = "hqreceivedoclib_eventhandler ";
String hqissuedoclib_itemupdatedname = "hqissuedoclib_eventhandler ";
For (INT I = 0; I {
Speventreceiverdefinition extends ER = hqdispatchlist. eventreceivers [I];
If (Explorer. Class. Equals (eventhandlernamespace + hqreceivedoclib_itemupdatedname ))
{
Explorer. Delete ();
}
}
Hqdispatchlist. eventreceivers. Add (speventreceivertype. itemupdated, incluename, eventhandlernamespace + hqreceivedoclib_itemupdatedname );
Hqdispatchlist. eventreceivers. Add (speventreceivertype. itemupdated, incluename, eventhandlernamespace + hqissuedoclib_itemupdatedname );
For (INT I = hqdispatchlist. eventreceivers. Count; I> 0; I --)
{
Speventreceiverdefinition extends ER = hqdispatchlist. eventreceivers [I-1];
Console. writeline (aggreger. Class );
Console. writeline (Explorer. GetType (). basetype );
Console. writeline (Explorer. type. tostring ());
Console. writeline ("=========================== ");
}
Console. Readline ();
}
}
Output:
Demetersoft. kipformoss. workflow. feature. eventhandler. hqreceivedoclib_eventhandler
System. Object
Itemupdated
======================================
Demetersoft. kipformoss. workflow. feature. eventhandler. hqissuedoclib_eventhandler
System. Object
Itemupdated
======================================