示例#1
0
        /// <summary>
        /// Sets the value. ( as Guid )
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            WorkflowPicker workflowPicker = control as WorkflowPicker;

            if (workflowPicker != null)
            {
                Guid?guid = value.AsGuidOrNull();
                if (guid.HasValue)
                {
                    var workflow = new WorkflowService(new RockContext()).Get(guid.Value);
                    if (workflow != null)
                    {
                        workflowPicker.WorkflowId = workflow.Id;
                        return;
                    }
                }
                else
                {
                    int?id = value.AsIntegerOrNull();
                    if (id.HasValue)
                    {
                        workflowPicker.WorkflowId = id.Value;
                    }
                }

                workflowPicker.WorkflowId = null;
            }
        }
示例#2
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            WorkflowPicker editControl = new WorkflowPicker {
                ID = id
            };

            if (configurationValues != null && configurationValues.ContainsKey(WORKFLOW_TYPE_KEY))
            {
                int workflowTypeId = 0;
                if (Int32.TryParse(configurationValues[WORKFLOW_TYPE_KEY].Value, out workflowTypeId) && workflowTypeId > 0)
                {
                    editControl.WorkflowTypeId = workflowTypeId;
                }
            }

            return(editControl);
        }
示例#3
0
        /// <summary>
        /// Reads new values entered by the user for the field ( as Guid )
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            WorkflowPicker workflowPicker = control as WorkflowPicker;

            if (workflowPicker != null)
            {
                if (workflowPicker.WorkflowId.HasValue)
                {
                    var workflow = new WorkflowService(new RockContext()).Get(workflowPicker.WorkflowId.Value);
                    if (workflow != null)
                    {
                        return(workflow.Guid.ToString());
                    }
                }
            }

            return(null);
        }