Molnar Tibor

blog

  Home  |   Contact  |   Syndication    |   Login
  21 Posts | 10 Stories | 55 Comments | 2 Trackbacks

News

Archives

Post Categories

Image Galleries

When a new timer job is created for Sharepoint, it has to be programatically installed in a SPWebApplication.JobDefinitions of type SPJobDefinitionCollection. If the timer job have to receive some settings during run time, one option would be to use the .Net application configuration feature.

First you might think to copy the configuration section from the app.config of the dll where the timer job resides into the web.config of the web application where the timer job is registered. The first catch: the timer job is loaded by the timer service, which is the 'Windows SharePoint Services Timer' Windows service on the web front end servers and runs the "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\OWSTIMER.EXE" executable, so we have to configure this service.

This can be done by creating the OWSTIMER.EXE.config file near the exe file, and put there the timer job configuration section.

Don't forget to restart the timer service :-).

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Wednesday, July 30, 2008 2:19 AM

Feedback

# re: Application setting for Sharepoint timer jobs 9/1/2008 11:11 PM pragna
can you please provide me the sample code for OWSTIMER.EXE.config as i want to set the config parameters like SiteUrl, SMTPHost,and other etc..

can you also brief me about how to deploy the timer job on client server using WSP (package).

Thanks in advance.

#  re 9/1/2008 11:39 PM Tibor Molnar
Yes, no problem. The OWSTIMER.EXE.config file is a normal .Net binary config file and contains the configuration sections for your dll, basically you copy the configuration section from the app.config file generated by Visual Studio for your dll into this file. Fo example:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="youAssemblyNamespace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<youAssemblyNamespace.Properties.Settings>
<setting name="SiteUrl" serializeAs="String">
<value>setting1value</value>
</setting>
<setting name="SMTPHost" serializeAs="String">
<value>settingValue</value>
</setting>
</youAssemblyNamespace.Properties.Settings>
</applicationSettings>
</configuration>

The deployment of the timer job is done in a feature receiver, code sample:

// Make sure the job isn't already registered.
foreach (SPJobDefinition job in webApplication.JobDefinitions) {
if (job.Name == Globals.TaskOverdueNotificatorJobName)
job.Delete();
}

// Install the job.
YourCustomJobClass yourCustomJob = new YourCustomJobClass (webApplication);

SPSchedule schedule = null;


SPDailySchedule dailySchedule = new SPDailySchedule();
dailySchedule.BeginHour = 0;
dailySchedule.BeginMinute = 0;
dailySchedule.BeginSecond = 0;
dailySchedule.EndHour = 1;
dailySchedule.EndMinute = 0;
dailySchedule.EndSecond = 0;
schedule = dailySchedule;

yourCustomJob.Schedule = schedule;
yourCustomJob.Update();


# re: Application setting for Sharepoint timer jobs 3/9/2009 7:16 PM Arjun
I need to run an exe file using sharepoint custome timer jobs.
can you briefly explain me how can i do this.i knew that i have to use spjobdefination class,spscheduler class and spminitescheduler classes.i don't know proper way to do this.
Thanks in advance.

# re: Application setting for Sharepoint timer jobs 8/13/2010 6:37 AM Vikram kumar reddy
Hi,
thanks a lot..........



Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: