从SharePoint自定义工作流活动返回文件夹GUID

时间:2009-11-12 04:33:02

标签: sharepoint directory workflow-activity

是否有人编写过代码来返回SharePoint Workflow Activity中文件夹的GUID,以便我可以将其传递给工作流变量?

如果您有代码示例,我真的非常希望看到代码示例!

谢谢

1 个答案:

答案 0 :(得分:0)

我做过类似的事情,我可以提供一些提示。我没有找到代码示例,因此我使用Reflector从SharePoint的DLL复制代码。

File: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\microsoft.sharepoint.WorkflowActions.dll
Class (for example): Microsoft.SharePoint.WorkflowActions.WaitForActivity

你会找到三个属性和DependencyProperty s:

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

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), Browsable(true), ValidationOption(ValidationOption.Required)]
public string __ListId
{
    get { return (string)base.GetValue(__ListIdProperty); }
    set { base.SetValue(__ListIdProperty, value); }
}

[Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), ValidationOption(ValidationOption.Required)]
public int __ListItem
{
    get { return (int)base.GetValue(__ListItemProperty); }
    set { base.SetValue(__ListItemProperty, value); }
}

public static DependencyProperty __ContextProperty;
public static DependencyProperty __ListIdProperty;
public static DependencyProperty __ListItemProperty;

这是一个静态构造函数:

static MyActivity()
{
    __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(MyActivity));
    __ListIdProperty = DependencyProperty.Register("__ListId", typeof(string), typeof(MyActivity));
    __ListItemProperty = DependencyProperty.Register("__ListItem", typeof(int), typeof(MyActivity));
}

将它们绑定在actions文件中:

  <Parameters>
    <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In"/>
    <Parameter Name="__ListId" Type="System.String, mscorlib, mscorlib" Direction="In" />
    <Parameter Name="__ListItem" Type="System.Int32, mscorlib, mscorlib" Direction="In" />
  </Parameters>

可以从文件中复制

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\Workflow\WSS.ACTIONS

然后,获取GUID相对容易,并使用属性和out参数绑定返回它。