コード例 #1
0
        /// <summary>
        /// Processes the selection, save state and navigates to the next page if no errors
        /// are encountered during processing the activity.
        /// </summary>
        /// <param name="modalAlert">The modal alert control to show if errors occur.</param>
        /// <param name="doNotProceedCondition">A condition that must be met after processing
        /// the activity in order to save state and continue to the next page.</param>
        /// <param name="conditionMessage">The message to display in the modal if the condition fails.</param>
        /// <param name="validateSelectionRequired">if set to <c>true</c> will check that block on next page has a selection required before redirecting.</param>
        /// <returns></returns>
        protected virtual bool ProcessSelection(Rock.Web.UI.Controls.ModalAlert modalAlert, Func <bool> doNotProceedCondition, string conditionMessage, bool validateSelectionRequired)
        {
            var errors = new List <string>();

            string workflowActivity = GetAttributeValue("WorkflowActivity");

            if (string.IsNullOrEmpty(workflowActivity) || ProcessActivity(workflowActivity, out errors))
            {
                if (doNotProceedCondition())
                {
                    modalAlert?.Show(conditionMessage, Rock.Web.UI.Controls.ModalAlertType.None);
                    return(false);
                }
                else
                {
                    SaveState();
                    NavigateToNextPage(validateSelectionRequired);
                    return(true);
                }
            }
            else
            {
                string errorMsg = "<ul><li>" + errors.AsDelimited("</li><li>") + "</li></ul>";
                modalAlert?.Show(errorMsg.Replace("'", @"\'"), Rock.Web.UI.Controls.ModalAlertType.Warning);
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Processes the selection, save state and navigates to the next page if no errors
        /// are encountered during processing the activity.
        /// </summary>
        /// <param name="modalAlert">The modal alert control to show if errors occur.</param>
        /// <param name="doNotProceedCondition">A condition that must be met after processing
        /// the activity in order to save state and continue to the next page.</param>
        /// <param name="conditionMessage">The message to display in the modal if the condition fails.</param>
        /// <returns></returns>
        protected virtual List <string> ProcessSelection(Rock.Web.UI.Controls.ModalAlert modalAlert, Func <bool> doNotProceedCondition, string conditionMessage)
        {
            var errors = new List <string>();

            string workflowActivity = GetAttributeValue("WorkflowActivity");

            if (string.IsNullOrEmpty(workflowActivity) || ProcessActivity(workflowActivity, out errors))
            {
                if (doNotProceedCondition())
                {
                    modalAlert.Show(conditionMessage, Rock.Web.UI.Controls.ModalAlertType.Warning);
                }
                else
                {
                    SaveState();
                    NavigateToNextPage();
                }
            }
            else
            {
                string errorMsg = "<ul><li>" + errors.AsDelimited("</li><li>") + "</li></ul>";
                modalAlert.Show(errorMsg, Rock.Web.UI.Controls.ModalAlertType.Warning);
            }

            return(errors);
        }
コード例 #3
0
        /// <summary>
        /// Processes the selection, save state and navigates to the next page if no errors
        /// are encountered during processing the activity.
        /// </summary>
        /// <param name="modalAlert">The modal alert control to show if errors occur.</param>
        /// <returns>a list of errors encountered during processing the activity</returns>
        /// <param name="validateSelectionRequired">if set to <c>true</c> will check that block on next page has a selection required before redirecting.</param>
        protected virtual List <string> ProcessSelection(Rock.Web.UI.Controls.ModalAlert modalAlert, bool validateSelectionRequired)
        {
            var errors = new List <string>();

            string workflowActivity = GetAttributeValue("WorkflowActivity");

            if (string.IsNullOrEmpty(workflowActivity) || ProcessActivity(workflowActivity, out errors))
            {
                SaveState();
                NavigateToNextPage(validateSelectionRequired);
            }
            else
            {
                string errorMsg = "<ul><li>" + errors.AsDelimited("</li><li>") + "</li></ul>";
                modalAlert.Show(errorMsg.Replace("'", @"\'"), Rock.Web.UI.Controls.ModalAlertType.Warning);
            }

            return(errors);
        }
コード例 #4
0
 /// <summary>
 /// Processes the selection, save state and navigates to the next page if no errors
 /// are encountered during processing the activity.
 /// </summary>
 /// <param name="modalAlert">The modal alert control to show if errors occur.</param>
 /// <param name="doNotProceedCondition">A condition that must be met after processing
 /// the activity in order to save state and continue to the next page.</param>
 /// <param name="conditionMessage">The message to display in the modal if the condition fails.</param>
 /// <returns></returns>
 protected virtual bool ProcessSelection(Rock.Web.UI.Controls.ModalAlert modalAlert, Func <bool> doNotProceedCondition, string conditionMessage)
 {
     return(ProcessSelection(modalAlert, doNotProceedCondition, conditionMessage, false));
 }
コード例 #5
0
 /// <summary>
 /// Processes the selection, save state and navigates to the next page if no errors
 /// are encountered during processing the activity.
 /// </summary>
 /// <param name="modalAlert">The modal alert control to show if errors occur.</param>
 /// <returns>a list of errors encountered during processing the activity</returns>
 protected virtual List <string> ProcessSelection(Rock.Web.UI.Controls.ModalAlert modalAlert)
 {
     return(ProcessSelection(modalAlert, false));
 }
コード例 #6
0
        /// <summary>
        /// Processes the selection.
        /// </summary>
        private bool ProcessSelection()
        {
            var editFamilyBlock = this.RockPage.ControlsOfTypeRecursive <CheckInEditFamilyBlock>().FirstOrDefault();

            hfShowEditFamilyPrompt.Value = "0";

            Func <bool> doNotProceedCondition = () =>
            {
                var noMatchingFamilies =
                    (
                        CurrentCheckInState.CheckIn.Families.All(f => f.People.Count == 0) &&
                        CurrentCheckInState.CheckIn.Families.All(f => f.Action == CheckinAction.CheckIn)   // not sure this is needed
                    )
                    &&
                    (
                        !CurrentCheckInState.AllowCheckout ||
                        (
                            CurrentCheckInState.AllowCheckout &&
                            CurrentCheckInState.CheckIn.Families.All(f => f.CheckOutPeople.Count == 0)
                        )
                    );

                if (noMatchingFamilies)
                {
                    if (CurrentCheckInState.Kiosk.RegistrationModeEnabled && editFamilyBlock != null)
                    {
                        hfShowEditFamilyPrompt.Value = "1";
                        return(true);
                    }
                    else
                    {
                        maWarning.Show(this.ConditionMessage, Rock.Web.UI.Controls.ModalAlertType.None);
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            };

            // use null as the processSelectionAlert since we will be doing the alert in Func<bool> doNotProceedCondition
            // but we'll have to handle the exception ourselves if we don't specific a modal to show when an exception occurs
            Rock.Web.UI.Controls.ModalAlert processSelectionAlert = null;

            try
            {
                if (ProcessSelection(processSelectionAlert, doNotProceedCondition, this.ConditionMessage))
                {
                    return(true);
                }
                else
                {
                    ClearSelection();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                // since we passed in null for the processSelectionAlert, we'll handle exceptions ourselves
                maWarning.Show(ex.Message, Rock.Web.UI.Controls.ModalAlertType.Alert);
                return(false);
            }
        }