Beispiel #1
0
    /// <summary>
    /// Initializes contact selector.
    /// </summary>
    private void InitContactSelector()
    {
        // Initialize contact selector
        ucSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton;

        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo(ProcessID);

        if (process == null)
        {
            RedirectToInformation("editedobject.notexists");
        }

        // Check permissions
        if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(listContacts.SiteID)) && (listContacts.SiteID != UniSelector.US_GLOBAL_AND_SITE_RECORD) && ((process != null) && process.WorkflowEnabled))
        {
            ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected;
            ucSelector.SiteID        = listContacts.SiteID;
            ucSelector.IsLiveSite    = false;
            ucSelector.IsSiteManager = ContactHelper.IsSiteManager;
            ucSelector.Enabled       = true;
            ucSelector.UniSelector.DialogButton.ToolTipResourceString = "automenu.startstatedesc";
        }
        else
        {
            ucSelector.Enabled = false;
            ucSelector.UniSelector.DialogButton.ToolTipResourceString = process.WorkflowEnabled ? "general.nopermission" : "autoMenu.DisabledStateDesc";
        }
    }
    /// <summary>
    ///  Initializes master page elements.
    /// </summary>
    private void InitializeMasterPage()
    {
        if (!CurrentUser.IsGlobalAdministrator)
        {
            PageTitle title = CurrentMaster.Title;
            title.TitleText     = GetString("ma.automationprocess.list");
            title.TitleImage    = GetImageUrl("Objects/MA_AutomationProcess/object.png");
            title.HelpName      = "helpTopic";
            title.HelpTopicName = "ma_process_list";
        }

        if (WorkflowInfoProvider.IsMarketingAutomationAllowed())
        {
            HeaderAction newProcess = new HeaderAction()
            {
                // New process link
                Text        = GetString("ma.newprocess"),
                ImageUrl    = GetImageUrl("Objects/MA_AutomationProcess/add.png"),
                RedirectUrl = AddSiteQuery("Process/New.aspx", null),
                Enabled     = WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)
            };

            AddHeaderAction(newProcess);
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridProcesses_OnAction(string actionName, object actionArgument)
    {
        int processId = Convert.ToInt32(actionArgument);

        switch (actionName)
        {
        case "edit":
            var url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditProcess");
            url = URLHelper.AddParameterToUrl(url, "displayTitle", "false");
            url = URLHelper.AddParameterToUrl(url, "objectId", processId.ToString());
            URLHelper.Redirect(url);
            break;

        case "delete":
            if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName))
            {
                RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "ManageProcesses");
            }

            // Delete the workflow with all the dependencies
            WorkflowInfoProvider.DeleteWorkflowInfo(processId);

            ShowConfirmation(GetString("ma.process.delete.confirmation"));
            break;
        }
    }
    protected List <string> uiGuide_OnGuideItemCreated(UIElementInfo uiElement, List <string> defaultItem)
    {
        switch (uiElement.ElementName.ToLowerCSafe())
        {
        case "tools.ecommerce":
            if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Ecommerce, ModuleEntry.ECOMMERCE))
            {
                return(null);
            }
            break;

        case "tools.onlinemarketing":
        case "onlinemarketing.contactmanagement":
            if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContactManagement, ModuleEntry.ONLINEMARKETING))
            {
                return(null);
            }
            break;

        case "onlinemarketing.automationprocess":
            if (!WorkflowInfoProvider.IsMarketingAutomationAllowed())
            {
                return(null);
            }
            break;
        }

        return(defaultItem);
    }
Beispiel #5
0
    /// <summary>
    /// Gets the automation state and move contact to previous step. Called when the "Move to previous step" button is pressed.
    /// Expects the CreateAutomationState method to be run first.
    /// </summary>
    private bool MoveContactToPreviousStep()
    {
        // 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 process state
            AutomationStateInfo state = contact.Processes.FirstItem as AutomationStateInfo;

            if (state != null)
            {
                // Move contact to next step
                manager.MoveToPreviousStep(contact, state, "Move to previous step");

                return(true);
            }
        }

        return(false);
    }
Beispiel #6
0
    /// <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
            DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID);

            if (!DataHelper.DataSourceIsEmpty(scopes))
            {
                // Create the scope info object
                WorkflowScopeInfo deleteScope = new WorkflowScopeInfo(scopes.Tables[0].Rows[0]);

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

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

        return(false);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "Workflow Edit - Header";

        workflowId = QueryHelper.GetInteger("workflowid", 0);

        WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(workflowId);

        // Set edited object
        EditedObject = wi;

        const string workflowListUrl = "~/CMSModules/Workflows/Workflow_List.aspx";
        string       workflows       = GetString("Development-Workflow_Edit.Workflows");
        string       currentWorkflow = string.Empty;
        string       title           = GetString("Development-Workflow_Edit.Title");

        if (wi != null)
        {
            currentWorkflow = wi.WorkflowDisplayName;
        }

        if (!RequestHelper.IsPostBack())
        {
            InitalizeMenu();

            if (QueryHelper.GetString("showtab", string.Empty) == "steps")
            {
                CurrentMaster.Tabs.SelectedTab = 1;
            }
        }

        // Initialize master page title
        InitializeMasterPage(title, workflows, workflowListUrl, currentWorkflow);
    }
Beispiel #8
0
    protected override void OnPreRender(EventArgs e)
    {
        if (CurrentWorkflow != null)
        {
            // Only basic workflow without auto-publish can be converted
            if (WorkflowInfoProvider.IsAdvancedWorkflowAllowed() && CurrentWorkflow.IsBasic)
            {
                HeaderAction convert = new HeaderAction()
                {
                    Text          = GetString("workflow.convert"),
                    ImageUrl      = GetImageUrl("Design/Controls/UniGrid/Actions/convert.png"),
                    OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("workflow.confirmconversion"), true) + ");",
                    EventName     = CONVERT_ACTION
                };

                if (editElem.CurrentWorkflow.WorkflowAutoPublishChanges)
                {
                    convert.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/convertdisabled.png");
                    convert.Tooltip  = GetString("workflow.conversionerror.versioningwithoutworkflow");
                    convert.Enabled  = false;
                }
                CurrentMaster.HeaderActions.AddAction(convert);
            }
        }
        base.OnPreRender(e);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // Do nothing!
        }
        else
        {
            plcLabel.Visible = !SimpleMode;
            RequiredFieldValidatorLabel.ErrorMessage = GetString("workflowstep.sourcepoint.requireslabel");

            if (CurrentSourcePoint != null)
            {
                // Switch default doesn't have condition
                if ((CurrentSourcePoint.Type == SourcePointTypeEnum.SwitchDefault) || (CurrentSourcePoint.Type == SourcePointTypeEnum.Timeout))
                {
                    lblCondition.Visible = cbCondition.Visible = false;
                }

                if (!RequestHelper.IsPostBack())
                {
                    txtLabel.Text    = CurrentSourcePoint.Label;
                    txtText.Text     = CurrentSourcePoint.Text;
                    txtTooltip.Text  = CurrentSourcePoint.Tooltip;
                    cbCondition.Text = CurrentSourcePoint.Condition;
                }
            }

            if (cbCondition.Visible)
            {
                WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(CurrentStepInfo.StepWorkflowID);
                cbCondition.ResolverName = WorkflowHelper.GetResolverName(wi);
            }
        }
    }
Beispiel #10
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridProcesses_OnAction(string actionName, object actionArgument)
    {
        int processId = Convert.ToInt32(actionArgument);

        switch (actionName)
        {
        case "edit":
            var url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditProcess");
            url = URLHelper.AddParameterToUrl(url, "displayTitle", "false");
            url = URLHelper.AddParameterToUrl(url, "objectId", processId.ToString());
            URLHelper.Redirect(AddSiteQuery(url, null));
            break;

        case "delete":
            if (AutomationHelper.CheckProcessDependencies(processId))
            {
                ShowError(GetString("MA.process.CannotDeleteUsed"));

                return;
            }

            if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName))
            {
                RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "ManageProcesses");
            }

            // Delete the workflow
            WorkflowInfoProvider.DeleteWorkflowInfo(processId);
            break;
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void UniGridWorkflows_OnAction(string actionName, object actionArgument)
    {
        int workflowid = Convert.ToInt32(actionArgument);

        switch (actionName)
        {
        case "edit":
            URLHelper.Redirect("Workflow_Edit.aspx?workflowid=" + workflowid);
            break;

        case "delete":
            // Check if documents use the workflow
            List <string> documentNames = new List <string>();
            if (WorkflowInfoProvider.CheckDependencies(workflowid, ref documentNames))
            {
                // Encode and localize names
                StringBuilder sb = new StringBuilder();
                documentNames.ForEach(item => sb.Append("<br />", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(item))));
                ShowError(GetString("Workflow.CannotDeleteUsed"), GetString("workflow.documentlist") + sb.ToString(), null);
                return;
            }
            else
            {
                // Delete the workflow
                WorkflowInfoProvider.DeleteWorkflowInfo(workflowid);
            }
            break;
        }
    }
Beispiel #12
0
    /// <summary>
    /// Saves new workflow's data and redirects to Workflow_Edit.aspx.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Event arguments</param>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator().NotEmpty(txtWorkflowDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName")).NotEmpty(txtWorkflowCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName"))
                        .IsCodeName(txtWorkflowCodeName.Text, GetString("general.invalidcodename"))
                        .Result;

        if (result == "")
        {
            WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(txtWorkflowCodeName.Text);
            if (wi == null)
            {
                int workflowId = SaveNewWorkflow();

                if (workflowId > 0)
                {
                    WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(workflowId);
                    URLHelper.Redirect("Workflow_Edit.aspx?workflowid=" + workflowId + "&saved=1");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Development-Workflow_New.WorkflowExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = result;
        }
    }
    /// <summary>
    /// Initializes the master page elements.
    /// </summary>
    private void InitializeMasterPage(int workflowId)
    {
        // Get workflow
        WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(workflowId);

        // Set edited object
        EditedObject = wi;

        if (wi != null)
        {
            // Check if 'automatically publish changes' is allowed
            if (wi.WorkflowAutoPublishChanges)
            {
                ShowInformation(GetString("Development-Workflow_Steps.CustomStepsCanNotBeCreated"));
            }
            else
            {
                // Set actions
                string[,] actions = new string[1, 8];
                actions[0, 0]     = "HyperLink";
                actions[0, 1]     = GetString("Development-Workflow_Steps.NewStep");
                actions[0, 3]     = "~/CMSModules/Workflows/Workflow_Step_New.aspx?workflowid=" + workflowId;
                actions[0, 5]     = GetImageUrl("Objects/CMS_WorkflowStep/add.png");

                CurrentMaster.HeaderActions.Actions = actions;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string workflowName = string.Empty;

        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo(ProcessID);

        if (workflow != null)
        {
            workflowName = workflow.WorkflowDisplayName;
        }

        InitalizeMenu();

        if (!RequestHelper.IsPostBack())
        {
            switch (QueryHelper.GetString("showtab", String.Empty).ToLowerCSafe())
            {
            case "steps":
                CurrentMaster.Tabs.SelectedTab = 1;
                break;

            case "triggers":
                CurrentMaster.Tabs.SelectedTab = 2;
                break;

            case "contacts":
                CurrentMaster.Tabs.SelectedTab = 3;
                break;
            }
        }

        // Initialize master page title
        InitializeMasterPage(workflowName);
    }
Beispiel #15
0
    /// <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);
    }
Beispiel #16
0
    /// <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);
    }
Beispiel #17
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);
    }
Beispiel #18
0
    /// <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", WorkflowTypeEnum.Approval);

        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);
    }
Beispiel #19
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);
    }
Beispiel #20
0
    /// <summary>
    /// Creates workflow scope. Called when the "Create scope" button is pressed.
    /// Expects the "CreateWorkflow" method to be run first.
    /// </summary>
    private bool CreateWorkflowScope()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (workflow != null)
        {
            // Create new workflow scope object
            WorkflowScopeInfo newScope = new WorkflowScopeInfo();

            // Get the site default culture from settings
            string      cultureCode = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCultureCode");
            CultureInfo culture     = CultureInfoProvider.GetCultureInfo(cultureCode);

            // Get root document type class ID
            int classID = DataClassInfoProvider.GetDataClassInfo("CMS.Root").ClassID;

            // Set the properties
            newScope.ScopeStartingPath = "/";
            newScope.ScopeCultureID    = culture.CultureID;
            newScope.ScopeClassID      = classID;

            newScope.ScopeWorkflowID = workflow.WorkflowID;
            newScope.ScopeSiteID     = SiteContext.CurrentSiteID;

            // Save the workflow scope
            WorkflowScopeInfoProvider.SetWorkflowScopeInfo(newScope);

            return(true);
        }

        return(false);
    }
Beispiel #21
0
    /// <summary>
    /// Saves data
    /// </summary>
    public void SaveData()
    {
        if (Workflow != null)
        {
            chkEmails.SetThreeStateValue(Workflow, "WorkflowSendEmails");

            Workflow.WorkflowApprovedTemplateName         = ValidationHelper.GetString(ucApprove.Value, null);
            Workflow.WorkflowReadyForApprovalTemplateName = ValidationHelper.GetString(ucReadyApproval.Value, null);
            Workflow.WorkflowRejectedTemplateName         = ValidationHelper.GetString(ucReject.Value, null);
            Workflow.WorkflowPublishedTemplateName        = ValidationHelper.GetString(ucPublish.Value, null);
            Workflow.WorkflowArchivedTemplateName         = ValidationHelper.GetString(ucArchive.Value, null);
            Workflow.WorkflowNotificationTemplateName     = ValidationHelper.GetString(ucNotif.Value, null);

            Workflow.WorkflowSendApproveEmails          = chkApprove.Checked;
            Workflow.WorkflowSendReadyForApprovalEmails = chkReadyApproval.Checked;
            Workflow.WorkflowSendRejectEmails           = chkReject.Checked;
            Workflow.WorkflowSendArchiveEmails          = chkArchive.Checked;
            Workflow.WorkflowSendPublishEmails          = chkPublish.Checked;

            // Save workflow info
            WorkflowInfoProvider.SetWorkflowInfo(Workflow);

            // Save selected users
            SaveUsersData();

            ShowChangesSaved();
        }
    }
Beispiel #22
0
    /// <summary>
    /// Gets and bulk updates workflows. Called when the "Get and bulk update workflows" button is pressed.
    /// Expects the CreateWorkflow method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateWorkflows()
    {
        // Prepare the parameters
        string where = "WorkflowName LIKE N'MyNewWorkflow%'";

        // Get the data
        InfoDataSet <WorkflowInfo> workflows = WorkflowInfoProvider.GetWorkflows(where, null, 0, null);

        if (!DataHelper.DataSourceIsEmpty(workflows))
        {
            // Loop through the individual items
            foreach (WorkflowInfo modifyWorkflow in workflows)
            {
                // Update the properties
                modifyWorkflow.WorkflowDisplayName = modifyWorkflow.WorkflowDisplayName.ToUpper();

                // Save the changes
                WorkflowInfoProvider.SetWorkflowInfo(modifyWorkflow);
            }

            return(true);
        }

        return(false);
    }
Beispiel #23
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;
        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);

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

            return(true);
        }

        return(false);
    }
Beispiel #24
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);
    }
Beispiel #25
0
    /// <summary>
    /// Creates process trigger. Called when the "Create trigger" button is pressed.
    /// Expects the CreateProcess method to be run first.
    /// </summary>
    private bool CreateProcessTrigger()
    {
        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (process != null)
        {
            // Create new process trigger object and set its properties
            ObjectWorkflowTriggerInfo newTrigger = new ObjectWorkflowTriggerInfo()
            {
                TriggerDisplayName = "My new trigger",
                TriggerType        = WorkflowTriggerTypeEnum.Change,
                TriggerSiteID      = SiteContext.CurrentSiteID,
                TriggerWorkflowID  = process.WorkflowID,
                TriggerObjectType  = "om.contact"
            };

            // Save the process trigger
            ObjectWorkflowTriggerInfoProvider.SetObjectWorkflowTriggerInfo(newTrigger);

            return(true);
        }

        return(false);
    }
Beispiel #26
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);
    }
Beispiel #27
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);
    }
Beispiel #28
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(TextBoxWorkflowDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName"))
                        .NotEmpty(txtCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName"))
                        .IsCodeName(txtCodeName.Text, GetString("general.invalidcodename"))
                        .Result;

        if (result == "")
        {
            if (currentWorkflow != null)
            {
                // Codename must be unique
                WorkflowInfo wiCodename = WorkflowInfoProvider.GetWorkflowInfo(txtCodeName.Text);
                if ((wiCodename == null) || (wiCodename.WorkflowID == currentWorkflow.WorkflowID))
                {
                    if (currentWorkflow.WorkflowDisplayName != TextBoxWorkflowDisplayName.Text)
                    {
                        // Refresh header
                        ScriptHelper.RefreshTabHeader(Page, null);
                    }

                    currentWorkflow.WorkflowDisplayName        = TextBoxWorkflowDisplayName.Text;
                    currentWorkflow.WorkflowName               = txtCodeName.Text;
                    currentWorkflow.WorkflowAutoPublishChanges = chkAutoPublish.Checked;

                    // Inherited from global settings
                    if (radSiteSettings.Checked)
                    {
                        currentWorkflow.WorkflowUseCheckinCheckout = null;
                    }
                    else
                    {
                        currentWorkflow.WorkflowUseCheckinCheckout = radYes.Checked;
                    }

                    // Save workflow info
                    WorkflowInfoProvider.SetWorkflowInfo(currentWorkflow);

                    lblInfo.Visible = true;
                    lblInfo.Text    = GetString("General.ChangesSaved");
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Development-Workflow_New.WorkflowExists");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Development-Workflow_General.WorkflowDoesNotExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = result;
        }
    }
Beispiel #29
0
    /// <summary>
    /// Saves new wokflow's data into DB.
    /// </summary>
    /// <returns>Returns ID of created wokflow</returns>
    protected int SaveNewWorkflow()
    {
        WorkflowInfo wi = new WorkflowInfo();

        wi.WorkflowDisplayName = txtWorkflowDisplayName.Text;
        wi.WorkflowName        = txtWorkflowCodeName.Text;
        WorkflowInfoProvider.SetWorkflowInfo(wi);
        return(wi.WorkflowID);
    }
Beispiel #30
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (WorkflowInfoProvider.IsAdvancedWorkflowAllowed())
        {
            SetTab(1, GetString("workflow.action.title"), "Pages/WorkflowAction/List.aspx", "SetHelpTopic('helpTopic', 'workflow_action_list');");
            SetTab(2, GetString("macros.macrorules"), "Pages/MacroRule/List.aspx?displaytitle=false", "SetHelpTopic('helpTopic', 'macros_macrorule_list');");
        }
    }