示例#1
0
    /// <summary>
    /// Gets and updates workflow scope. Called when the "Get and update scope" button is pressed.
    /// Expects the CreateWorkflowScope method to be run first.
    /// </summary>
    private bool GetAndUpdateWorkflowScope()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (workflow != null)
        {
            // Get the workflow's scopes
            InfoDataSet <WorkflowScopeInfo> scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID);

            if (!DataHelper.DataSourceIsEmpty(scopes))
            {
                // Create the scope info object
                WorkflowScopeInfo updateScope = scopes.First <WorkflowScopeInfo>();

                // Update the properties - the scope will include all cultures and document types
                updateScope.ScopeCultureID = 0;
                updateScope.ScopeClassID   = 0;

                // Save the changes
                WorkflowScopeInfoProvider.SetWorkflowScopeInfo(updateScope);

                return(true);
            }
            else
            {
                // No scope was found
                apiGetAndUpdateWorkflowScope.ErrorMessage = "The scope was not found.";
            }
        }

        return(false);
    }
示例#2
0
    /// <summary>
    /// Gets the automation state and move contact to specific step. Called when the "Move to specific step" button is pressed.
    /// Expects the CreateAutomationState method to be run first.
    /// </summary>
    private bool MoveContactToSpecificStep()
    {
        // Get dataset of contacts
        string where = "ContactLastName LIKE N'My New Contact%'";
        int topN = 1;
        InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null);

        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null))
        {
            // Get the contact from dataset
            ContactInfo contact = contacts.First <ContactInfo>();

            // Get the instance of automation manager
            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);

            // Get the automation state
            AutomationStateInfo state = contact.Processes.FirstItem as AutomationStateInfo;

            if (state != null)
            {
                // Get the finished step
                WorkflowStepInfo finishedStep = manager.GetFinishedStep(contact, state);

                // Move contact to specific step
                manager.MoveToSpecificStep(contact, state, finishedStep, "Move to specific step");

                return(true);
            }
        }

        return(false);
    }
示例#3
0
    /// <summary>
    /// Creates process transitions. Called when the "Create transitions" button is pressed.
    /// Expects the CreateProcess and CreateProcessStep method to be run first.
    /// </summary>
    private bool CreateProcessTransitions()
    {
        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (process != null)
        {
            // Get the previously created process step
            WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewProcessStep", process.WorkflowID);

            // Get the step with codename 'Finished'
            WorkflowStepInfo finishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Finished", process.WorkflowID);

            if ((step != null) && (finishedStep != null))
            {
                // Get existed transition from 'Start' step to 'Finished' step
                InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(process.WorkflowID, null, null, 1, null);
                WorkflowTransitionInfo existedTransition         = transitions.First <WorkflowTransitionInfo>();

                // Change existed transition to leads from 'Start' step to 'My new step' step
                existedTransition.TransitionEndStepID = step.StepID;
                // Save existed transition
                WorkflowTransitionInfoProvider.SetWorkflowTransitionInfo(existedTransition);

                // Connect 'My new step' step to 'Finished' step
                step.ConnectTo(step.StepDefinition.SourcePoints[0].Guid, finishedStep);

                return(true);
            }
        }

        return(false);
    }
示例#4
0
    /// <summary>
    /// Creates automation state. Called when the "Start process" button is pressed.
    /// Expects the CreateProcess, CreateProcessStep and CreateTemporaryObjects method to be run first.
    /// </summary>
    private bool CreateAutomationState()
    {
        // Get dataset of contacts
        string where = "ContactLastName LIKE N'My New Contact%'";
        int topN = 1;
        InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null);

        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null))
        {
            // Get the contact from dataset
            ContactInfo contact = contacts.First <ContactInfo>();

            // Get the instance of automation manager
            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);

            // Start the process
            manager.StartProcess(contact, process.WorkflowID);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Deletes workflow transition. Called when the "Delete transition" button is pressed.
    /// Expects the CreateWorklow and CreateTransitions method to be run first.
    /// </summary>
    private bool DeleteTransition()
    {
        // Get the process
        WorkflowInfo worklow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

        if (worklow != null)
        {
            // Get step
            WorkflowStepInfo startStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewStep", worklow.WorkflowID);

            if (startStep != null)
            {
                // Get existing transition leading from 'My new step'
                string where = "TransitionStartStepID = " + startStep.StepID;
                InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(worklow.WorkflowID, where, null, 1, null);
                WorkflowTransitionInfo existingTransition        = transitions.First <WorkflowTransitionInfo>();

                if (existingTransition != null)
                {
                    // Delete transition
                    WorkflowTransitionInfoProvider.DeleteWorkflowTransitionInfo(existingTransition);

                    return(true);
                }
            }
        }

        return(false);
    }
    /// <summary>
    /// Creates workflow transitions. Called when the "Create transition" button is pressed.
    /// Expects the CreateWorklow and CreateStep method to be run first.
    /// </summary>
    private bool CreateTransition()
    {
        // Get the workflow
        WorkflowInfo worklow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

        if (worklow != null)
        {
            // Get steps with codename 'MyNewStep' and 'Published'
            WorkflowStepInfo myNewStep     = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewStep", worklow.WorkflowID);
            WorkflowStepInfo publishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Published", worklow.WorkflowID);

            if ((myNewStep != null) && (publishedStep != null))
            {
                // Get existing transition leading to 'Published step'
                string where = "TransitionEndStepID = " + publishedStep.StepID;
                InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(worklow.WorkflowID, where, null, 1, null);
                WorkflowTransitionInfo existingTransition        = transitions.First <WorkflowTransitionInfo>();

                // Change existing transition to leads from 'Start step' to 'My new step'
                existingTransition.TransitionEndStepID = myNewStep.StepID;

                // Save existing transition
                WorkflowTransitionInfoProvider.SetWorkflowTransitionInfo(existingTransition);

                // Connect 'My new step' step to 'Published' step
                myNewStep.ConnectTo(myNewStep.StepDefinition.SourcePoints[0].Guid, publishedStep);

                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// Deletes workflow scope. Called when the "Delete scope" button is pressed.
    /// Expects the CreateWorkflowScope method to be run first.
    /// </summary>
    private bool DeleteWorkflowScope()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (workflow != null)
        {
            // Get the workflow's scopes
            InfoDataSet <WorkflowScopeInfo> scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID);

            if (!DataHelper.DataSourceIsEmpty(scopes))
            {
                // Create the scope info object
                WorkflowScopeInfo deleteScope = scopes.First <WorkflowScopeInfo>();

                // Delete the workflow scope
                WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(deleteScope);

                return(true);
            }
            else
            {
                // No scope was found
                apiDeleteWorkflowScope.ErrorMessage = "The scope was not found.";
            }
        }

        return(false);
    }
示例#8
0
    /// <summary>
    /// Remove contact from process. Called when the "Remove contact from process" button is pressed.
    /// Expects the CreateAutomationState method to be run first.
    /// </summary>
    private bool RemoveContactFromProcess()
    {
        // Get dataset of contacts
        string where = "ContactLastName LIKE N'My New Contact%'";
        int topN = 1;
        InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null);

        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null))
        {
            // Get the contact from dataset
            ContactInfo contact = contacts.First <ContactInfo>();

            // Get the instance of automation manager
            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);

            // Prepare the parameters
            where = "StateWorkflowID = " + process.WorkflowID + " AND StateObjectID = " + contact.ContactID + " AND StateObjectType = '" + PredefinedObjectType.CONTACT + "'";

            // Get the states
            InfoDataSet <AutomationStateInfo> states = AutomationStateInfoProvider.GetStates(where, null);

            if (!DataHelper.DataSourceIsEmpty(states))
            {
                // Loop through the individual items
                foreach (AutomationStateInfo state in states)
                {
                    // Remove contact from process
                    manager.RemoveProcess(contact, state);
                }

                return(true);
            }
        }

        return(false);
    }