using CMS.SettingsProvider;
using CMS.CMSHelper;
using CMS.DataEngine;
using CMS.GlobalHelper;
using CMS.TreeEngine;
using CMS.SiteProvider;
using CMS.WorkflowEngine;
...
// Get the workflow
WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo("TestingWorkflow");
if (wi != null)
{
// Init new step
WorkflowStepInfo wsi = new WorkflowStepInfo();
wsi.StepDisplayName = "Article approval";
wsi.StepName = "ArticleApproval";
// Get published step info for the proper position
WorkflowStepInfo psi = WorkflowInfoProvider.GetPublishedStep(wi.WorkflowID);
if (psi != null)
{
// New step has the previous published step order
wsi.StepOrder = psi.StepOrder;
// Move the published step down
psi.StepOrder += 1;
WorkflowInfoProvider.SetWorkflowStepInfo(psi);
// Move the archived step down
WorkflowStepInfo asi = WorkflowInfoProvider.GetArchivedStep(wi.WorkflowID);
if (asi != null)
{
asi.StepOrder += 1;
WorkflowInfoProvider.SetWorkflowStepInfo(asi);
}
}
// Insert the step to the database
wsi.StepWorkflowID = wi.WorkflowID;
WorkflowInfoProvider.SetWorkflowStepInfo(wsi);
}
|