Skip to content

Instantly share code, notes, and snippets.

@jyarbro
Created October 25, 2017 06:15
Show Gist options
  • Save jyarbro/880018ffc6dd46e1977a1b41cb2a589c to your computer and use it in GitHub Desktop.
Save jyarbro/880018ffc6dd46e1977a1b41cb2a589c to your computer and use it in GitHub Desktop.
The bare minimum necessary to get an SP2010 workflow going in VS2017.
using Client.SharePoint.Services;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
using System.Workflow.ComponentModel;
namespace Client.SharePoint.Workflow {
public class ReportWorkflow : Activity {
public WorkflowContext __Context {
get => ((WorkflowContext)(GetValue(__ContextProperty)));
set => SetValue(__ContextProperty, value);
}
public static DependencyProperty __ContextProperty = DependencyProperty.Register(nameof(__Context), typeof(WorkflowContext), typeof(ReportWorkflow));
public SPWorkflowActivationProperties __ActivationProperties {
get => (SPWorkflowActivationProperties)GetValue(__ActivationPropertiesProperty);
set => SetValue(__ActivationPropertiesProperty, value);
}
public static DependencyProperty __ActivationPropertiesProperty = DependencyProperty.Register(nameof(__ActivationProperties), typeof(SPWorkflowActivationProperties), typeof(ReportWorkflow));
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) {
// Here's where you execute your magic.
var workflowService = new WorkflowService();
// Passing __Context is safe. It causes no compiler issues on the other end.
workflowService.Run(__Context);
return ActivityExecutionStatus.Closed;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment