public override void Initialize(string name, NameValueCollection config)
        {
            string temp = null;

            Debug.Trace("SimpleMailWebEventProvider", "Initializing: name=" + name);

            ProviderUtil.GetAndRemoveStringAttribute(config, "bodyHeader", name, ref _bodyHeader);
            if (_bodyHeader != null)
            {
                _bodyHeader += "\n";
            }

            ProviderUtil.GetAndRemoveStringAttribute(config, "bodyFooter", name, ref _bodyFooter);
            if (_bodyFooter != null)
            {
                _bodyFooter += "\n";
            }

            ProviderUtil.GetAndRemoveStringAttribute(config, "separator", name, ref temp);
            if (temp != null)
            {
                _separator = temp + "\n";
            }

            ProviderUtil.GetAndRemovePositiveOrInfiniteAttribute(config, "maxEventLength", name, ref _maxEventLength);

            base.Initialize(name, config);
        }
Exemplo n.º 2
0
        public override void Initialize(string name, NameValueCollection config)
        {
            Debug.Trace("SqlWebEventProvider", "Initializing: name=" + name);
            _SchemaVersionCheck = 0;
            string temp = null;

            ProviderUtil.GetAndRemoveStringAttribute(config, "connectionStringName", name, ref temp);
            ProviderUtil.GetAndRemoveStringAttribute(config, "connectionString", name, ref _sqlConnectionString);
            if (!String.IsNullOrEmpty(temp))
            {
                if (!String.IsNullOrEmpty(_sqlConnectionString))
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Only_one_connection_string_allowed));
                }

                _sqlConnectionString = SqlConnectionHelper.GetConnectionString(temp, true, true);
                if (_sqlConnectionString == null || _sqlConnectionString.Length < 1)
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Connection_string_not_found, temp));
                }
            }
            else
            {
                // If a connection string is specified explicitly, verify that its not using integrated security
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(_sqlConnectionString);
                if (builder.IntegratedSecurity)
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Cannot_use_integrated_security));
                }
            }

            if (String.IsNullOrEmpty(_sqlConnectionString))
            {
                throw new ConfigurationErrorsException(SR.GetString(SR.Must_specify_connection_string_or_name, temp));
            }


            ProviderUtil.GetAndRemovePositiveOrInfiniteAttribute(config, "maxEventDetailsLength", name, ref _maxEventDetailsLength);
            if (_maxEventDetailsLength == ProviderUtil.Infinite)
            {
                _maxEventDetailsLength = NO_LIMIT;
            }
            else if (_maxEventDetailsLength > SQL_MAX_NTEXT_SIZE)
            {
                throw new ConfigurationErrorsException(SR.GetString(SR.Invalid_max_event_details_length, name, _maxEventDetailsLength.ToString(CultureInfo.CurrentCulture)));
            }

            ProviderUtil.GetAndRemovePositiveAttribute(config, "commandTimeout", name, ref _commandTimeout);

            base.Initialize(name, config);
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            this._SchemaVersionCheck = 0;
            string val = null;

            ProviderUtil.GetAndRemoveStringAttribute(config, "connectionStringName", name, ref val);
            ProviderUtil.GetAndRemoveStringAttribute(config, "connectionString", name, ref this._sqlConnectionString);
            if (!string.IsNullOrEmpty(val))
            {
                if (!string.IsNullOrEmpty(this._sqlConnectionString))
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Only_one_connection_string_allowed"));
                }
                this._sqlConnectionString = SqlConnectionHelper.GetConnectionString(val, true, true);
                if ((this._sqlConnectionString == null) || (this._sqlConnectionString.Length < 1))
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Connection_string_not_found", new object[] { val }));
                }
            }
            else
            {
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(this._sqlConnectionString);
                if (builder.IntegratedSecurity)
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Cannot_use_integrated_security"));
                }
            }
            if (string.IsNullOrEmpty(this._sqlConnectionString))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Must_specify_connection_string_or_name", new object[] { val }));
            }
            ProviderUtil.GetAndRemovePositiveOrInfiniteAttribute(config, "maxEventDetailsLength", name, ref this._maxEventDetailsLength);
            if (this._maxEventDetailsLength == 0x7fffffff)
            {
                this._maxEventDetailsLength = -1;
            }
            else if (this._maxEventDetailsLength > 0x3fffffff)
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Invalid_max_event_details_length", new object[] { name, this._maxEventDetailsLength.ToString(CultureInfo.CurrentCulture) }));
            }
            ProviderUtil.GetAndRemovePositiveAttribute(config, "commandTimeout", name, ref this._commandTimeout);
            base.Initialize(name, config);
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            string val = null;

            ProviderUtil.GetAndRemoveStringAttribute(config, "bodyHeader", name, ref this._bodyHeader);
            if (this._bodyHeader != null)
            {
                this._bodyHeader = this._bodyHeader + "\n";
            }
            ProviderUtil.GetAndRemoveStringAttribute(config, "bodyFooter", name, ref this._bodyFooter);
            if (this._bodyFooter != null)
            {
                this._bodyFooter = this._bodyFooter + "\n";
            }
            ProviderUtil.GetAndRemoveStringAttribute(config, "separator", name, ref val);
            if (val != null)
            {
                this._separator = val + "\n";
            }
            ProviderUtil.GetAndRemovePositiveOrInfiniteAttribute(config, "maxEventLength", name, ref this._maxEventLength);
            base.Initialize(name, config);
        }