Rock.Web.UI.Controls.WorkflowActionTypePicker.SetValue C# (CSharp) Method

SetValue() public method

Sets the value.
public SetValue ( Rock.Web.Cache.EntityTypeCache entityType ) : void
entityType Rock.Web.Cache.EntityTypeCache Type of the entity.
return void
        public void SetValue( EntityTypeCache entityType )
        {
            ItemId = Constants.None.IdValue;
            ItemName = Constants.None.TextHtml;

            if ( entityType != null )
            {
                ItemId = entityType.Id.ToString();
                ItemName = ActionContainer.GetComponentName(entityType.Name);

                var action = ActionContainer.GetComponent( entityType.Name );
                if ( action != null )
                {
                    var actionType = action.GetType();
                    var obj = actionType.GetCustomAttributes( typeof( ActionCategoryAttribute ), true ).FirstOrDefault();
                    if ( obj != null )
                    {
                        var actionCategory = obj as ActionCategoryAttribute;
                        if ( actionCategory != null )
                        {
                            var categoryEntry = ActionContainer.Instance.Categories.Where( c => c.Value == actionCategory.CategoryName ).FirstOrDefault();
                            InitialItemParentIds = categoryEntry.Key.ToString();
                        }
                    }
                }
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// Sets the type of the workflow action.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="workflowTypeAttributes">The workflow type attributes.</param>
        public void SetWorkflowActionType(WorkflowActionType value, Dictionary <Guid, Rock.Model.Attribute> workflowTypeAttributes)
        {
            EnsureChildControls();
            _hfActionTypeGuid.Value = value.Guid.ToString();

            _ddlCriteriaAttribute.Items.Clear();
            _ddlCriteriaAttribute.Items.Add(new ListItem());

            _tbddlCriteriaValue.DropDownList.Items.Clear();
            _tbddlCriteriaValue.DropDownList.Items.Add(new ListItem());
            foreach (var attribute in workflowTypeAttributes)
            {
                var li = new ListItem(attribute.Value.Name, attribute.Key.ToString());
                li.Selected = value.CriteriaAttributeGuid.HasValue && value.CriteriaAttributeGuid.Value.ToString() == li.Value;
                _ddlCriteriaAttribute.Items.Add(li);

                _tbddlCriteriaValue.DropDownList.Items.Add(new ListItem(attribute.Value.Name, attribute.Key.ToString()));
            }

            _ddlCriteriaComparisonType.SetValue(value.CriteriaComparisonType.ConvertToInt());
            _tbddlCriteriaValue.SelectedValue = value.CriteriaValue;

            _tbActionTypeName.Text = value.Name;
            _wfatpEntityType.SetValue(EntityTypeCache.Get(value.EntityTypeId));
            _cbIsActivityCompletedOnSuccess.Checked = value.IsActivityCompletedOnSuccess;

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

            if (entityType != null && entityType.Name == typeof(Rock.Workflow.Action.UserEntryForm).FullName)
            {
                if (value.WorkflowForm == null)
                {
                    value.WorkflowForm         = new WorkflowActionForm();
                    value.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)
                    {
                        value.WorkflowForm.NotificationSystemEmailId = systemEmail.Id;
                    }
                }
                _formEditor.SetForm(value.WorkflowForm, workflowTypeAttributes);
                _cbIsActionCompletedOnSuccess.Checked = true;
                _cbIsActionCompletedOnSuccess.Enabled = false;
            }
            else
            {
                _formEditor.SetForm(null, workflowTypeAttributes);
                _cbIsActionCompletedOnSuccess.Checked = value.IsActionCompletedOnSuccess;
                _cbIsActionCompletedOnSuccess.Enabled = true;
            }

            _phActionAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls(value, _phActionAttributes, true, ValidationGroup, new List <string>()
            {
                "Active", "Order"
            });
        }
All Usage Examples Of Rock.Web.UI.Controls.WorkflowActionTypePicker::SetValue