SharePoint provides a framework for tasks that can be executed at scheduled intervals called SharePoint timer jobs. These timer jobs, when configured, are executed by the SharePoint Timer Windows service. In a large site with a lot of contributors, there may be the need to enforce some rules in the environment in a more automated fashion, such as using consistent branding. In this recipe, we will create a timer job that ensures the site branding feature is activated on all sites in the site collection.
Follow these steps to create a timer job:
From the Solution Explorer pane, right-click on the project name.
Select Add and then select Class.
Provide a name for the class (for instance,
BrandingTimerJob
).Give the class a
public
access modifier and inherit from theSPJobDefinition
base class as follows:public class BrandingTimerJob : SPJobDefinition
In the
BrandingTimerJob
class, add a staticGUID
for our SiteBranding...