Ответ на это пару шагов:
- Добавьте свойства к своей пользовательской активности .cs
- Свяжите свойства в вашем файле .actions (чтобы SPD знал, как сопоставить ваши свойства)
- Используйте свойства в вашем коде
ШАГ 1 : Вот код для свойств (мой класс называется GetEmails, который вам нужно будет переименовать, чтобы он был вашим классом):
public static DependencyProperty __ContextProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(GetEmails));
[Description("The site context")]
[Category("User")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public WorkflowContext __Context
{
get
{
return ((WorkflowContext)(base.GetValue(GetEmails.__ContextProperty)));
}
set
{
base.SetValue(GetEmails.__ContextProperty, value);
}
}
public static DependencyProperty __ListIdProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__ListId", typeof(string), typeof(GetEmails));
[ValidationOption(ValidationOption.Required)]
public string __ListId
{
get
{
return ((string)(base.GetValue(GetEmails.__ListIdProperty)));
}
set
{
base.SetValue(GetEmails.__ListIdProperty, value);
}
}
public static DependencyProperty __ListItemProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__ListItem", typeof(int), typeof(GetEmails));
[ValidationOption(ValidationOption.Required)]
public int __ListItem
{
get
{
return ((int)(base.GetValue(GetEmails.__ListItemProperty)));
}
set
{
base.SetValue(GetEmails.__ListItemProperty, value);
}
}
public static DependencyProperty __ActivationPropertiesProperty = DependencyProperty.Register("__ActivationProperties", typeof(Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties), typeof(GetEmails));
[ValidationOption(ValidationOption.Required)]
public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties __ActivationProperties
{
get
{
return (Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties)base.GetValue(GetEmails.__ActivationPropertiesProperty);
}
set
{
base.SetValue(GetEmails.__ActivationPropertiesProperty, value);
}
}
ШАГ 2 : Затем в файле .actions добавьте в свой блок сопоставления для этих свойств (обратите внимание на записи для __ListID, __ListItem, __Context и __ActivationProperties):
<Action Name="[DESCRIPTION OF YOUR ACTION]"
ClassName="[Your.Namespace.Goes.Here].GetEmails"
Assembly="[yourDLLName], Version=1.0.0.0, Culture=neutral, PublicKeyToken=0bfc6fa4c4aa913b"
AppliesTo="all"
Category="[Your Category Goes Here]">
<RuleDesigner Sentence="[blah blah blah]">
<FieldBind Field="PeopleFieldName" Text="people field" Id="1"/>
<FieldBind Field="Output" Text="emailAddress" Id="2" DesignerType="parameterNames" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" Direction="In" />
<Parameter Name="__ListId" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="__ListItem" Type="System.Int32, mscorlib" Direction="In" />
<Parameter Name="PeopleFieldName" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="Output" Type="System.String, mscorlib" Direction="Out" />
<Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="Out" />
</Parameters>
</Action>
ШАГ 3 :
Вот пример выполнения функции:
protected override ActivityExecutionStatus Execute(ActivityExecutionContext provider)
{
Output = string.Empty;
try
{
SPWeb web = __Context.Web;
// get all of the information we currently have about the item
// that this workflow is running on
Guid listGuid = new Guid(__ListId);
SPList myList = web.Lists[listGuid];
SPListItem myItem = myList.GetItemById(__ListItem);
//...
}
catch (Exception e)
{
//...
}
return ActivityExecutionStatus.Closed;
}