In order to gather the metrics for the active projects we will use a timer job to support the scheduled job scenario reviewed at the beginning of the chapter.
1. Start by adding an Empty Element to the solution.
2. Name the element
SiteMetricsProcess
.3. Within the
SiteMetricsProcess
SPI, we now need to add in a class namedSiteMetricsTimerJob.cs
. This class is where the actual timer job and its execution logic will reside.4. We will need to import the following namespaces to support our work:
using System; using System.Collections.Generic; using System.Data; using Microsoft.Office.Server.Search; using Microsoft.Office.Server.Search.Query; using Microsoft.Office.Server.Search.Administration; using Microsoft.SharePoint; using Microsoft.SharePoint.Administration;
5. Next, we need to inherit from the
SPJobDefinition
class, which will allow us to perform the timer job functions displayed as follows:class SiteMetricsTimerJob :...