/// <summary> /// Install a new workflow definition. /// </summary> public static void InstallWorkflow(ref ClientContext clientConext, ref WorkflowServicesManager wfServicesManager, Guid listId) { // connect to deployment service WorkflowDeploymentService depService = wfServicesManager.GetWorkflowDeploymentService(); string workflowStamp = DateTime.Now.ToString(); WorkflowDefinition workflowDefinition = new WorkflowDefinition(clientConext); workflowDefinition.Xaml = _validWorkflow; workflowDefinition.DisplayName = "Custom-" + workflowStamp; workflowDefinition.Description = "new custom workflow created " + workflowStamp; workflowDefinition.RestrictToType = "List"; // ["List" | "Site" | ""] workflowDefinition.RestrictToScope = listId.ToString(); Console.WriteLine(); Console.WriteLine("Creating new workflow"); Console.WriteLine(" saving workflow..."); ClientResult <Guid> result = depService.SaveDefinition(workflowDefinition); clientConext.ExecuteQuery(); Console.WriteLine(" publishing workflow..."); depService.PublishDefinition(result.Value); clientConext.ExecuteQuery(); Console.WriteLine("Workflow published... use SharePoint Designer 2013 to see it."); }
/// <summary> /// Validate a bad workflow. /// </summary> public static void ValidateBadWorkflow(ref ClientContext clientConext, ref WorkflowServicesManager wfServicesManager) { // connect to deployment service WorkflowDeploymentService depService = wfServicesManager.GetWorkflowDeploymentService(); Console.WriteLine(); Console.WriteLine("Validating workflow:"); Console.WriteLine(_invalidWorkflow); ClientResult <string> result = depService.ValidateActivity(_invalidWorkflow); clientConext.ExecuteQuery(); Console.WriteLine(); Console.Write("Validation result: "); if (string.IsNullOrEmpty(result.Value)) { Console.WriteLine("workflow validated"); } else { Console.WriteLine("error: " + result.Value); } }
public static Guid GetOneInstalledWorkflow(ref ClientContext clientContext, ref WorkflowServicesManager wfServiceManager) { WorkflowDeploymentService depService = wfServiceManager.GetWorkflowDeploymentService(); bool showPublishedWorkflows = true; WorkflowDefinitionCollection wfdefinitions = depService.EnumerateDefinitions(showPublishedWorkflows); clientContext.Load(wfdefinitions); clientContext.ExecuteQuery(); Console.WriteLine(wfdefinitions.First().DisplayName); return(wfdefinitions.First().Id); }
/// <summary> /// Get one installed workflow definition. /// </summary> public static Guid GetOneInstalledWorkflow(ref ClientContext clientConext, ref WorkflowServicesManager wfServicesManager) { // connect to deployment service WorkflowDeploymentService depService = wfServicesManager.GetWorkflowDeploymentService(); // get all installed workflows bool showOnlyPublishedWorkflows = true; WorkflowDefinitionCollection wfDefintions = depService.EnumerateDefinitions(showOnlyPublishedWorkflows); clientConext.Load(wfDefintions); clientConext.ExecuteQuery(); return(wfDefintions.First().Id); }
public static void ShowAllInstalledWorkflows(ref ClientContext clientContext, ref WorkflowServicesManager wfsm) { //connect to deployment service WorkflowDeploymentService depService = wfsm.GetWorkflowDeploymentService(); // get all installed workflows bool showOnlyPublishWorkflows = true; WorkflowDefinitionCollection definitions = depService.EnumerateDefinitions(showOnlyPublishWorkflows); clientContext.Load(definitions); clientContext.ExecuteQuery(); foreach (var def in definitions) { Console.WriteLine("Workflow ID: {0} - Workflow Name: {1}", def.Id, def.DisplayName); } }
/// <summary> /// Write out all installed workflows. /// </summary> public static void ShowAllInstalledWorkflows(ref ClientContext clientConext, ref WorkflowServicesManager wfServicesManager) { // connect to deployment service WorkflowDeploymentService depService = wfServicesManager.GetWorkflowDeploymentService(); // get all installed workflows bool showOnlyPublishedWorkflows = true; WorkflowDefinitionCollection wfDefintions = depService.EnumerateDefinitions(showOnlyPublishedWorkflows); clientConext.Load(wfDefintions); clientConext.ExecuteQuery(); // write all Console.WriteLine(); Console.WriteLine("All Installed Workflows:"); foreach (WorkflowDefinition wfDefintion in wfDefintions) { Console.WriteLine("{0} - {1}", wfDefintion.Id, wfDefintion.DisplayName); } }