Inheritance: System.Web.UI.WebControls.CompositeControl, IHasValidationGroup
        /// <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 WorkflowActionEditor CreateWorkflowActionTypeEditorControl( WorkflowActivityEditor workflowActivityTypeEditor, WorkflowActionType workflowActionType, bool forceContentVisible = false )
        {
            WorkflowActionEditor workflowActionTypeEditor = new WorkflowActionEditor();
            workflowActionTypeEditor.ID = "WorkflowActionTypeEditor_" + workflowActionType.Guid.ToString( "N" );
            workflowActionTypeEditor.DeleteActionTypeClick += workflowActionTypeEditor_DeleteActionTypeClick;

            var workflowAttributes = new Dictionary<Guid, string>();
            AttributesState.OrderBy( a => a.Order).ToList().ForEach( a => workflowAttributes.Add( a.Guid, a.Name ) );
            workflowActionTypeEditor.WorkflowAttributes = workflowAttributes;

            workflowActionTypeEditor.WorkflowActionType = workflowActionType;
            workflowActionTypeEditor.ForceContentVisible = forceContentVisible;

            workflowActivityTypeEditor.Controls.Add( workflowActionTypeEditor );

            return workflowActionTypeEditor;
        }
        /// <summary>
        /// Builds the controls.
        /// </summary>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="activeActivityGuid">The active activity unique identifier.</param>
        private void BuildControls( bool setValues = false, Guid? activeActivityGuid = null, bool showInvalid = false )
        {
            phAttributes.Controls.Clear();
            if ( _canEdit )
            {
                Helper.AddEditControls( Workflow, phAttributes, setValues, btnSave.ValidationGroup );
            }
            else
            {
                Helper.AddDisplayControls( Workflow, phAttributes );
            }

            var rockContext = new RockContext();

            phActivities.Controls.Clear();
            foreach ( var activity in Workflow.Activities.OrderBy( a => a.ActivatedDateTime ) )
            {
                var activityEditor = new WorkflowActivityEditor();
                activityEditor.ID = "WorkflowActivityEditor_" + activity.Guid.ToString( "N" );
                phActivities.Controls.Add( activityEditor );
                activityEditor.CanEdit = _canEdit;
                activityEditor.ValidationGroup = btnSave.ValidationGroup;
                activityEditor.IsDeleteEnabled = !activity.LastProcessedDateTime.HasValue;
                activityEditor.DeleteActivityTypeClick += workflowActivityEditor_DeleteActivityClick;
                activityEditor.SetWorkflowActivity( activity, rockContext, setValues);

                foreach ( WorkflowAction action in activity.Actions.OrderBy( a => a.ActionType.Order ) )
                {
                    var actionEditor = new WorkflowActionEditor();
                    actionEditor.ID = "WorkflowActionEditor_" + action.Guid.ToString( "N" );
                    activityEditor.Controls.Add( actionEditor );
                    actionEditor.CanEdit = _canEdit;
                    actionEditor.ValidationGroup = activityEditor.ValidationGroup;
                    actionEditor.SetWorkflowAction( action, setValues );
                }

                if ( _canEdit && setValues )
                {
                    activityEditor.Expanded = ExpandedActivities.Contains( activity.Guid );

                    if ( !activityEditor.Expanded && showInvalid && !activity.IsValid )
                    {
                        activityEditor.Expanded = true;
                    }

                    if ( !activityEditor.Expanded )
                    {
                        activityEditor.Expanded = activeActivityGuid.HasValue && activeActivityGuid.Equals( activity.Guid );
                    }
                }

            }
        }
Exemple #3
0
        /// <summary>
        /// Builds the controls.
        /// </summary>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="activeActivityGuid">The active activity unique identifier.</param>
        private void BuildControls( bool setValues = false, Guid? activeActivityGuid = null, bool showInvalid = false )
        {
            lReadOnlyTitle.Text = Workflow.Name.FormatAsHtmlTitle();
            hlInactive.Visible = Workflow.CompletedDateTime.HasValue;
            hlType.Text = Workflow.WorkflowType.Name;

            tbName.Text = Workflow.Name;
            lName.Text = Workflow.Name;

            tbStatus.Text = Workflow.Status;
            lStatus.Text = Workflow.Status;

            if ( Workflow.InitiatorPersonAlias != null && Workflow.InitiatorPersonAlias.Person != null)
            {
                ppInitiator.SetValue( Workflow.InitiatorPersonAlias.Person );
                lInitiator.Text = Workflow.InitiatorPersonAlias.Person.FullName;
            }
            else
            {
                ppInitiator.SetValue( null );
                lInitiator.Text = string.Empty;
            }

            cbIsCompleted.Checked = Workflow.CompletedDateTime.HasValue;
            lIsCompleted.Text = Workflow.CompletedDateTime.HasValue ? "Yes" : "No";

            var sbState = new StringBuilder();
            if ( Workflow.ActivatedDateTime.HasValue )
            {
                sbState.AppendFormat( "<strong>Activated:</strong> {0} {1} ({2})<br/>",
                    Workflow.ActivatedDateTime.Value.ToShortDateString(),
                    Workflow.ActivatedDateTime.Value.ToShortTimeString(),
                    Workflow.ActivatedDateTime.Value.ToRelativeDateString() );
            }
            if ( Workflow.CompletedDateTime.HasValue )
            {
                sbState.AppendFormat( "<strong>Completed:</strong> {0} {1} ({2})",
                    Workflow.CompletedDateTime.Value.ToShortDateString(),
                    Workflow.CompletedDateTime.Value.ToShortTimeString(),
                    Workflow.CompletedDateTime.Value.ToRelativeDateString() );
            }
            lState.Text = sbState.ToString();

            phAttributes.Controls.Clear();
            if ( _canEdit )
            {
                Helper.AddEditControls( Workflow, phAttributes, setValues, btnSave.ValidationGroup );
            }
            else
            {
                Helper.AddDisplayControls( Workflow, phAttributes );
            }

            phActivities.Controls.Clear();
            foreach ( var activity in Workflow.Activities.OrderBy( a => a.ActivatedDateTime ) )
            {
                var activityEditor = new WorkflowActivityEditor();
                activityEditor.ID = "WorkflowActivityEditor_" + activity.Guid.ToString( "N" );
                phActivities.Controls.Add( activityEditor );
                activityEditor.CanEdit = _canEdit;
                activityEditor.ValidationGroup = btnSave.ValidationGroup;
                activityEditor.IsDeleteEnabled = !activity.LastProcessedDateTime.HasValue;
                activityEditor.DeleteActivityTypeClick += workflowActivityEditor_DeleteActivityClick;
                activityEditor.SetWorkflowActivity( activity, setValues );

                foreach ( WorkflowAction action in activity.Actions.OrderBy( a => a.ActionType.Order ) )
                {
                    var actionEditor = new WorkflowActionEditor();
                    actionEditor.ID = "WorkflowActionEditor_" + action.Guid.ToString( "N" );
                    activityEditor.Controls.Add( actionEditor );
                    actionEditor.CanEdit = _canEdit;
                    actionEditor.ValidationGroup = activityEditor.ValidationGroup;
                    actionEditor.SetWorkflowAction( action, setValues );
                }

                if ( _canEdit && setValues )
                {
                    activityEditor.Expanded = ExpandedActivities.Contains( activity.Guid );

                    if ( !activityEditor.Expanded && showInvalid && !activity.IsValid )
                    {
                        activityEditor.Expanded = true;
                    }

                    if ( !activityEditor.Expanded )
                    {
                        activityEditor.Expanded = activeActivityGuid.HasValue && activeActivityGuid.Equals( activity.Guid );
                    }

                }
            }
        }