Part of a project I'm working on involves creating a custom timer job which has some properties which are populated via the feature Template.XML file by default.
However, while this is sufficient for development purposes, it becomes a terrible hassle once it's used on a production server. So I wanted to create a configuration page for the timer job.
I've managed to create a custom Application Page visible in Central Administration. However, I'm struggling to get the actual
SPJobDefinition object in the pages' code-behind.
Here's my current code:
var jobs = new List<SPJobDefinition>(); jobs.AddRange(SPAdministrationWebApplication.Local.JobDefinitions); jobs.AddRange(SPFarm.Local.Services.SelectMany(s => s.JobDefinitions)); return jobs.Where(j => j.Name == TimerJobs.SyncTimerJob.JobName).ToList();
The job definitely exists and is being executed, but the above code doesn't return the definition. (I know the above code isn't optimized - I've left it like that to see what results I get!)
What am I doing wrong? How can I get the definition for my custom timer job from an Application Page code-behind deployed in Central Administration?