Inheritance: System.Web.UI.WebControls.CompositeControl
Exemplo n.º 1
0
        /// <summary>
        /// Builds the action control.
        /// </summary>
        /// <param name="actionType">Type of the action.</param>
        /// <param name="activeWorkflowActionTypeGuid">The active workflow action type unique identifier.</param>
        /// <returns></returns>
        private WorkflowActionTypeEditor BuildActionControl( Control parentControl, bool setValues, WorkflowActionType actionType, 
            Dictionary<Guid, Attribute> attributes, Dictionary<string, string> activities, Guid? activeWorkflowActionTypeGuid = null, 
                bool showInvalid = false )
        {
            var control = new WorkflowActionTypeEditor();
            parentControl.Controls.Add( control );
            control.ID = actionType.Guid.ToString( "N" );
            control.ValidationGroup = btnSave.ValidationGroup;

            control.DeleteActionTypeClick += workflowActionTypeEditor_DeleteActionTypeClick;
            control.ChangeActionTypeClick += workflowActionTypeEditor_ChangeActionTypeClick;

            control.WorkflowActivities = activities;

            if (actionType.WorkflowForm != null)
            {
                var formAttributes = actionType.WorkflowForm.FormAttributes;

                // Remove any fields that were removed
                foreach ( var formAttribute in formAttributes.ToList() )
                {
                    if (!attributes.ContainsKey(formAttribute.Attribute.Guid))
                    {
                        formAttributes.Remove( formAttribute );
                    }
                }

                // Add any new attributes
                foreach(var attribute in attributes)
                {
                    if ( !formAttributes.Select( a => a.Attribute.Guid ).Contains( attribute.Key ) )
                    {
                        var formAttribute = new WorkflowActionFormAttribute();
                        formAttribute.Attribute = new Rock.Model.Attribute { Guid = attribute.Key, Name = attribute.Value.Name };
                        formAttribute.Guid = Guid.NewGuid();
                        formAttribute.Order = formAttributes.Any() ? formAttributes.Max( a => a.Order ) + 1 : 0;
                        formAttribute.IsVisible = false;
                        formAttribute.IsReadOnly = true;
                        formAttribute.IsRequired = false;
                        formAttribute.HideLabel = false;
                        formAttribute.PreHtml = string.Empty;
                        formAttribute.PostHtml = string.Empty;
                        formAttributes.Add( formAttribute );
                    }
                }
            }
            control.SetWorkflowActionType( actionType, attributes );

            control.Expanded = ExpandedActions.Contains( actionType.Guid );

            if ( setValues )
            {

                // Set order
                int newOrder = 0;
                foreach ( var attributeRow in control.FormEditor.AttributeRows )
                {
                    attributeRow.Order = newOrder++;
                }

                if ( !control.Expanded && showInvalid && !actionType.IsValid )
                {
                    control.Expanded = true;
                }

                if ( !control.Expanded )
                {
                    control.Expanded = activeWorkflowActionTypeGuid.HasValue && activeWorkflowActionTypeGuid.Equals( actionType.Guid );
                }
            }

            return control;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates the workflow action type editor control.
 /// </summary>
 /// <param name="workflowActivityTypeEditor">The workflow activity type editor.</param>
 /// <param name="workflowActionType">Type of the workflow action.</param>
 private void CreateWorkflowActionTypeEditorControl( WorkflowActivityTypeEditor workflowActivityTypeEditor, WorkflowActionType workflowActionType )
 {
     WorkflowActionTypeEditor workflowActionTypeEditor = new WorkflowActionTypeEditor();
     workflowActionTypeEditor.ID = "WorkflowActionTypeEditor_" + workflowActionType.Guid.ToString( "N" );
     workflowActionTypeEditor.DeleteActionTypeClick += workflowActionTypeEditor_DeleteActionTypeClick;
     workflowActionTypeEditor.WorkflowActionType = workflowActionType;
     workflowActivityTypeEditor.Controls.Add( workflowActionTypeEditor );
 }