Okay, I've been so goddamn busy, that it sucks that I have so much to blog about, and no time to do so.
Anyway, here is something that I know everyone will find useful at some point or the other.
SharePoint 2007 has a number of timer jobs. These are things that run on a scheduled basis, you can go check out a list of them at
Central Administration > Operations > Timer Job Definitions
So say for instance, I find myself with a client who wants me to deliver a solution based on "Information Management Policy" in a flat 4 hours. Well thats great, except I can't demo that solution because guess what - That job is set to run on a daily basis. I think it would be hella useful to test such things that run based on a timer in a development environment anyway, so there has to be a way to configure these jobs to run on a shorter time schedule.
Luckily, there is such a way.
For instance, the "Information Management Policy" job, is a part of the "PolicyConfigService". So I can use the SharePointAPI to write code as shown below -
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://moss2007"))
{
SPServiceCollection services = site.WebApplication.Farm.Services;
foreach (SPService service in services)
{
if (service.Name == "PolicyConfigService")
{
foreach (SPJobDefinition job in service.JobDefinitions)
{
if (job.Title == "Information management policy")
{
SPMinuteSchedule schedule = new SPMinuteSchedule();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 5;
job.Schedule = schedule;
job.Update();
}
Console.WriteLine("JOB: " + job.Title);
}
}
}
}
}
There you go.
As you can see, I sneakily replaced the schedule for the Information management policy job to a minute based schedule.
Now, when I set a site collection policy to delete a document, I can demonstrate that working in a minute's time.
Purty darned useful I say :).