Exemplo n.º 1
0
 private static void RemoveWorkflow(ClientContext context)
 {
     //Construct object with workflow template info
     WorkflowTemplateInfo solutionInfo = new WorkflowTemplateInfo();
     //Package Guid is mandatory
     solutionInfo.PackageGuid = workflowUserSolutionId;
     solutionInfo.PackageName = Path.GetFileNameWithoutExtension(solutionPath);
     //Init workflow template deployer
     using (WorkflowTemplateDeployer workflowDeployer = new WorkflowTemplateDeployer(context))
     {
         //Deactivate workflow template
         workflowDeployer.DeactivateWorkflowSolution(solutionInfo);
         //Remove workflow template files
         workflowDeployer.RemoveWorkflowSolution(Path.GetFileName(solutionPath));
     }
 }
Exemplo n.º 2
0
        private static void RemoveWorkflow(ClientContext context)
        {
            //Construct object with workflow template info
            WorkflowTemplateInfo solutionInfo = new WorkflowTemplateInfo();

            //Package Guid is mandatory
            solutionInfo.PackageGuid = workflowUserSolutionId;
            solutionInfo.PackageName = Path.GetFileNameWithoutExtension(solutionPath);
            //Init workflow template deployer
            using (WorkflowTemplateDeployer workflowDeployer = new WorkflowTemplateDeployer(context))
            {
                //Deactivate workflow template
                workflowDeployer.DeactivateWorkflowSolution(solutionInfo);
                //Remove workflow template files
                workflowDeployer.RemoveWorkflowSolution(Path.GetFileName(solutionPath));
            }
        }
        /// <summary>
        /// Activate user solution based on workflow template information
        /// </summary>
        /// <param name="wfSolution">Encapsulates workflow solution information - package name is mandatory</param>
        public void ActivateWorkflowSolution(WorkflowTemplateInfo wfSolution)
        {
            // install the solution from the file url
            var filerelativeurl = templateLibrary.RootFolder.ServerRelativeUrl + "/" + Path.GetFileName(wfSolution.PackageFilePath);

            DesignPackageInfo packageInfo = new DesignPackageInfo()
            {
                PackageGuid = wfSolution.PackageGuid,
                PackageName = wfSolution.PackageName
            };

            DesignPackage.Install(clientContext, clientContext.Site, packageInfo, filerelativeurl);
            clientContext.ExecuteQuery();
            logger.WriteMessage("Workflow solution " + Path.GetFileName(wfSolution.PackageFilePath) + " is activated.");

            ActivateWorkflowFeature(wfSolution.FeatureId);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Activate user solution based on workflow template information
        /// </summary>
        /// <param name="wfSolution">Encapsulates workflow solution information - package name is mandatory</param>
        public void ActivateWorkflowSolution(WorkflowTemplateInfo wfSolution)
        {

            // install the solution from the file url
            var filerelativeurl = templateLibrary.RootFolder.ServerRelativeUrl + "/" + Path.GetFileName(wfSolution.PackageFilePath);

            DesignPackageInfo packageInfo = new DesignPackageInfo()
            {
                PackageGuid = wfSolution.PackageGuid,
                PackageName = wfSolution.PackageName
            };
            DesignPackage.Install(clientContext, clientContext.Site, packageInfo, filerelativeurl);
            clientContext.ExecuteQuery();
            logger.WriteMessage("Workflow solution " + Path.GetFileName(wfSolution.PackageFilePath) + " is activated.");

            ActivateWorkflowFeature(wfSolution.FeatureId);

        }
        /// <summary>
        /// Deactivate user solution based on workflow template information
        /// </summary>
        /// <param name="wfSolution">Encapsulates workflow solution information - package guid is mandatory</param>
        public void DeactivateWorkflowSolution(WorkflowTemplateInfo wfSolution)
        {
            if (wfSolution.PackageGuid.Equals(Guid.Empty))
            {
                throw new Exception("PackageGuid is not specified, please fill in.");
            }
            // uninstall the solution

            DesignPackageInfo packageInfo = new DesignPackageInfo()
            {
                PackageGuid = wfSolution.PackageGuid,
                PackageName = wfSolution.PackageName
            };

            DesignPackage.UnInstall(clientContext, clientContext.Site, packageInfo);

            clientContext.ExecuteQuery();

            logger.WriteMessage("Workflow solution " + wfSolution.PackageName + " is deactivated.");
        }
Exemplo n.º 6
0
        private static void ProvisionWorkflow(ClientContext context)
        {
            //Construct object with workflow template info
            WorkflowTemplateInfo solutionInfo = new WorkflowTemplateInfo();

            solutionInfo.PackageFilePath = solutionPath;
            //PackageName is mandatory
            solutionInfo.PackageName = Path.GetFileNameWithoutExtension(solutionPath);
            //Guid is automatically predefined in template file (wsp)
            solutionInfo.PackageGuid = workflowUserSolutionId;
            //Workflow feature Id is need to activate workflow in the web
            solutionInfo.FeatureId = workflowFeature;
            //Init workflow template deployer
            using (WorkflowTemplateDeployer workflowDeployer = new WorkflowTemplateDeployer(context))
            {
                //Provisiong workflow resources
                workflowDeployer.DeployWorkflowSolution(solutionPath);
                //Activates workflow template
                workflowDeployer.ActivateWorkflowSolution(solutionInfo);
            }
        }
Exemplo n.º 7
0
        private static void ProvisionWorkflow(ClientContext context)
        {

            //Construct object with workflow template info
            WorkflowTemplateInfo solutionInfo = new WorkflowTemplateInfo();
            solutionInfo.PackageFilePath = solutionPath;
            //PackageName is mandatory
            solutionInfo.PackageName = Path.GetFileNameWithoutExtension(solutionPath);
            //Guid is automatically predefined in template file (wsp)
            solutionInfo.PackageGuid = workflowUserSolutionId;
            //Workflow feature Id is need to activate workflow in the web
            solutionInfo.FeatureId = workflowFeature;
            //Init workflow template deployer
            using (WorkflowTemplateDeployer workflowDeployer = new WorkflowTemplateDeployer(context))
            {
                //Provisiong workflow resources
                workflowDeployer.DeployWorkflowSolution(solutionPath);
                //Activates workflow template
                workflowDeployer.ActivateWorkflowSolution(solutionInfo);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Deactivate user solution based on workflow template information
        /// </summary>
        /// <param name="wfSolution">Encapsulates workflow solution information - package guid is mandatory</param>
        public void DeactivateWorkflowSolution(WorkflowTemplateInfo wfSolution)
        {
            if (wfSolution.PackageGuid.Equals(Guid.Empty))
            {
                throw new Exception("PackageGuid is not specified, please fill in.");
            }
            // uninstall the solution

            DesignPackageInfo packageInfo = new DesignPackageInfo()
            {
                PackageGuid = wfSolution.PackageGuid,
                PackageName = wfSolution.PackageName
            };

            DesignPackage.UnInstall(clientContext, clientContext.Site, packageInfo);

            clientContext.ExecuteQuery();

            logger.WriteMessage("Workflow solution " + wfSolution.PackageName + " is deactivated.");
        }