ActivityLibrary for Sharepoint Designer

本文关键字:Designer Sharepoint for ActivityLibrary | 更新日期: 2023-09-27 18:07:36

我正在尝试实现一个MSDN教程来创建Sharepoint Designer的活动库,它给了我这个错误:

Namespace1.CreateTaskInListOnSite' does not contain a definition for 'ListName' and no extension method 'ListName' accepting a ...

AssignedTo和'SiteUrl '相同。

不应该' assigndto ', 'ListName'和'SiteUrl'从SequenceActivity类继承成员?

下面是错误的代码:

protected override ActivityExecutionStatus 
Execute(ActivityExecutionContext executionContext)
{
    try
    {
        SPSite sitecollection = new SPSite(this.SiteUrl); //here
        SPWeb web = sitecollection.OpenWeb();
        SPUser user = web.Users[this.AssignTo[0].ToString()]; // here
        SPList list = web.Lists[this.ListName]; // and here
        SPListItem item = list.Items.Add();
        item["Title"] = this.TaskTitle; 
        item["AssignedTo"] = user; 
        item.Update();
    } 
    catch (Exception ex)
    {
        EventLog.WriteEntry("MSDN Workflow", ex.ToString());
    }
    return ActivityExecutionStatus.Closed; 
}

.actions文件:

<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="Create Task in List On Site"
 ClassName="Namespace1.CreateTaskInListOnSite"
Assembly="CustomWorkflowActivities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a3170baa21b0a3e9"
AppliesTo="all" Category="Cross Site Actions">
    <RuleDesigner
     Sentence="Create task titled %1 for %2 on site %3 in 
          list %4">
    <FieldBind Field="TaskTitle" DesignerType="TextArea"
       Id="1"/>
    <FieldBind Field="AssignTo" DesignerType="Person"
       Text="this user" Id="2"/>
    <FieldBind Field="SiteUrl" DesignerType="TextArea" Id="3"/>
    <FieldBind Field="ListName" DesignerType="TextArea" Id="4"/>
  </RuleDesigner>
  <Parameters>
    <Parameter Name="TaskTitle" Type="System.String, mscorlib"
      Direction="In" />
    <Parameter Name="AssignTo" Type="System.String, mscorlib"
      Direction="In" />
    <Parameter Name="SiteUrl" Type="System.String, mscorlib"
      Direction="In" />
    <Parameter Name="ListName" Type="System.String, mscorlib"
      Direction="In" />
  </Parameters>
</Action>

ActivityLibrary for Sharepoint Designer

. actions文件将ClassName调用为MSDN.HowTo。CreateTaskInListOnSite,在您的代码文件中,您似乎使用命名空间Namespace1。两者必须匹配。

所以要么你把。actions改成这个:

<Action Name="Create Task in List On Site"
 ClassName="MSDN.HowTo.CreateTaskInListOnSite" .... />

或者将代码文件中的名称空间定义更改为MSDN.HowTo.

程序集属性值也必须正确。可以使用sn.exe工具检索程序集的公钥令牌。