SetWorkflowAction() public method

Sets the workflow action.
public SetWorkflowAction ( WorkflowAction action, bool setValues = false ) : void
action WorkflowAction The value.
setValues bool if set to true [set values].
return void
        /// <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 );
                    }
                }

            }
        }
Example #2
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 );
                    }

                }
            }
        }