mercredi 10 décembre 2014

Create two different timer jobs but SharePoint keeps assigning the same name



I have a SharePoint 2013 project with two very different custom timer jobs in it. In the feature I create the jobs with two different name, but when going to "Job Definitions" in Central Admin, I can see the two jobs but they have the same name. it will use the name assigned to the first job for both, so I can switch them around in code and still get the same effect, my feature code is below:



const string JobName = "Client Portal Update";
const string NewClientJobName = "New Client Prep";

private bool CreateJob(SPWebApplication site)
{
bool jobCreated = false;

try
{
ClientUpdateTimerJob job = new ClientUpdateTimerJob(JobName, site);

SPMinuteSchedule schedule = new SPMinuteSchedule();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 15;
job.Schedule = schedule;

job.Update();

NewClientPrepTimerJob newClientJob = new NewClientPrepTimerJob(NewClientJobName, site);
SPMinuteSchedule newClientSchedule = new SPMinuteSchedule();
newClientSchedule.BeginSecond = 0;
newClientSchedule.EndSecond = 59;
newClientSchedule.Interval = 30;
newClientJob.Schedule = newClientSchedule;

newClientJob.Update();
}
catch (Exception)
{
jobCreated = false;
}

return jobCreated;
}







0 commentaires:

Enregistrer un commentaire