Esempio n. 1
0
        /// <summary>
        /// Gets the type of the workflow action.
        /// </summary>
        /// <returns></returns>
        public WorkflowActionType GetWorkflowActionType(bool expandInvalid)
        {
            EnsureChildControls();
            WorkflowActionType result = new WorkflowActionType();

            result.Guid = new Guid(_hfActionTypeGuid.Value);

            result.CriteriaAttributeGuid  = _ddlCriteriaAttribute.SelectedValueAsGuid();
            result.CriteriaComparisonType = _ddlCriteriaComparisonType.SelectedValueAsEnum <ComparisonType>();
            result.CriteriaValue          = _tbddlCriteriaValue.SelectedValue;

            result.Name         = _tbActionTypeName.Text;
            result.EntityTypeId = _wfatpEntityType.SelectedValueAsInt() ?? 0;
            result.IsActionCompletedOnSuccess   = _cbIsActionCompletedOnSuccess.Checked;
            result.IsActivityCompletedOnSuccess = _cbIsActivityCompletedOnSuccess.Checked;

            var entityType = EntityTypeCache.Get(result.EntityTypeId);

            if (entityType != null && entityType.Name == typeof(Rock.Workflow.Action.UserEntryForm).FullName)
            {
                result.WorkflowForm = _formEditor.GetForm();
                if (result.WorkflowForm == null)
                {
                    result.WorkflowForm         = new WorkflowActionForm();
                    result.WorkflowForm.Actions = "Submit^^^Your information has been submitted successfully.";
                    var systemEmail = new SystemEmailService(new RockContext()).Get(SystemGuid.SystemEmail.WORKFLOW_FORM_NOTIFICATION.AsGuid());
                    if (systemEmail != null)
                    {
                        result.WorkflowForm.NotificationSystemEmailId = systemEmail.Id;
                    }
                }
            }
            else
            {
                result.WorkflowForm = null;
            }

            result.LoadAttributes();
            Rock.Attribute.Helper.GetEditValues(_phActionAttributes, result);

            if (expandInvalid && !result.IsValid)
            {
                Expanded = true;
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the type of the workflow action.
        /// </summary>
        /// <returns></returns>
        public WorkflowActionType GetWorkflowActionType(bool expandInvalid)
        {
            EnsureChildControls();
            WorkflowActionType result = new WorkflowActionType();

            result.Guid = new Guid(_hfActionTypeGuid.Value);

            result.CriteriaAttributeGuid  = _ddlCriteriaAttribute.SelectedValueAsGuid();
            result.CriteriaComparisonType = _ddlCriteriaComparisonType.SelectedValueAsEnum <ComparisonType>();
            result.CriteriaValue          = _tbddlCriteriaValue.SelectedValue;

            result.Name         = _tbActionTypeName.Text;
            result.EntityTypeId = _wfatpEntityType.SelectedValueAsInt() ?? 0;
            result.IsActionCompletedOnSuccess   = _cbIsActionCompletedOnSuccess.Checked;
            result.IsActivityCompletedOnSuccess = _cbIsActivityCompletedOnSuccess.Checked;

            var entityType = EntityTypeCache.Get(result.EntityTypeId);

            if (entityType != null && entityType.Name == typeof(Rock.Workflow.Action.FormBuilder).FullName)
            {
                // Do nothing to the existing WorkflowForm property.
            }
            else if (entityType != null && entityType.Name == typeof(Rock.Workflow.Action.UserEntryForm).FullName)
            {
                result.WorkflowForm = _formEditor.GetForm();
                if (result.WorkflowForm == null)
                {
                    result.WorkflowForm = CreateNewWorkflowForm();
                }
            }
            else
            {
                result.WorkflowForm = null;
            }

            result.LoadAttributes();
            Rock.Attribute.Helper.GetEditValues(_phActionAttributes, result);

            if (expandInvalid && !result.IsValid)
            {
                Expanded = true;
            }

            return(result);
        }
        /// <summary>
        /// Gets or sets the form.
        /// </summary>
        /// <value>
        /// The form.
        /// </value>
        public WorkflowActionForm GetForm()
        {
            EnsureChildControls();
            var form = new WorkflowActionForm();

            form.Guid = _hfFormGuid.Value.AsGuid();
            if (form.Guid != Guid.Empty)
            {
                form.NotificationSystemEmailId    = _ddlNotificationSystemEmail.SelectedValueAsId();
                form.IncludeActionsInNotification = _cbIncludeActions.Checked;
                form.Header     = _ceHeaderText.Text;
                form.Footer     = _ceFooterText.Text;
                form.Actions    = _falActions.Value;
                form.AllowNotes = _cbAllowNotes.Checked;

                foreach (var row in AttributeRows)
                {
                    var formAttribute = new WorkflowActionFormAttribute();
                    formAttribute.Attribute = new Rock.Model.Attribute {
                        Guid = row.AttributeGuid, Name = row.AttributeName
                    };
                    formAttribute.Guid       = row.Guid;
                    formAttribute.Order      = row.Order;
                    formAttribute.IsVisible  = row.IsVisible;
                    formAttribute.IsReadOnly = !row.IsEditable;
                    formAttribute.IsRequired = row.IsRequired;
                    formAttribute.HideLabel  = row.HideLabel;
                    formAttribute.PreHtml    = row.PreHtml;
                    formAttribute.PostHtml   = row.PostHtml;
                    form.FormAttributes.Add(formAttribute);
                }

                form.ActionAttributeGuid = _ddlActionAttribute.SelectedValueAsGuid();

                return(form);
            }
            return(null);
        }