Ejemplo n.º 1
0
    /// <summary>
    /// Creates a new workflow step. Called when the "Create workflow step" button is pressed.
    /// Expects the CreateWorkflow method to be run first.
    /// </summary>
    private bool CreateWorkflowStep()
    {
        // Get the workflow
        WorkflowInfo myWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (myWorkflow != null)
        {
            // Create new workflow step object
            WorkflowStepInfo newStep = new WorkflowStepInfo();

            // Set the properties
            newStep.StepWorkflowID  = myWorkflow.WorkflowID;
            newStep.StepName        = "MyNewWorkflowStep";
            newStep.StepDisplayName = "My new workflow step";
            newStep.StepOrder       = 1;
            newStep.StepType        = WorkflowStepTypeEnum.Standard;

            // Save the step into database
            WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep);

            // Ensure correct step order
            WorkflowStepInfoProvider.InitStepOrders(myWorkflow);

            return(true);
        }

        return(false);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Saves new workflow step's data into DB.
    /// </summary>
    /// <returns>Returns ID of created workflow step</returns>
    protected int SaveNewWorkflowStep()
    {
        SetFormValues(CurrentStepInfo);

        // Ensure correct order for basic workflow
        if (CurrentWorkflow.IsBasic)
        {
            // Get published step info for the proper position
            WorkflowStepInfo psi = WorkflowStepInfoProvider.GetPublishedStep(WorkflowID);
            if (psi != null)
            {
                CurrentStepInfo.StepOrder = psi.StepOrder;
                // Move the published step down
                psi.StepOrder += 1;
                WorkflowStepInfoProvider.SetWorkflowStepInfo(psi);

                // Move the archived step down
                WorkflowStepInfo asi = WorkflowStepInfoProvider.GetArchivedStep(WorkflowID);
                if (asi != null)
                {
                    asi.StepOrder += 1;
                    WorkflowStepInfoProvider.SetWorkflowStepInfo(asi);
                }
            }
        }

        CurrentStepInfo.StepWorkflowID = WorkflowID;
        WorkflowStepInfoProvider.SetWorkflowStepInfo(CurrentStepInfo);
        return(CurrentStepInfo.StepID);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Creates process. Called when the "Create process" button is pressed.
    /// </summary>
    private bool CreateProcess()
    {
        // Create new process object and set its properties
        WorkflowInfo newProcess = new WorkflowInfo()
        {
            WorkflowDisplayName    = "My new process",
            WorkflowName           = "MyNewProcess",
            WorkflowType           = WorkflowTypeEnum.Automation,
            WorkflowRecurrenceType = ProcessRecurrenceTypeEnum.Recurring
        };

        // Save the process
        WorkflowInfoProvider.SetWorkflowInfo(newProcess);

        // Create default steps
        WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(newProcess);

        // Get the step with codename 'Finished' and allow Move to previous
        WorkflowStepInfo finishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Finished", newProcess.WorkflowID);

        finishedStep.StepAllowReject = true;

        // Save the 'Finished' step
        WorkflowStepInfoProvider.SetWorkflowStepInfo(finishedStep);

        return(true);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Gets and bulk updates process steps. Called when the "Get and bulk update steps" button is pressed.
    /// Expects the CreateProcessStep method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateProcessSteps()
    {
        // Prepare the parameters
        string where = "StepName LIKE N'MyNewProcessStep%'";

        // Get the data
        InfoDataSet <WorkflowStepInfo> steps = WorkflowStepInfoProvider.GetWorkflowSteps(where, null);

        if (!DataHelper.DataSourceIsEmpty(steps))
        {
            // Loop through the individual items
            foreach (WorkflowStepInfo modifyStep in steps)
            {
                // Update the properties
                modifyStep.StepDisplayName = modifyStep.StepDisplayName.ToUpper();

                // Save the changes
                WorkflowStepInfoProvider.SetWorkflowStepInfo(modifyStep);
            }

            return(true);
        }

        return(false);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Saves new wokflow step's data into DB.
    /// </summary>
    /// <returns>Returns ID of created wokflow step</returns>
    protected int SaveNewWorkflowStep()
    {
        WorkflowStepInfo wsi = new WorkflowStepInfo();

        wsi.StepDisplayName = txtWorkflowDisplayName.Text;
        wsi.StepName        = txtWorkflowCodeName.Text;

        // Get published step info for the proper position
        WorkflowStepInfo psi = WorkflowStepInfoProvider.GetPublishedStep(workflowid);

        if (psi != null)
        {
            wsi.StepOrder = psi.StepOrder;
            // Move the published step down
            psi.StepOrder += 1;
            WorkflowStepInfoProvider.SetWorkflowStepInfo(psi);

            // Move the archived step down
            WorkflowStepInfo asi = WorkflowStepInfoProvider.GetArchivedStep(workflowid);
            if (asi != null)
            {
                asi.StepOrder += 1;
                WorkflowStepInfoProvider.SetWorkflowStepInfo(asi);
            }
        }

        wsi.StepWorkflowID = workflowid;
        WorkflowStepInfoProvider.SetWorkflowStepInfo(wsi);
        return(wsi.StepID);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Saves edited object to database.
    /// </summary>
    /// <param name="validateData">Indicates whether form data should be validated prior to save</param>
    public void Save(bool validateData)
    {
        if (!validateData || ValidateData())
        {
            if (validateData)
            {
                SaveData(false);
            }

            WorkflowStepInfoProvider.SetWorkflowStepInfo(CurrentStepInfo);
            ShowChangesSaved();
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Replace value in ActivityCampaign field where <see cref="CampaignInfo.CampaignName"/> is stored by <see cref="CampaignInfo.CampaignID"/>.
    /// </summary>
    /// <param name="step">Step to be replaced.</param>
    private static void UpdateCustomActivityStep(WorkflowStepInfo step)
    {
        var parameters   = step.StepActionParameters;
        var campaignName = parameters.GetValue("ActivityCampaign");
        var campaign     = CampaignInfoProvider.GetCampaigns()
                           .WhereEquals("CampaignName", campaignName)
                           .FirstOrDefault();

        if (campaign == null)
        {
            return;
        }

        parameters.SetValue("ActivityCampaign", campaign.CampaignID);
        WorkflowStepInfoProvider.SetWorkflowStepInfo(step);
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Saves data
    /// </summary>
    public void SaveData()
    {
        if (WorkflowStep != null)
        {
            chkEmails.SetThreeStateValue(WorkflowStep, "StepSendEmails");
            chkApprove.SetThreeStateValue(WorkflowStep, "StepSendApproveEmails");
            chkReadyApproval.SetThreeStateValue(WorkflowStep, "StepSendReadyForApprovalEmails");
            chkReject.SetThreeStateValue(WorkflowStep, "StepSendRejectEmails");

            WorkflowStep.StepApprovedTemplateName         = ValidationHelper.GetString(ucApprove.Value, null);
            WorkflowStep.StepReadyForApprovalTemplateName = ValidationHelper.GetString(ucReadyApproval.Value, null);
            WorkflowStep.StepRejectedTemplateName         = ValidationHelper.GetString(ucReject.Value, null);

            // Save workflow info
            WorkflowStepInfoProvider.SetWorkflowStepInfo(WorkflowStep);

            ShowChangesSaved();
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Saves data of edited workflow from TextBoxes into DB.
    /// </summary>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        // Finds whether required fields are not empty
        string result = new Validator().NotEmpty(txtWorkflowStepDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName")).NotEmpty(txtWorkflowStepCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName"))
                        .IsCodeName(txtWorkflowStepCodeName.Text, GetString("general.invalidcodename"))
                        .Result;

        if (result == "")
        {
            if (WorkflowStepId > 0)
            {
                if (CurrentStepInfo != null)
                {
                    if (CurrentStepInfo.StepDisplayName != txtWorkflowStepDisplayName.Text)
                    {
                        // Refresh header
                        ScriptHelper.RefreshTabHeader(Page, null);
                    }

                    CurrentStepInfo.StepDisplayName = txtWorkflowStepDisplayName.Text;
                    CurrentStepInfo.StepName        = txtWorkflowStepCodeName.Text;
                    WorkflowStepInfoProvider.SetWorkflowStepInfo(CurrentStepInfo);

                    lblInfo.Visible = true;
                    lblInfo.Text    = GetString("General.ChangesSaved");
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Development-Workflow_Step_New.WorkflowExists");
                }
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = result;
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Gets and updates process step. Called when the "Get and update step" button is pressed.
    /// Expects the CreateProcessStep method to be run first.
    /// </summary>
    private bool GetAndUpdateProcessStep()
    {
        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (process != null)
        {
            // Get the process step
            WorkflowStepInfo modifyStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewProcessStep", process.WorkflowID);
            if (modifyStep != null)
            {
                // Update the properties
                modifyStep.StepDisplayName = modifyStep.StepDisplayName.ToLower();

                // Save the changes
                WorkflowStepInfoProvider.SetWorkflowStepInfo(modifyStep);

                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Creates workflow step. Called when the "Create step" button is pressed.
    /// Expects the CreateWorkflow method to be run first.
    /// </summary>
    private bool CreateStepForTransition()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

        if (workflow != null)
        {
            // Create new workflow step object and set its properties
            WorkflowStepInfo newStep = new WorkflowStepInfo()
            {
                StepWorkflowID  = workflow.WorkflowID,
                StepName        = "MyNewStep",
                StepDisplayName = "My new step",
                StepType        = WorkflowStepTypeEnum.Standard
            };

            // Save the step
            WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep);

            return(true);
        }

        return(false);
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Ensures correct steps order
    /// </summary>
    private void EnsureStepsOrder()
    {
        // Ensure correct order for basic workflow
        if ((CurrentWorkflow != null) && CurrentWorkflow.IsBasic)
        {
            // Get published step info for the proper position
            WorkflowStepInfo psi = WorkflowStepInfoProvider.GetPublishedStep(CurrentWorkflow.WorkflowID);
            if (psi != null)
            {
                CurrentStepInfo.StepOrder = psi.StepOrder;
                // Move the published step down
                psi.StepOrder += 1;
                WorkflowStepInfoProvider.SetWorkflowStepInfo(psi);

                // Move the archived step down
                WorkflowStepInfo asi = WorkflowStepInfoProvider.GetArchivedStep(CurrentWorkflow.WorkflowID);
                if (asi != null)
                {
                    asi.StepOrder += 1;
                    WorkflowStepInfoProvider.SetWorkflowStepInfo(asi);
                }
            }
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Creates process step. Called when the "Create step" button is pressed.
    /// Expects the CreateProcess method to be run first.
    /// </summary>
    private bool CreateProcessStep()
    {
        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (process != null)
        {
            // Create new process step object and set its properties
            WorkflowStepInfo newStep = new WorkflowStepInfo()
            {
                StepWorkflowID  = process.WorkflowID,
                StepName        = "MyNewProcessStep",
                StepDisplayName = "My new step",
                StepType        = WorkflowStepTypeEnum.Standard
            };

            // Save the process step
            WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep);

            return(true);
        }

        return(false);
    }
Ejemplo n.º 14
0
    /// <summary>
    ///Creates the document, workflow scope and step needed for this example. Called when the "Create example objects" button is pressed.
    /// </summary>
    private bool CreateExampleObjects()
    {
        // Create a new tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get the root node
        TreeNode parent = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");

        if (parent != null)
        {
            // Create the API document
            TreeNode node = TreeNode.New("CMS.MenuItem", tree);

            node.DocumentName    = "API Example";
            node.DocumentCulture = "en-us";

            // Insert it to database
            DocumentHelper.InsertDocument(node, parent, tree);

            // Get the default workflow
            WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("default");

            if (workflow != null)
            {
                // Get the document data
                node = DocumentHelper.GetDocument(node, tree);

                // Create new workflow scope
                WorkflowScopeInfo scope = new WorkflowScopeInfo();

                // Assign to the default workflow and current site and set starting alias path to the example document
                scope.ScopeWorkflowID   = workflow.WorkflowID;
                scope.ScopeStartingPath = node.NodeAliasPath;
                scope.ScopeSiteID       = CMSContext.CurrentSiteID;

                // Save the scope into the database
                WorkflowScopeInfoProvider.SetWorkflowScopeInfo(scope);

                // Create a new workflow step
                WorkflowStepInfo step = new WorkflowStepInfo();

                // Set its properties
                step.StepWorkflowID  = workflow.WorkflowID;
                step.StepName        = "MyNewWorkflowStep";
                step.StepDisplayName = "My new workflow step";
                step.StepOrder       = 1;

                // Save the workflow step
                WorkflowStepInfoProvider.SetWorkflowStepInfo(step);

                // Ensure correct step order
                WorkflowStepInfoProvider.InitStepOrders(workflow);

                return(true);
            }
            else
            {
                apiCreateExampleObjects.ErrorMessage = "The default workflow was not found.";
            }
        }

        return(false);
    }