I had a requirement from customer to develop an archival workflow solution using which they can automate the Site Collection archival based on a set of business rules. The features should be, notify users for the key LOB information expiration based on which the sites were created, Maintain the notification count and based on the count take a call to make a particular site read-only, offline or take a back up & delete it permanently from the content database in case of no action taken to update the key LOB information.
And, just to give you a little idea about the size of the farm, it’s in TBs and there are thousands of site collections created automatically across multiple content databases through an automated process. so to do the above steps manually for each site collection based on different notification counter values and repeat it every week, was just impossible and that’s how we decided for an automatic site archival solution.
The purpose of this blog post is to give you an idea about the various features and parts of the solution so in case you come across any of the similar business requirement in future then can make use of some of these ideas or code snippets and make your life little easier
This solution has several features like
- Automatic scanning for all Site Collections with expired Key Information(Based on which Site Collections are created)
- Check for the expiration date of Key Information with LOB system(The Origin place of the Key Information)
- Find out the Site Owners
- Validation of the Site Owners with the directory services
- Send configurable email notifications to Site Owners about the Key Information expiration
- Keep track of notifications count
- Automatically extend the Site Collection’s Key Information details in SharePoint if it’s been updated in LOB system
- Make the Site Collection offline based on the notification count in case of no response from Owners
- Take the Site Collection Backup, transfer the back up to a shared location for the archival & delete it to reclaim the used space based on the notification count
- Provision to take an exception for a Site Collection for the Key Information expiration scan & archival
And following are the configuration features of the solution
- Configurable LOB pointer & Workflow Admins list
- Configurable Email Templates for notifications
- Configurable Execution Timing/Schedule
- No IISRESET/ App pool recycle required
- Logging of each execution in the event viewers for the Admin review
So here is how I designed these configuration features
For Configurable LOB pointer & Workflow Admins list, I kept txt files with solution which would contain the connection and Administrator details respectively so can be modified anytime.
Created XML for the email templates and would read the specific template from the code using template id.
Built whole application as an exe so can be configured with windows task scheduler.
Since no deployment of WSP to SharePoint and solution is just a stand alone exe, no IISReset/ App Pool Recycle required.
Used Event viewer for writing the execution log.
Now following are a few Code Snippets which are used for the above functionalities.
For txt read
To check user validity with directory services
To get mail templates from XML
To make NoAccess to the Site Collection
To backup & move the Site Collection in a shared location
To delete Site Collection