Answered Delete a work item from an event receiver

  • Saturday, May 05, 2012 7:29 AM
     
      Has Code

    Icrandoatimerjobwith the classand ISPWorkItemJobDefinitiontheconditionin whichI believewith aEventReceiverto knowif there is aworkitemor moreto removequeuedbutnotlike knowingthatdirtrectamentewithsharepointand I amabout tomake astored procedurealthoughit is notallowedif I finda solutionI will have noother.


    Annexthe method whereImake the conditionto see if thereeliminiarall itemsassociated with thatlist item.

    public override void ItemUpdated(SPItemEventProperties properties) { try { SPSite site = properties.OpenSite(); #region GetSchdDateTime Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX"); DateTime dateSendReminder = Convert.ToDateTime(properties.ListItem["FechaHoraEnvioNotificacion"]); DateTime dateCompare = Convert.ToDateTime(properties.ListItem["FechaHoraEnvioNotificacion"]); DateTime dateSend = new DateTime(dateCompare.Year, dateCompare.Month, dateCompare.Day, dateCompare.Hour, dateCompare.Minute, 00); DateTime getDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 00); #endregion GetSchdDateTime Guid webId = properties.Web.ID; Guid listId = properties.ListId; int itemId = properties.ListItem.ID; Guid itemUniqueId = properties.ListItem.UniqueId; int currentUserId = properties.Web.CurrentUser.ID; in this part is where I need to do validation and go look for the database to see if there,delete it and create posterirmente

    if (dateSend >= getDate) { SPSecurity.RunWithElevatedPrivileges(() => { try { site.AddWorkItem( Guid.NewGuid(), dateSendReminder.ToUniversalTime(), new Guid("1549D631-2711-464D-8FD6-CD643F0B44A7"), webId, listId, itemId, false, itemUniqueId, Guid.Empty, currentUserId, null, "FE_Timer_Notificaciones_ItemUpdated", Guid.Empty); }


    Greetings and hopetoguide meandsupport mewith this part.thanks

All Replies