public Guid Subscribe(string name, Guid definitionId, Guid targetListId, WorkflowSubscritpionEventType eventTypes, Guid taskListId, Guid historyListId) { var eventTypesList = new List <string>(); foreach (WorkflowSubscritpionEventType type in Enum.GetValues(typeof(WorkflowSubscritpionEventType))) { if ((type & eventTypes) > 0) { eventTypesList.Add(type.ToString()); } } var subscription = new WorkflowSubscription(ClientContext) { Name = name, Enabled = true, DefinitionId = definitionId, EventSourceId = targetListId, EventTypes = eventTypesList.ToArray() }; subscription.SetProperty("TaskListId", taskListId.ToString()); subscription.SetProperty("HistoryListId", historyListId.ToString()); var subscriptionService = workflowServicesManager.GetWorkflowSubscriptionService(); var result = subscriptionService.PublishSubscriptionForList(subscription, targetListId); ClientContext.ExecuteQuery(); return(result.Value); }
public Guid Subscribe(string name, Guid definitionId, Guid targetListId, WorkflowSubscritpionEventType eventTypes, Guid taskListId, Guid historyListId) { var eventTypesList = new List<string>(); foreach (WorkflowSubscritpionEventType type in Enum.GetValues(typeof(WorkflowSubscritpionEventType))) { if ((type & eventTypes) > 0) eventTypesList.Add(type.ToString()); } var subscription = new WorkflowSubscription(ClientContext) { Name = name, Enabled = true, DefinitionId = definitionId, EventSourceId = targetListId, EventTypes = eventTypesList.ToArray() }; subscription.SetProperty("TaskListId", taskListId.ToString()); subscription.SetProperty("HistoryListId", historyListId.ToString()); var subscriptionService = workflowServicesManager.GetWorkflowSubscriptionService(); var result = subscriptionService.PublishSubscriptionForList(subscription, targetListId); ClientContext.ExecuteQuery(); return result.Value; }