コード例 #1
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;
        var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN);

        // 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);
    }