Exemplo n.º 1
0
 protected override void ComposeTo(Notification notification)
 {
     if (IsValidEmail(UserEmail))
     {
         NotificationAddress to = new NotificationAddress(UserEmail);
         notification.To.Add(to);
     }
     // order coordinator of the website
     if (IsValidEmail(WebContext.Current.ApplicationOption.OrderCoordinatorEmail))
     {
         NotificationAddress to = new NotificationAddress(WebContext.Current.ApplicationOption.OrderCoordinatorEmail);
         notification.To.Add(to);
     }
     // customer shipto email
     if (WebContext.Current.ApplicationOption.IsEmailToCustomer)
     {
         foreach (OrderInfoDto order in Orders)
         {
             if (IsValidEmail(order.NotificationEmail))
             {
                 NotificationAddress to = new NotificationAddress(order.NotificationEmail);
                 notification.To.Add(to);
             }
         }
     }
 }
 public static MailAddress Convert(NotificationAddress address)
 {
     if (string.IsNullOrEmpty(address.DisplayName))
     {
         return(new MailAddress(address.Identifier));
     }
     return(new MailAddress(address.Identifier, address.DisplayName));
 }
Exemplo n.º 3
0
 protected virtual void ComposeTo(Notification notification)
 {
     // site coordinator of the website
     if (IsValidEmail(WebContext.Current.ApplicationOption.SiteCoordinatorEmail))
     {
         NotificationAddress to = new NotificationAddress(WebContext.Current.ApplicationOption.SiteCoordinatorEmail);
         notification.To.Add(to);
     }
 }
Exemplo n.º 4
0
        protected void WorkerInitialization(WorkItemType itemType, string itemsDefinitionKey)
        {
            Guard.AssertNotNullOrEmptyString(itemsDefinitionKey);
            Guard.AssertNotNull(this.SnapshotRepository);

            WorkDescription w = new WorkDescription(this.SnapshotRepository, itemType);

            w.AccessToken = this.Configuration[WorkerApplication.TokenVariableName];
            if (string.IsNullOrEmpty(w.AccessToken))
            {
                throw new InvalidOperationException(string.Format("{0} not available via appsettings or environment variable", TokenVariableName));
            }

            w.Items = this.Configuration.GetStringArrayFromConfiguration(itemsDefinitionKey, false, this.Logger);

            w.Channels = this.Configuration.DefineChannels(this.Logger);

            string fromEmail = string.Format("{0}", this.Configuration["eMail.From"]);

            if (string.IsNullOrEmpty(fromEmail))
            {
                throw new InvalidOperationException("eMail.From not defined in appsettings");
            }
            fromEmail = System.Environment.ExpandEnvironmentVariables(fromEmail);
            if (string.IsNullOrEmpty(fromEmail))
            {
                throw new InvalidOperationException("eMail.From empty afer ExpandEnvironmentVariables");
            }


            NotificationAddress fromAddress = new NotificationAddress()
            {
                Identifier = fromEmail
            };

            base.Logger.LogTrace("eMail.From={0}", fromEmail);

            string[] to = this.Configuration.GetStringArrayFromConfiguration("eMail.To", true, this.Logger);
            List <NotificationAddress> toAddresses = new List <NotificationAddress>();

            foreach (string value in to)
            {
                toAddresses.Add(new NotificationAddress()
                {
                    Identifier = value
                });
            }

            w.From           = fromAddress;
            w.To             = toAddresses.ToArray();
            this.CurrentWork = w;
        }