2011-02-22 69 views

回答

4

SharePoint在完全不同的進程下例行運行您的工作流程。至少,你可以期望你的工作流活動下出現:

  • 的IIS工作進程,
  • owstimer.exe過程,
  • 即與SharePoint(例如控制檯應用程序)接口的任意可執行文件。

在相對於引發工作流程複雜的工作流程情況事件(!)的SharePoint選擇將實際執行它的進程。因此,從ASP.NET觸發的長時間運行的工作流程(即IIS工作進程)會自動重新計劃以在owstimer.exe下運行。

結果是你不能使用SPContext.Current。在工作流活動中,您必須使用WorkflowContext實例,該實例提供了Web屬性。您的活動必須聲明WorkflowContext類型的依賴項屬性才能訪問它 - 詳情請參閱MSDN here。 VS項目模板將爲您提供必要的代碼。

實施例:

public partial class LogEventActivity: Activity 
{ 
    public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(LogEventActivity)); 

    [Browsable(true)] 
    [ValidationOption(ValidationOption.Required)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public WorkflowContext __Context 
    { 
     get 
     { 
      return (WorkflowContext)base.GetValue(__ContextProperty); 
     } 
     set 
     { 
      base.SetValue(__ContextProperty, value); 
     } 
    } 
} 
相關問題