Sharepoint 2010 工作流在手动运行时具有SPContext.Current,但在运行时不具有SPContext.Current;“关于变化”吗;?
如果我手动运行此工作流,它可以正常工作。当我让它在编辑时自动运行时,SPContext.Current为空。当SPContext.Current自动运行时,我如何访问它?SharePoint通常在完全不同的流程下运行您的工作流。至少,您可以期望您的工作流活动显示在以下位置:Sharepoint 2010 工作流在手动运行时具有SPContext.Current,但在运行时不具有SPContext.Current;“关于变化”吗;?,sharepoint-2010,workflow,Sharepoint 2010,Workflow,如果我手动运行此工作流,它可以正常工作。当我让它在编辑时自动运行时,SPContext.Current为空。当SPContext.Current自动运行时,我如何访问它?SharePoint通常在完全不同的流程下运行您的工作流。至少,您可以期望您的工作流活动显示在以下位置: IIS工作进程 owstimer.exe进程 与SharePoint交互的任意可执行文件(例如控制台应用程序) 对于触发工作流的事件和工作流场景的复杂性(!!),SharePoint选择将实际执行它的流程。因此,当从AS
- IIS工作进程
进程owstimer.exe
- 与SharePoint交互的任意可执行文件(例如控制台应用程序)
owstimer.exe
下运行
结果是您无法使用SPContext.Current
。在工作流活动中,您必须使用提供Web
属性的WorkflowContext
实例。您的活动应声明类型为WorkflowContext
的依赖项属性,以访问该属性-请参阅。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);
}
}
}