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 void UpdateWorkflowDefinitionXAML(PSHWorkflowDefinition WFDefinition) { using (var clientContext = new ClientContext(_PWAUrl)) { var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web); // connect to the deployment service var workflowDeploymentService = workflowServicesManager.GetWorkflowDeploymentService(); //Get all the definitions from the Deployment Service, or get a specific definition using the GetDefinition method. WorkflowDefinitionCollection wfDefinitions = workflowDeploymentService.EnumerateDefinitions(false); clientContext.Load(wfDefinitions, wfDefs => wfDefs.Where(wfd => wfd.Id == WFDefinition.WFDefinitionId)); clientContext.ExecuteQuery(); WorkflowDefinition wfDefinition = wfDefinitions.First(); wfDefinition.DisplayName = WFDefinition.WFName; wfDefinition.Xaml = WFDefinition.WFDefinitionXAML; ClientResult <Guid> wfDefId = workflowDeploymentService.SaveDefinition(wfDefinition); workflowDeploymentService.PublishDefinition(wfDefinition.Id); clientContext.ExecuteQuery(); } }
public PSHWorkflowDefinition GetWorkflowDefinition(string WFDefinitionName) { PSHWorkflowDefinition objWFDefinition = null; using (var clientContext = new ClientContext(_PWAUrl)) { var workflowServicesManager = new WorkflowServicesManager(clientContext, clientContext.Web); // connect to the deployment service var workflowDeploymentService = workflowServicesManager.GetWorkflowDeploymentService(); Web oWeb = clientContext.Web; //Get all the definitions from the Deployment Service, or get a specific definition using the GetDefinition method. WorkflowDefinitionCollection wfDefinitions = workflowDeploymentService.EnumerateDefinitions(false); clientContext.Load(wfDefinitions, wfDefs => wfDefs.Where(wfd => wfd.DisplayName == WFDefinitionName)); clientContext.ExecuteQuery(); WorkflowDefinition wfDefinition = wfDefinitions.First(); ClientResult <Guid> wfDefId = workflowDeploymentService.SaveDefinition(wfDefinition); workflowDeploymentService.PublishDefinition(wfDefinition.Id); clientContext.ExecuteQuery(); if (wfDefinition != null) { objWFDefinition = new PSHWorkflowDefinition() { WFDefinitionId = wfDefinition.Id, WFDefinitionXAML = wfDefinition.Xaml, WFName = wfDefinition.DisplayName }; } } return(objWFDefinition); }