Beispiel #1
0
    /// <summary>
    /// Gets and bulk updates actions. Called when the "Get and bulk update actions" button is pressed.
    /// Expects the CreateAction method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateActions()
    {
        // Prepare the parameters
        string where = "ActionName LIKE N'MyNewAction%'";

        // Get the data
        InfoDataSet <WorkflowActionInfo> actions = WorkflowActionInfoProvider.GetWorkflowActions(where, null);

        if (!DataHelper.DataSourceIsEmpty(actions))
        {
            // Loop through the individual items
            foreach (WorkflowActionInfo modifyAction in actions)
            {
                // Update the properties
                modifyAction.ActionDisplayName = modifyAction.ActionDisplayName.ToUpper();

                // Save the changes
                WorkflowActionInfoProvider.SetWorkflowActionInfo(modifyAction);
            }

            return(true);
        }

        return(false);
    }
Beispiel #2
0
    // Individual upgrade methods belong here

    /// <summary>
    /// Update all "Log Activity Action" steps. Replace value in ActivityCampaign field where <see cref="CampaignInfo.CampaignName"/> is stored by <see cref="CampaignInfo.CampaignID"/>.
    /// </summary>
    private static void UpdateCustomActivityActionStep()
    {
        var customActivityAction = WorkflowActionInfoProvider.GetWorkflowActions()
                                   .WhereEquals("ActionName", "Log_custom_activity")
                                   .FirstOrDefault();

        if (customActivityAction == null)
        {
            return;
        }

        WorkflowStepInfoProvider.GetWorkflowSteps()
        .WhereEquals("StepActionID", customActivityAction.ActionID)
        .ToList()
        .ForEach(UpdateCustomActivityStep);
    }
    /// <summary>
    /// Adds group for actions.
    /// </summary>
    /// <param name="where">Pattern to be used to filter actions</param>
    private void AddActionGroup(string where)
    {
        string condition = "ActionEnabled = 1";

        // Allowed objects
        condition = SqlHelper.AddWhereCondition(condition, "ActionAllowedObjects IS NULL OR ActionAllowedObjects LIKE N'%" + Workflow.WorkflowAllowedObjects + "%'");

        // Workflow type
        condition = SqlHelper.AddWhereCondition(condition, Workflow.IsAutomation ? "ActionWorkflowType = " + (int)Workflow.WorkflowType : "ActionWorkflowType = " + (int)Workflow.WorkflowType + " OR ActionWorkflowType IS NULL");

        InfoDataSet <WorkflowActionInfo> actions = WorkflowActionInfoProvider.GetWorkflowActions(condition, "ActionDisplayName", "ActionID, ActionThumbnailGUID, ActionThumbnailClass, ActionDisplayName, ActionDescription, ActionIconGUID, ActionIconClass");

        List <Item> nodesMenuItems = Factory.GetSettingsObjectBy(actions);

        nodesMenuItems = FilterList(nodesMenuItems, where);
        nodesMenuItems = nodesMenuItems.OrderBy(i => i.Text).ToList();

        if (nodesMenuItems.Count > 0)
        {
            KeyValuePair <string, object> nodesValue = new KeyValuePair <string, object>("NodesMenuItems", nodesMenuItems);
            AppendGroup(NodesControlPath, nodesValue, "");
        }
    }
    /// <summary>
    /// Returns true if process had passed through one/all selected automation actions.
    /// </summary>
    /// <param name="state">Process instance to check</param>
    /// <param name="actions">Automation action names separated with a semicolon</param>
    /// <param name="allActions">If true all actions must have been passed.</param>
    public static bool PassedThroughActions(object state, string actions, bool allActions)
    {
        AutomationStateInfo si = state as AutomationStateInfo;

        if (si != null)
        {
            if (!String.IsNullOrEmpty(actions))
            {
                // Get IDs of action steps this process visited in history
                string historyWhere = String.Format("HistoryStepType = {0} AND HistoryStateID = {1}", (int)WorkflowStepTypeEnum.Action, si.StateID);
                var    history      = AutomationHistoryInfoProvider.GetAutomationHistories(historyWhere, null, 0, "HistoryStepID");

                // Get action IDs of actions associated to the visited action steps
                string stepWhere   = SqlHelperClass.GetWhereCondition("StepID", history.Select <AutomationHistoryInfo, int>(h => h.HistoryStepID).ToList());
                var    actionSteps = WorkflowStepInfoProvider.GetWorkflowSteps(stepWhere, null, 0, "StepActionID");

                string[] selectedActions = actions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                // Get action infos to visited actions that have selected name
                string actionWhere = SqlHelperClass.GetWhereCondition("ActionID", actionSteps.Select <WorkflowStepInfo, int>(s => s.StepActionID).ToList());
                actionWhere = SqlHelperClass.AddWhereCondition(actionWhere, SqlHelperClass.GetWhereCondition("ActionName", selectedActions));

                var actionInfos = WorkflowActionInfoProvider.GetWorkflowActions(actionWhere, null, "ActionName").Items;

                // Return true if all/any actions were visited in history
                return(allActions ? (actionInfos.Count == selectedActions.Length) : (actionInfos.Count > 0));
            }
            else if (allActions)
            {
                // No actions were selected
                return(true);
            }
        }

        return(false);
    }
Beispiel #5
0
    /// <summary>
    /// Returns true if document had passed through one/all selected workflow actions.
    /// </summary>
    /// <param name="document">Document to check</param>
    /// <param name="actions">Workflow action names separated with a semicolon</param>
    /// <param name="allActions">If true all actions must have been passed.</param>
    public static bool PassedThroughActions(object document, string actions, bool allActions)
    {
        TreeNode doc = document as TreeNode;

        if (doc != null)
        {
            if (!String.IsNullOrEmpty(actions))
            {
                // Get IDs of action steps this document visited in history
                string historyWhere = String.Format("StepType = {0} AND HistoryObjectID = {1} AND HistoryObjectType = '{2}'", (int)WorkflowStepTypeEnum.Action, doc.DocumentID, DocumentObjectType.DOCUMENT);
                var    history      = WorkflowHistoryInfoProvider.GetWorkflowHistories(historyWhere, null, 0, "StepID");

                // Get action IDs of actions associated to the visited action steps
                string stepWhere   = SqlHelperClass.GetWhereCondition("StepID", history.Select <WorkflowHistoryInfo, int>(h => h.StepID).ToList());
                var    actionSteps = WorkflowStepInfoProvider.GetWorkflowSteps(stepWhere, null, 0, "StepActionID");

                string[] selectedActions = actions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                // Get action infos to visited actions that have selected name
                string actionWhere = SqlHelperClass.GetWhereCondition("ActionID", actionSteps.Select <WorkflowStepInfo, int>(s => s.StepActionID).ToList());
                actionWhere = SqlHelperClass.AddWhereCondition(actionWhere, SqlHelperClass.GetWhereCondition("ActionName", selectedActions));

                var actionInfos = WorkflowActionInfoProvider.GetWorkflowActions(actionWhere, null, "ActionName").Items;

                // Return true if all/any actions were visited in history
                return(allActions ? (actionInfos.Count == selectedActions.Length) : (actionInfos.Count > 0));
            }
            else if (allActions)
            {
                // No actions were selected
                return(true);
            }
        }

        return(false);
    }