예제 #1
0
        /// <summary>
        /// Handles the GetRecipientMergeFields event of the gSteps control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GetRecipientMergeFieldsEventArgs"/> instance containing the event data.</param>
        protected void gSteps_GetRecipientMergeFields(object sender, GetRecipientMergeFieldsEventArgs e)
        {
            Step stepRow = e.DataItem as Step;

            if (stepRow == null)
            {
                return;
            }

            var dataContext = GetDataContext();

            var step = new StepService(dataContext).Get(stepRow.Id);

            step.LoadAttributes();

            var mergefields = e.MergeValues;

            e.MergeValues.Add("StepStatus", step.StepStatus.Name);
            e.MergeValues.Add("StepName", step.StepType.Name);

            dynamic dynamicAttributeCarrier = new RockDynamic();

            foreach (var attributeKeyValue in step.AttributeValues)
            {
                dynamicAttributeCarrier[attributeKeyValue.Key] = attributeKeyValue.Value.Value;
            }

            e.MergeValues.Add("StepAttributes", dynamicAttributeCarrier);
        }