Пример #1
0
 private void gridState_OnAction(string actionName, object actionArgument)
 {
     switch (actionName.ToLowerCSafe())
     {
     case "delete":
         int stateId = ValidationHelper.GetInteger(actionArgument, 0);
         AutomationManager manager = AutomationManager.GetInstance(CurrentUser);
         var obj   = CMSObjectHelper.GetObjectById(ObjectType, ObjectID);
         var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId);
         manager.RemoveProcess(obj, state);
         break;
     }
 }
Пример #2
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;
        var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN);

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

        if (DataHelper.DataSourceIsEmpty(contacts) || (process == null))
        {
            return(false);
        }

        // Get the contact from dataset
        ContactInfo contact = contacts.First <ContactInfo>();

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

        // Get the states
        var states = AutomationStateInfoProvider.GetAutomationStates()
                     .WhereEquals("StateWorkflowID", process.WorkflowID)
                     .WhereEquals("StateObjectID", contact.ContactID)
                     .WhereEquals("StateObjectType", PredefinedObjectType.CONTACT);

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

            return(true);
        }

        return(false);
    }
Пример #3
0
    private void gridState_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        case "delete":
            int stateId = ValidationHelper.GetInteger(actionArgument, 0);

            var obj   = BaseAbstractInfoProvider.GetInfoById(ObjectType, ObjectID);
            var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId);

            if (!CurrentUser.IsAuthorizedPerResource(ModuleName.ONLINEMARKETING, "RemoveProcess", SiteInfoProvider.GetSiteName(state.StateSiteID)))
            {
                RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "RemoveProcess");
            }

            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);
            manager.RemoveProcess(obj, state);

            break;
        }
    }
Пример #4
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);
    }