I have created a SharePoint project that contains a custom workflow activity (not sandboxed, but inheriting from Activity). The project deploys a custon .ACTIONS file that describes the rule designer and parameters. I also add my assembly as an authorized type to the SP web.config after I do a deployment.
I am able to build, deploy, and locate the custom activity when creating a site workflow, but after selecting the activity there is nothing displayed in the designer. From what I have read this is usally due to a malformed ACTIONS defintion, but I am at a loss as to what i am doing wrong.
Any assitance or things I can try would be apprecaited, I am disappointed in the lack of feedback from the SharePoint designer on what is wrong. To clarify, I can select the custom activity, but the Rule Designer Sentence is not displayed in the workflow step and thus I cannot specify the input parameter(s).
.ACTIONS definition:
<WorkflowInfo Language="en-en">
<Actions Sequential="then" Parallel="and">
<Action Name="Call a Web Service"
ClassName="Hanford.SharePoint.Idms.UploadToIdmsActivity"
Assembly="IdmsIntegration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30d0fe63085b90b2"
AppliesTo="all"
UsesCurrentItem="true"
Category="IDMS">
<RuleDesigner Sentence="Address: %1;">
<FieldBind Field="Address" Text="URL" Id="1" DesignerType="TextArea" />
</RuleDesigner>
<Parameters>
<Parameter Name="Address" Type="System.String, mscorlib" Direction="In" />
<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="Response" Type="System.Object, mscorlib" Direction="Optional" />
</Parameters>
</Action>
</Actions>
</WorkflowInfo>
Custom Activity class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
namespace Hanford.SharePoint.Idms
{
/// <summary>
///
/// </summary>
public class UploadToIdmsActivity : Activity
{
//=======================================================================================================
// Public Properties
//=======================================================================================================
#region __Context
/// <summary>
///
/// </summary>
public WorkflowContext __Context
{
get { return (WorkflowContext)GetValue(__ContextProperty); }
set { SetValue(__ContextProperty, value); }
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty __ContextProperty =
DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(UploadToIdmsActivity));
#endregion
#region __ListId
/// <summary>
///
/// </summary>
public string __ListId
{
get { return (string)GetValue(__ListIdProperty); }
set { SetValue(__ListIdProperty, value); }
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty __ListIdProperty =
DependencyProperty.Register("__ListId", typeof(string), typeof(UploadToIdmsActivity));
#endregion
#region __ListItem
/// <summary>
///
/// </summary>
public int __ListItem
{
get { return (int)GetValue(__ListItemProperty); }
set { SetValue(__ListItemProperty, value); }
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty __ListItemProperty =
DependencyProperty.Register("__ListItem", typeof(int), typeof(UploadToIdmsActivity));
#endregion
#region Address
/// <summary>
///
/// </summary>
public string Address
{
get { return (string)GetValue(AddressProperty); }
set { SetValue(AddressProperty, value); }
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty AddressProperty =
DependencyProperty.Register("Address", typeof(string), typeof(UploadToIdmsActivity));
#endregion
#region Response
/// <summary>
///
/// </summary>
public object Response
{
get { return GetValue(ResponseProperty); }
set { SetValue(ResponseProperty, value); }
}
/// <summary>
///
/// </summary>
public static readonly DependencyProperty ResponseProperty =
DependencyProperty.Register("Response", typeof(object), typeof(UploadToIdmsActivity));
#endregion
//=======================================================================================================
// Protected Methods
//=======================================================================================================
#region Execute(ActivityExecutionContext executionContext)
/// <summary>
///
/// </summary>
/// <param name="executionContext"></param>
/// <returns></returns>
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
SPSecurity.RunWithElevatedPrivileges(
delegate()
{
using(WebClient webClient = new WebClient())
{
webClient.UseDefaultCredentials = true;
webClient.Headers[HttpRequestHeader.ContentType] = "text/xml; charset=utf-8";
Activity parent = executionContext.Activity;
while (parent.Parent != null)
{
parent = parent.Parent;
}
Response = webClient.DownloadString(Address);
if (Response != null)
{
ISharePointService spService = (ISharePointService)executionContext.GetService(typeof(ISharePointService));
spService.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, -1, TimeSpan.MinValue, "Information",
Response.ToString(), String.Empty);
}
}
}
);
return ActivityExecutionStatus.Closed;
}
#endregion
#region HandleFault(ActivityExecutionContext executionContext, Exception exception)
/// <summary>
///
/// </summary>
/// <param name="executionContext"></param>
/// <param name="exception"></param>
/// <returns></returns>
protected override ActivityExecutionStatus HandleFault(ActivityExecutionContext executionContext, Exception exception)
{
string errorMessage = string.Format("Error calling Upload to IDMS. {0}", exception.Message);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
ISharePointService spService = (ISharePointService)executionContext.GetService(typeof(ISharePointService));
spService.LogToHistoryList(this.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowError, -1, TimeSpan.MinValue, "Error",
errorMessage, String.Empty);
});
return base.HandleFault(executionContext, exception);
}
#endregion
}
}
Authorized Type configuration:
<authorizedType Assembly="IdmsIntegration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30d0fe63085b90b2" Namespace="Hanford.SharePoint.Idms.*" TypeName="*" Authorized="True" />