I need to run the Word Automation Services immediately after adding a job. My code is running in a workflow.
Here is what I got so far :
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite spSite = new SPSite(site))
{
var job = new ConversionJob("Word Automation Services");
job.UserToken = spSite.UserToken;
job.Settings.UpdateFields = false;
job.Settings.OutputFormat = SaveFormat.PDF;
job.AddFile(source, destination);
job.Start();
foreach (var service in spSite.WebApplication.Farm.Services)
{
if (service.TypeName == "Word Automation Services")
{
foreach (var jobDefinition in service.JobDefinitions)
{
if (jobDefinition.Name == "Word Automation Services")
{
jobDefinition.RunNow();
break;
}
}
}
}
}
});
But I got an access denied on the RunNow() method. Is there a way to call this method from a workflow ?