Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 18th, 2012  |  syntax: None  |  size: 1.21 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Timer job not listed in Timer Job Definitions   Sharepoint 2007
  2. public override void FeatureActivated(SPFeatureReceiverProperties properties)
  3.         {
  4.             try
  5.             {
  6.                 SPSecurity.RunWithElevatedPrivileges(delegate()
  7.                 {
  8.                     SPWeb parentWeb = properties.Feature.Parent as SPWeb;
  9.                     UpdateEmpReferralListTimer taskJob;
  10.                     SPMinuteSchedule schedule;
  11.                     foreach (SPJobDefinition job in parentWeb.Site.WebApplication.JobDefinitions)
  12.                     {
  13.  
  14.                         if (job.Name == "xyz")
  15.                             job.Delete();
  16.                     }
  17.                     parentWeb = properties.Feature.Parent as SPWeb;
  18.                     taskJob = new UpdateEmpReferralListTimer("xyz", parentWeb.Site.WebApplication);
  19.                     schedule = new SPMinuteSchedule();
  20.                     schedule.BeginSecond = 0;
  21.                     schedule.EndSecond = 59;
  22.                     taskJob.Schedule = schedule;
  23.                     taskJob.Update();
  24.  
  25.                 });
  26.             }
  27.             catch (Exception Ex)
  28.             {
  29.                 string str = Ex.Message.ToString();
  30.             }
  31.         }