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>
        /// 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. 4
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. 5
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);
        }
Esempio n. 6
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name="mailFrom">The mail from.</param>
        /// <param name="rcptTo">The RCPT to.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="emlData">The eml data.</param>
        internal static void SendMessage(OutgoingEmailServiceType serviceType, int?serviceKey, string mailFrom, string rcptTo, string subject, byte[] emlData)
        {
            //EmailMessageSmtpQueueRow newOutMsg = new EmailMessageSmtpQueueRow();
            //newOutMsg.MailFrom = MailFrom;
            //newOutMsg.RcptTo = RcptTo;
            //newOutMsg.Subject = Subject;
            //newOutMsg.Created = DateTime.UtcNow;
            //newOutMsg.ErrorMsg = string.Empty;

            //newOutMsg.Update();
            //using (Stream outStream = newOutMsg.GetEmlData(DbContext.Current.Transaction, SqlBlobAccess.Write))
            //{
            //    outStream.Write(EmlData, 0, EmlData.Length);
            //    outStream.Flush();
            //}
            //tran.Commit();
            EmailEntity email = BusinessManager.InitializeEntity <EmailEntity>(EmailEntity.ClassName);

            email.From           = mailFrom;
            email.To             = rcptTo;
            email.Subject        = subject;
            email.MessageContext = System.Text.Encoding.Default.GetString(emlData);

            email.HtmlBody = string.Empty;

            // Create Message
            CreateRequest request = new CreateRequest(email);

            request.Parameters.Add(OutgoingMessageQueuePlugin.AddToQueue, true);
            request.Parameters.Add(OutgoingMessageQueuePlugin.SourceName,
                                   string.Format("{0}{1}",
                                                 serviceType,
                                                 serviceKey.HasValue?(":" + serviceKey.Value.ToString()):""));

            BusinessManager.Execute(request);
        }
Esempio n. 7
0
 /// <summary>
 /// Finds the SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int? key)
 {
     return FindSmtpBox(serviceType, key, true);
 }
Esempio n. 8
0
 /// <summary>
 /// Finds the SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <param name="returnDefault">if set to <c>true</c> [return default].</param>
 /// <returns></returns>
 public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, bool returnDefault)
 {
     return FindSmtpBox(serviceType, null, returnDefault);
 }
Esempio n. 9
0
 /// <summary>
 /// Finds the SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <returns></returns>
 public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType)
 {
     return FindSmtpBox(serviceType, null, true);
 }
Esempio n. 10
0
 /// <summary>
 /// Assigns the with SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <param name="smtpBoxId">The SMTP box id.</param>
 public static void AssignWithSmtpBox(OutgoingEmailServiceType serviceType, int smtpBoxId)
 {
     AssignWithSmtpBox(serviceType, null, smtpBoxId);
 }
Esempio n. 11
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. 12
0
 /// <summary>
 /// Finds the SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <param name="returnDefault">if set to <c>true</c> [return default].</param>
 /// <returns></returns>
 public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, bool returnDefault)
 {
     return(FindSmtpBox(serviceType, null, returnDefault));
 }
Esempio n. 13
0
 /// <summary>
 /// Finds the SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <returns></returns>
 public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType)
 {
     return(FindSmtpBox(serviceType, null, true));
 }
Esempio n. 14
0
 /// <summary>
 /// Assigns the with SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <param name="smtpBoxId">The SMTP box id.</param>
 public static void AssignWithSmtpBox(OutgoingEmailServiceType serviceType, int smtpBoxId)
 {
     AssignWithSmtpBox(serviceType, null, smtpBoxId);
 }
Esempio n. 15
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;
        }
Esempio n. 16
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. 17
0
 /// <summary>
 /// Finds the SMTP box.
 /// </summary>
 /// <param name="serviceType">Type of the service.</param>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public static SmtpBox FindSmtpBox(OutgoingEmailServiceType serviceType, int?key)
 {
     return(FindSmtpBox(serviceType, key, true));
 }