Sharepoint Designer的ActivityLibrary

时间:2011-09-06 12:58:44

标签: c# sharepoint sharepoint-2010

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

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

AssignedTo以及'SiteUrl`相同。

不应该'AssignedTo','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>

1 个答案:

答案 0 :(得分:0)

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

所以你要么改变.ACTIONS:

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

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

装配属性值也必须正确。您可以使用sn.exe tool检索程序集的公钥标记。