2011-02-22 52 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); 
     } 
    } 
} 
相关问题