2011-05-02 50 views
3

如何以编程方式强制执行/启动Word Automation Services?
我需要开始/执行一次提交转换过程。如何以编程方式执行Word Automation Services?

string siteUrl = "http://localhost"; 
    string wordAutomationServiceName = "Word Automation Services"; 
    using (SPSite spSite = new SPSite(siteUrl)) 
    { 
     ConversionJob job = new ConversionJob(wordAutomationServiceName); 
     job.UserToken = spSite.UserToken; 
     job.Settings.UpdateFields = true; 
     job.Settings.OutputFormat = SaveFormat.PDF; 
     job.AddFile(siteUrl + "/Shared%20Documents/Test.docx", siteUrl + "/Shared%20Documents/Test.pdf"); 
     job.Start(); 
    } 

回答

2

你是问是否有办法迫使作业立即执行,而不是等待在Word中自动化控制系统服务管理设置中设定的时间间隔? 目前,在Word Automation Services for SP 2010中,没有办法做到这一点。我所能想到的只是将时间间隔改为最小1分钟(而不是默认的15分钟)。

4

是的,你可以强制工作立即从代码以及从中央管理界面开始。参见我的解决方案(建立在RunNow方法的SPJobDefinition类的顶部)here

您应该启动Word Automation Services计时器作业

对于eaxmple,使用的PowerShell:

$watj = Get-SPTimerJob "Word Automation Service Application" 
$watj.RunNow() 

或甚至更短:

​​