public Task Defer(DateTimeOffset approximateDueTime, Dictionary<string, string> headers, byte[] body)
        {
            var messageIdToPrint = headers.GetValueOrNull(Headers.MessageId) ?? "<no message ID>";

            var message =
                $"Received message with ID {messageIdToPrint} which is supposed to be deferred until {approximateDueTime} -" +
                " this is a problem, because the internal handling of deferred messages is" +
                " disabled when using SQS as the transport layer in, which" +
                " case the native support for a specific future enqueueing time is used...";

            throw new InvalidOperationException(message);
        }
Example #2
0
        public async Task Defer(DateTimeOffset approximateDueTime, Dictionary<string, string> headers, byte[] body)
        {
            var messageIdToPrint = headers.GetValueOrNull(Headers.MessageId) ?? "<no message ID>";

            var message = string.Format("Received message with ID {0} which is supposed to be deferred until {1} -" +
                                        " this is a problem, because the internal handling of deferred messages is" +
                                        " disabled when using Azure Storage Queues as the transport layer in, which" +
                                        " case the native support for a specific initial visibility delay is used...",
                messageIdToPrint, approximateDueTime);

            throw new InvalidOperationException(message);
        }
Example #3
0
        int GetMessagePriority(Dictionary<string, string> headers)
        {
            var valueOrNull = headers.GetValueOrNull(MessagePriorityHeaderKey);
            if (valueOrNull == null) return 0;

            try
            {
                return int.Parse(valueOrNull);
            }
            catch (Exception exception)
            {
                throw new FormatException(string.Format("Could not parse '{0}' into an Int32!", valueOrNull), exception);
            }
        }
        /// <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 Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            Panel pnlRange = new Panel { ID = id, CssClass = "form-control-group" };
            //Panel pnlCol1 = new Panel { CssClass = "col-md-6" };
            //Panel pnlCol2 = new Panel { CssClass = "col-md-6" };

            RockDropDownList lowerValueControl = new RockDropDownList { ID = string.Format( "{0}_ddlLower", id ) };
            lowerValueControl.CssClass = "input-width-md";
            RockDropDownList upperValueControl = new RockDropDownList { ID = string.Format( "{0}_ddlUpper", id ) };
            upperValueControl.CssClass = "input-width-md";
            pnlRange.Controls.Add( lowerValueControl );
            pnlRange.Controls.Add( new Label { CssClass = "to", Text = " to " } );
            pnlRange.Controls.Add( upperValueControl );

            if ( configurationValues != null && configurationValues.ContainsKey( DEFINED_TYPE_KEY ) )
            {
                Guid definedTypeGuid = configurationValues.GetValueOrNull( DEFINED_TYPE_KEY ).AsGuid();
                DefinedTypeCache definedType = DefinedTypeCache.Read( definedTypeGuid );

                if ( definedType != null )
                {
                    var definedValues = definedType.DefinedValues;
                    if ( definedValues.Any() )
                    {
                        bool useDescription = configurationValues.GetValueOrNull( DISPLAY_DESCRIPTION ).AsBoolean();

                        lowerValueControl.Items.Add( new ListItem() );
                        upperValueControl.Items.Add( new ListItem() );

                        foreach ( var definedValue in definedValues)
                        {
                            lowerValueControl.Items.Add( new ListItem( useDescription ? definedValue.Description : definedValue.Value, definedValue.Guid.ToString() ) );
                            upperValueControl.Items.Add( new ListItem( useDescription ? definedValue.Description : definedValue.Value, definedValue.Guid.ToString() ) );
                        }
                    }

                    return pnlRange;
                }
            }

            return null;
        }
        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
        {
            if ( value != null )
            {
                string[] valuePair = value.Split( new char[] { ',' }, StringSplitOptions.None );
                if ( valuePair.Length == 2 )
                {
                    bool useDescription = false;
                    if ( !condensed && configurationValues.GetValueOrNull( DISPLAY_DESCRIPTION ).AsBoolean() )
                    {
                        useDescription = true;
                    }

                    var lowerDefinedValue = DefinedValueCache.Read( valuePair[0].AsGuid() );
                    var upperDefinedValue = DefinedValueCache.Read( valuePair[1].AsGuid() );
                    if ( lowerDefinedValue != null || upperDefinedValue != null )
                    {
                        if ( useDescription )
                        {
                            return string.Format(
                                "{0} to {1}",
                                lowerDefinedValue != null ? lowerDefinedValue.Description : string.Empty,
                                upperDefinedValue != null ? upperDefinedValue.Description : string.Empty );
                        }
                        else
                        {
                            return string.Format(
                                "{0} to {1}",
                                lowerDefinedValue != null ? lowerDefinedValue.Value : string.Empty,
                                upperDefinedValue != null ? upperDefinedValue.Value : string.Empty );
                        }
                    }
                    else
                    {
                        return string.Empty;
                    }
                }
            }

            // something unexpected.  Let the base format it
            return base.FormatValue( parentControl, value, configurationValues, condensed );
        }
        /// <summary>
        /// Sets the configuration value.
        /// </summary>
        /// <param name="controls"></param>
        /// <param name="configurationValues"></param>
        public override void SetConfigurationValues( List<Control> controls, Dictionary<string, ConfigurationValue> configurationValues )
        {
            if ( controls != null && configurationValues != null )
            {
                DropDownList ddlDefinedType = controls.Count > 0 ? controls[0] as DropDownList : null;
                CheckBox cbDisplayDescription = controls.Count > 1 ? controls[1] as CheckBox : null;
                if ( ddlDefinedType != null )
                {
                    ddlDefinedType.SelectedValue = configurationValues.GetValueOrNull( DEFINED_TYPE_KEY );
                }

                if ( cbDisplayDescription != null )
                {
                    cbDisplayDescription.Checked = configurationValues.GetValueOrNull( DISPLAY_DESCRIPTION ).AsBoolean();
                }
            }
        }
Example #7
0
        static string GetMessageLabel(Dictionary<string, string> headers)
        {
            var id = headers.GetValueOrNull(Headers.MessageId) ?? "<unknown>";

            string type;

            if (headers.TryGetValue(Headers.Type, out type))
            {
                var dotnetType = Type.GetType(type);

                if (dotnetType != null)
                {
                    type = dotnetType.Name;
                }
            }
            else
            {
                type = "<unknown>";
            }

            return $"{type}/{id}";
        }