About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



Dumping Dated SharePoint Recycle Bins [Fix]

For whatever rationale, typed iterations to dump particular SPRecycleBinItem objects out of the SharePoint recycle bin don’t work due to a problem with the proc_DeleteRecycleBinItem stored procedure.  But it seems to be indeterminate and I can’t locate any sort of thresholds.

So, for some reason:

C#:
  1. public static void NonWorkingRecycleBinDump(string url)
  2. {
  3. using (SPSite site = new SPSite(url))
  4. {
  5. using (SPWeb web = site.OpenWeb())
  6. {
  7. SPRecycleBinItemCollection coll = site.RecycleBin;
  8. foreach (SPRecycleBinItem item in coll)
  9. {
  10. item.Delete();
  11. }
  12. }
  13. }
  14. }

will not work in some environments, with certain items. I cushion the claim with the “some” because my testing has been limited to my VM, some production stuff, and the SharePoint support engineer’s VM I am talking to. It's nonetheless a frustrating problem to run into.

It should be noted that this apparently isn’t the case however when using the SPWeb.RecycleBin.DeleteAll() if you are doing a complete dump, as detailed here:

http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/dump-recycle-bin-programmatically/

The final solution to the aforementioned problem is documented here:

http://blogs.msdn.com/nishand/archive/2008/06/07/how-to-delete-sprecyclebin-items.aspx

However, this doesn’t take into account hydrating specific DateTime objects. In order to introduce this functionality, we just have to modify this code slightly. In this case, through the use of the DateTime.Compare method, we can remove certain logs based on their DeletedDate property.

C#:
  1. public static void WorkingRecycleBinDump(string url)
  2. {
  3. using (var site = new SPSite(url))
  4. {
  5. using (SPWeb web = site.OpenWeb())
  6. {
  7. SPRecycleBinItemCollection coll = web.RecycleBin;
  8. for (int x = 0; x <coll.Count; x++)
  9. {
  10. var ids = new Guid[1];
  11. DateTime deletedTime = coll[x].DeletedDate;
  12. DateTime selectedTime = [your DateTimeObject];
  13. if (DateTime.Compare(selectedTime, deletedTime)> 0)
  14. {
  15. ids[0] = coll[x].ID;
  16. coll.Delete(ids);
  17. }
  18. x = x - 1;
  19. }
  20. }
  21. }
  22. }

  • Share/Bookmark

1 Comment »

  1. [...] Dumping Dated SharePoint Recycle Bins [Fix] [...]

    Pingback by Links (9/25/2008) « Steve Pietrek - Everything SharePoint — September 25, 2008 @ 5:40 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment