Synchronous     Asynchronous ItemAdding       ItemAddedItemUpdating     ItemUpdated FieldAdding     FieldUpdatedFieldDelet...
public class CheckJobs : SPItemEventReceiver{  public override void ItemUpdating(SPItemEventProperties properties)  {    s...
public class CatchEmails : SPEmailEventReceiver{  public override void EmailReceived(    SPList list,    SPEmailMessage em...
public class MyListWorkflows : SPWorkflowEventReceiver{  public override void WorkflowStarted(SPWorkflowEventProperties pr...
public class MyAuditTrail : SPListEventReceiver{  public override void FieldDeleting(SPListEventProperties properties)  { ...
public class MyTopologyManager : SPWebEventReceiver{  public override void WebAdding(SPWebEventProperties properties)  {  ...
public class MyTopologyManager :    SPWebEventReceiver{  public override void FeatureActivated    (SPFeatureReceiverProper...
public class SchemaProtector : SPListEventReceiver{  public override void FieldDeleting(SPListEventProperties properties) ...
void setProliferationFlag(){  SPWebApplication webApp = SPWebApplication.Lookup(new    Uri("http://SharePoint"));  SPWebCo...
Estimated time: 45 minutes
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Event recvr ss
Upcoming SlideShare
Loading in …5
×

Event recvr ss

275 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
275
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Event recvr ss

  1. 1. Synchronous Asynchronous ItemAdding ItemAddedItemUpdating ItemUpdated FieldAdding FieldUpdatedFieldDeleting FieldDeleted WebAdding WebProvisioned
  2. 2. public class CheckJobs : SPItemEventReceiver{ public override void ItemUpdating(SPItemEventProperties properties) { string oldJobTitle = properties.BeforeProperties["Title"].ToString(); string newJobTitle = properties.AfterProperties["Title"].ToString(); ... base.ItemUpdating(properties); }}
  3. 3. public class CatchEmails : SPEmailEventReceiver{ public override void EmailReceived( SPList list, SPEmailMessage emailMessage, String receiverData) { string listTitle = list.Title; string sender = emailMessage.Sender; string body = emailMessage.PlainTextBody; ... base.EmailReceived(list, emailMessage, receiverData); }}
  4. 4. public class MyListWorkflows : SPWorkflowEventReceiver{ public override void WorkflowStarted(SPWorkflowEventProperties properties) { string myInitData = properties.InitiationData; ... base.WorkflowStarted(properties); }}
  5. 5. public class MyAuditTrail : SPListEventReceiver{ public override void FieldDeleting(SPListEventProperties properties) { string usrName = properties.UserLoginName; string listTitle = properties.ListTitle; ... base.FieldDeleting(properties); }}
  6. 6. public class MyTopologyManager : SPWebEventReceiver{ public override void WebAdding(SPWebEventProperties properties) { int currentCount = properties.Web.ParentWeb.Webs.Count; ... base.WebAdding(properties); }}
  7. 7. public class MyTopologyManager : SPWebEventReceiver{ public override void FeatureActivated (SPFeatureReceiverProperties properties) { setProliferationFlag(true); } public override void FeatureDeactivating (SPFeatureReceiverProperties properties) { setProliferationFlag(false); } void setProliferationFlag(bool status) { if (status) { ... } else { ... } }}
  8. 8. public class SchemaProtector : SPListEventReceiver{ public override void FieldDeleting(SPListEventProperties properties) { if(properties.Field.Title == "MyRequiredDataField") { properties.ErrorMessage = "You must NOT delete this field."; properties.Status = SPEventReceiverStatus.CancelWithError; properties.Cancel = true; return; } base.FieldDeleting(properties); }}
  9. 9. void setProliferationFlag(){ SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://SharePoint")); SPWebConfigModification mySetting = null; mySetting = new SPWebConfigModification(); mySetting.Path = "configuration/appSettings"; mySetting.Name = "add [@key=preventProliferation] [@value=1]"; mySetting.Sequence = 0; mySetting.Owner = "Lab05Owner"; mySetting.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; mySetting.Value = "<add key=preventProliferation value=1 />"; webApp.WebConfigModifications.Add(mySetting); webApp.Update(); webApp.Farm.Services.GetValue<SPWebService>() .ApplyWebConfigModifications();}
  10. 10. Estimated time: 45 minutes

×