Esempio n. 1
0
        /// <summary>
        /// Assigns the with default SMTP box.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="key">The key.</param>
        public static void AssignWithDefaultSmtpBox(OutgoingEmailServiceType serviceType, int?key)
        {
            OutgoingEmailServiceConfigRow row = FindConfigRow(serviceType, key);

            if (row != null)
            {
                row.Delete();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Assigns the with SMTP box.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="key">The key.</param>
        /// <param name="smtpBoxId">The SMTP box id.</param>
        public static void AssignWithSmtpBox(OutgoingEmailServiceType serviceType, int?key, int smtpBoxId)
        {
            OutgoingEmailServiceConfigRow row = FindConfigRow(serviceType, key);

            if (row == null)
            {
                row             = new OutgoingEmailServiceConfigRow();
                row.ServiceType = (int)serviceType;
                row.ServiceKey  = key;
            }
            row.SmtpBoxId = smtpBoxId;
            row.Update();
        }
Esempio n. 3
0
        /// <summary>
        /// Finds the config row.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        private static OutgoingEmailServiceConfigRow FindConfigRow(OutgoingEmailServiceType serviceType, int?key)
        {
            OutgoingEmailServiceConfigRow[] configs = OutgoingEmailServiceConfigRow.List(
                FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceType, serviceType),
                key.HasValue ?
                FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceKey, key):
                FilterElement.IsNullElement(OutgoingEmailServiceConfigRow.ColumnServiceKey));

            if (configs.Length > 0)
            {
                return(configs[0]);
            }

            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Finds the Smtp box.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="key">The key.</param>
        /// <param name="returnDefault">if set to <c>true</c> [return default].</param>
        /// <returns></returns>
        public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int?key, bool returnDefault)
        {
            OutgoingEmailServiceConfigRow config = FindConfigRow(serviceType, key);

            if (config != null)
            {
                return(SmtpBox.Load(config.SmtpBoxId));
            }

            // Return Default
            if (returnDefault)
            {
                return(SmtpBox.GetDefault());
            }

            return(null);
        }