Пример #1
0
        private void LoadSettings()
        {
            letterGuid = WebUtils.ParseGuidFromQueryString("letter", Guid.Empty);

            if (letterGuid != Guid.Empty)
            {
                letter = new Letter(letterGuid);
                if (letter.LetterGuid != Guid.Empty)
                {
                    letterInfo = new LetterInfo(letter.LetterInfoGuid);
                    if (letterInfo.SiteGuid != siteSettings.SiteGuid) { letter = null; }
                    if (!WebUser.IsInRoles(letterInfo.AvailableToRoles)) { letter = null; }
                    if ((!letterInfo.AllowArchiveView)&&(!WebUser.IsNewsletterAdmin))
                    {
                        letter = null;
                        unavailableReason = Resource.NewsletterArchivesNotAllowed;

                    }

                }
                else
                {
                    letter = null;
                }

            }

            AddClassToBody("administration");
            AddClassToBody("letterview");
        }
Пример #2
0
        private void LoadSettings()
        {
            currentUser = SiteUtils.GetCurrentSiteUser();
            letterInfoGuid = WebUtils.ParseGuidFromQueryString("l", Guid.Empty);
            //spnAdmin.Visible = WebUser.IsAdminOrContentAdmin;
            ScriptConfig.IncludeColorBox = true;

            if (letterInfoGuid == Guid.Empty) return;

            letterInfo = new LetterInfo(letterInfoGuid);
            if (letterInfo.SiteGuid != siteSettings.SiteGuid)
            {
                letterInfo = null;
                letterInfoGuid = Guid.Empty;

            }

            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone = SiteUtils.GetUserTimeZone();

            lnkAdminMenu.Visible = WebUser.IsAdminOrContentAdmin;
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("eletterarchive");
        }
Пример #3
0
        private void LoadSettings()
        {
            //spnAdmin.Visible = WebUser.IsAdminOrContentAdmin;

            currentUser = SiteUtils.GetCurrentSiteUser();
            letterInfoGuid = WebUtils.ParseGuidFromQueryString("l", Guid.Empty);

            if (letterInfoGuid == Guid.Empty) return;

            letterInfo = new LetterInfo(letterInfoGuid);
            if (letterInfo.SiteGuid != siteSettings.SiteGuid)
            {
                letterInfo = null;
                letterInfoGuid = Guid.Empty;

            }

            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);

            lnkAdminMenu.Visible = WebUser.IsAdminOrContentAdmin;
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("eletterdrafts");
        }
Пример #4
0
        private void RunTask()
        {
            Letter letter = new Letter(this.letterGuid);

            if (letter.LetterGuid == Guid.Empty)
            {
                return;
            }
            if (letter.SendCompleteUtc > DateTime.MinValue)
            {
                return;
            }
            if (letter.SendClickedUtc == DateTime.MinValue)
            {
                return;
            }

            LetterInfo letterInfo = new LetterInfo(letter.LetterInfoGuid);

            // TODO: this could be a very large recordset if the kist is very large
            // might be better to get a page at a time instead of all at once.

            List <LetterSubscriber> subscribers
                = LetterSubscriber.GetSubscribersNotSentYet(
                      letter.LetterGuid,
                      letter.LetterInfoGuid);

            nextStatusUpdateTime   = DateTime.UtcNow.AddSeconds(updateFrequency);
            totalSubscribersToSend = subscribers.Count;

            if ((totalSubscribersToSend > 0) && (letter.SendStartedUtc == DateTime.MinValue))
            {
                letter.TrackSendStarted();
            }

            SmtpSettings smtpSettings = new SmtpSettings();

            smtpSettings.Password               = password;
            smtpSettings.Port                   = port;
            smtpSettings.PreferredEncoding      = preferredEncoding;
            smtpSettings.RequiresAuthentication = requiresAuthentication;
            smtpSettings.UseSsl                 = useSsl;
            smtpSettings.User                   = user;
            smtpSettings.Server                 = server;

            foreach (LetterSubscriber subscriber in subscribers)
            {
                SendLetter(smtpSettings, letterInfo, letter, subscriber);
                subscribersSentSoFar += 1;

                if (DateTime.UtcNow > nextStatusUpdateTime)
                {
                    ReportStatus();
                }
            }

            ReportStatus();
        }
Пример #5
0
        private void DoUnsubscribe()
        {
            if (subscriptionGuid != Guid.Empty)
            {
                LetterSubscriber s = subscriptions.Fetch(subscriptionGuid);
                if (s == null)
                {
                    ShowNotFoundMessge();
                    return;
                }
                subscriptions.Delete(s);
                LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);
                lblUnsubscribe.Text = Resource.NewsletterUnsubscribeSuccess;

                btnUnsubscribeConfirm.Visible = false;
                lblUnsubscribe.Visible = true;
                return;
            }

            LetterInfo letterInfo = new LetterInfo(letterInfoGuid);
            if (letterInfo.LetterInfoGuid == Guid.Empty)
            {
                ShowNotFoundMessge();
                return;
            }

            List<LetterSubscriber> userSubscriptions = subscriptions.GetListByUser(siteSettings.SiteGuid, userGuid);

            bool unsubscribed = false;

            foreach (LetterSubscriber s in userSubscriptions)
            {
                if (s.LetterInfoGuid == letterInfoGuid)
                {
                    subscriptions.Delete(s);
                    unsubscribed = true;
                    LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);
                }

            }

            if (unsubscribed)
            {
                lblUnsubscribe.Text = string.Format(CultureInfo.InvariantCulture,
                    Resource.NewsletterUnsubscribeSuccessFormatString,
                    letterInfo.Title);

                btnUnsubscribeConfirm.Visible = false;
                lblUnsubscribe.Visible = true;
            }
            else
            {
                ShowNotFoundMessge();
            }
        }
Пример #6
0
        private static List <LetterInfo> LoadFromReader(IDataReader reader)
        {
            List <LetterInfo> letterInfoList = new List <LetterInfo>();

            try
            {
                while (reader.Read())
                {
                    LetterInfo letterInfo = new LetterInfo();
                    letterInfo.LetterInfoGuid      = new Guid(reader["LetterInfoGuid"].ToString());
                    letterInfo.SiteGuid            = new Guid(reader["SiteGuid"].ToString());
                    letterInfo.Title               = reader["Title"].ToString();
                    letterInfo.Description         = reader["Description"].ToString();
                    letterInfo.AvailableToRoles    = reader["AvailableToRoles"].ToString();
                    letterInfo.Enabled             = Convert.ToBoolean(reader["Enabled"]);
                    letterInfo.AllowUserFeedback   = Convert.ToBoolean(reader["AllowUserFeedback"]);
                    letterInfo.AllowAnonFeedback   = Convert.ToBoolean(reader["AllowAnonFeedback"]);
                    letterInfo.FromAddress         = reader["FromAddress"].ToString();
                    letterInfo.FromName            = reader["FromName"].ToString();
                    letterInfo.ReplyToAddress      = reader["ReplyToAddress"].ToString();
                    letterInfo.SendMode            = Convert.ToInt32(reader["SendMode"]);
                    letterInfo.EnableViewAsWebPage = Convert.ToBoolean(reader["EnableViewAsWebPage"]);
                    letterInfo.EnableSendLog       = Convert.ToBoolean(reader["EnableSendLog"]);
                    letterInfo.RolesThatCanEdit    = reader["RolesThatCanEdit"].ToString();
                    letterInfo.RolesThatCanApprove = reader["RolesThatCanApprove"].ToString();
                    letterInfo.RolesThatCanSend    = reader["RolesThatCanSend"].ToString();
                    letterInfo.CreatedUtc          = Convert.ToDateTime(reader["CreatedUTC"]);
                    letterInfo.CreatedBy           = new Guid(reader["CreatedBy"].ToString());
                    letterInfo.LastModUtc          = Convert.ToDateTime(reader["LastModUTC"]);
                    letterInfo.LastModBy           = new Guid(reader["LastModBy"].ToString());
                    letterInfo.SubscriberCount     = Convert.ToInt32(reader["SubscriberCount"]);
                    letterInfo.UnVerifiedCount     = Convert.ToInt32(reader["UnVerifiedCount"]);
                    letterInfo.AllowArchiveView    = Convert.ToBoolean(reader["AllowArchiveView"]);
                    letterInfo.ProfileOptIn        = Convert.ToBoolean(reader["ProfileOptIn"]);
                    letterInfo.SortRank            = Convert.ToInt32(reader["SortRank"]);

                    letterInfo.DisplayNameDefault = reader["DisplayNameDefault"].ToString();
                    letterInfo.FirstNameDefault   = reader["FirstNameDefault"].ToString();
                    letterInfo.LastNameDefault    = reader["LastNameDefault"].ToString();
                    if (reader["SendClickedUTC"] != DBNull.Value)
                    {
                        letterInfo.LastSentUtc = Convert.ToDateTime(reader["SendClickedUTC"]);
                    }
                    letterInfoList.Add(letterInfo);
                }
            }
            finally
            {
                reader.Close();
            }

            return(letterInfoList);
        }
Пример #7
0
        private void LoadSettings()
        {
            if (letterInfoGuid != Guid.Empty)
            {
                letterInfo = new LetterInfo(letterInfoGuid);
                if (letterInfo.LetterInfoGuid == Guid.Empty) { letterInfo = null; }
                if (letterInfo.SiteGuid != siteSettings.SiteGuid) { letterInfo = null; }
            }

            if (letterGuid != Guid.Empty)
            {
                letter = new Letter(letterGuid);
                if (letter.LetterGuid == Guid.Empty) { letter = null; }
                if (letter.LetterInfoGuid != letterInfoGuid) { letter = null; }
            }

            lnkSendLog.NavigateUrl = SiteRoot + "/eletter/SendLog.aspx?letter=" + letterGuid.ToString();

            lnkAdminMenu.Visible = WebUser.IsAdminOrContentAdmin;
            litLinkSeparator1.Visible = lnkAdminMenu.Visible;

            AddClassToBody("administration");
            AddClassToBody("lettersendprogress");
        }
Пример #8
0
        private void SendLetter(
            SmtpSettings smtpSettings,
            LetterInfo letterInfo,
            Letter letter,
            LetterSubscriber subscriber)
        {
            // TODO: use multi part email with both html and plain text body
            // instead of this either or approach

            bool testMode = false;

            if (
                (ConfigurationManager.AppSettings["NewsletterTestMode"] != null) &&
                (ConfigurationManager.AppSettings["NewsletterTestMode"] == "true")
                )
            {
                testMode = true;
            }

            LetterSendLog mailLog = new LetterSendLog();

            mailLog.EmailAddress = subscriber.EmailAddress;
            mailLog.LetterGuid   = letter.LetterGuid;
            mailLog.UserGuid     = subscriber.UserGuid;

            if (testMode)
            {
                Thread.Sleep(3000); // sleep 3 seconds per message to simulate
            }
            else
            {
                try
                {
                    if (subscriber.UseHtml)
                    {
                        Email.SendEmail(
                            smtpSettings,
                            letterInfo.FromAddress,
                            subscriber.EmailAddress,
                            string.Empty,
                            string.Empty,
                            letter.Subject,
                            ReplaceHtmlTokens(letter.HtmlBody, subscriber),
                            subscriber.UseHtml,
                            "Normal");
                    }
                    else
                    {
                        Email.SendEmail(
                            smtpSettings,
                            letterInfo.FromAddress,
                            subscriber.EmailAddress,
                            string.Empty,
                            string.Empty,
                            letter.Subject,
                            ReplaceTextTokens(letter.TextBody, subscriber),
                            subscriber.UseHtml,
                            "Normal");
                    }
                }
                catch (Exception ex)
                {
                    // TODO: catch more specific exception(s) figure out what ones can be thrown here
                    mailLog.ErrorOccurred = true;
                    mailLog.ErrorMessage  = ex.ToString();
                    log.Error(ex);
                }
            }

            mailLog.Save();
        }
Пример #9
0
        private void DoSubscribe(LetterInfo letter, SiteUser siteUser)
        {
            LetterSubscriber s = new LetterSubscriber();
            s.SiteGuid = siteSettings.SiteGuid;
            s.EmailAddress = siteUser.Email;
            s.UserGuid = siteUser.UserGuid;
            s.LetterInfoGuid = letter.LetterInfoGuid;
            s.UseHtml = true;
            s.IsVerified = true;
            s.IpAddress = SiteUtils.GetIP4Address();
            subscriptions.Save(s);

            LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);
        }
Пример #10
0
        private void PopulateLetterInfoControls()
        {
            //if (letterInfoGuid == Guid.Empty) return;

            LetterInfo letterInfo = new LetterInfo(letterInfoGuid);

            if (letterInfo.Title.Length > 0)
            {
                lnkThisPage.Text = letterInfo.Title;
            }

            txtTitle.Text = letterInfo.Title;
            edDescription.Text = letterInfo.Description;
            //txtAvailableToRoles.Text = letterInfo.AvailableToRoles.ToString();
            chkEnabled.Checked = letterInfo.Enabled;
            chkAllowUserFeedback.Checked = letterInfo.AllowUserFeedback;
            chkAllowAnonFeedback.Checked = letterInfo.AllowAnonFeedback;
            txtFromAddress.Text = letterInfo.FromAddress;
            txtFromName.Text = letterInfo.FromName;
            txtReplyToAddress.Text = letterInfo.ReplyToAddress;
            //txtSendMode.Text = letterInfo.SendMode.ToString();
            chkEnableViewAsWebPage.Checked = letterInfo.EnableViewAsWebPage;
            chkEnableSendLog.Checked = letterInfo.EnableSendLog;

            chkAllowArchiveView.Checked = letterInfo.AllowArchiveView;
            chkProfileOptIn.Checked = letterInfo.ProfileOptIn;
            txtSortRank.Text = letterInfo.SortRank.ToInvariantString();

            txtDisplayNameDefault.Text = letterInfo.DisplayNameDefault;
            txtFirstNameDefault.Text = letterInfo.FirstNameDefault;
            txtLastNameDefault.Text = letterInfo.LastNameDefault;

            if (letterInfoGuid != Guid.Empty)
            {
                lblLastModified.Text = letterInfo.LastModUtc.ToString();
            }

            ListItem allItem = new ListItem();
            // localize display
            allItem.Text = Resource.RolesAllUsersRole;
            allItem.Value = "All Users";

            if (
                (letterInfo.AvailableToRoles.LastIndexOf("All Users") > -1)
                ||(letterInfoGuid == Guid.Empty)
                )
            {
                allItem.Selected = true;
            }

            chkListAvailableToRoles.Items.Clear();
            chkListAvailableToRoles.Items.Add(allItem);

            chkListEditRoles.Items.Clear();
            chkListApproveRoles.Items.Clear();
            chkListSendMailRoles.Items.Clear();

            using (IDataReader reader = Role.GetSiteRoles(siteSettings.SiteId))
            {
                while (reader.Read())
                {

                    ListItem listItem = new ListItem();
                    listItem.Text = reader["DisplayName"].ToString();
                    listItem.Value = reader["RoleName"].ToString();

                    if ((letterInfo.AvailableToRoles.LastIndexOf(listItem.Value + ";")) > -1)
                    {
                        listItem.Selected = true;
                    }

                    chkListAvailableToRoles.Items.Add(listItem);

                    // edit roles

                    ListItem editItem = new ListItem();
                    editItem.Text = reader["DisplayName"].ToString();
                    editItem.Value = reader["RoleName"].ToString();

                    if ((letterInfo.RolesThatCanEdit.LastIndexOf(editItem.Value + ";")) > -1)
                    {
                        editItem.Selected = true;
                    }

                    chkListEditRoles.Items.Add(editItem);

                    // approve roles
                    ListItem approveItem = new ListItem();
                    approveItem.Text = reader["DisplayName"].ToString();
                    approveItem.Value = reader["RoleName"].ToString();

                    if ((letterInfo.RolesThatCanApprove.LastIndexOf(approveItem.Value + ";")) > -1)
                    {
                        approveItem.Selected = true;
                    }

                    chkListApproveRoles.Items.Add(approveItem);

                    // send roles
                    ListItem sendItem = new ListItem();
                    sendItem.Text = reader["DisplayName"].ToString();
                    sendItem.Value = reader["RoleName"].ToString();

                    if ((letterInfo.RolesThatCanSend.LastIndexOf(sendItem.Value + ";")) > -1)
                    {
                        sendItem.Selected = true;
                    }

                    chkListSendMailRoles.Items.Add(sendItem);

                }
            }
        }
Пример #11
0
 private void PopulateControls()
 {
     if (subscription == null)
     {
         pnlNotFound.Visible = true;
         pnlConfirmed.Visible = false;
     }
     else
     {
         letterInfo = new LetterInfo(subscription.LetterInfoGuid);
         litConfrimDetails.Text = string.Format(CultureInfo.InvariantCulture, Resource.NewsletterConfirmedFormat, letterInfo.Title);
         pnlNotFound.Visible = false;
         pnlConfirmed.Visible = true;
     }
 }
Пример #12
0
        private void ShowUnsubscribePrompt()
        {
            LetterInfo letterInfo = new LetterInfo(letterInfoGuid);
            if (letterInfo.LetterInfoGuid == Guid.Empty)
            {
                ShowNotFoundMessge();
                return;
            }

            btnUnsubscribeConfirm.Visible = true;
            lblUnsubscribe.Visible = false;
            btnUnsubscribeConfirm.Text = string.Format(CultureInfo.InvariantCulture,
                Resource.NewsletterUnsubscribeConfirmFormatString,
                Server.HtmlEncode(letterInfo.Title));
        }
Пример #13
0
        private void RunTask()
        {
            Letter letter = new Letter(this.letterGuid);
            if (letter.LetterGuid == Guid.Empty)
            {
                log.Error("LetterSendTask letter not found so ending.");
                ReportStatus();
                return;
            }
            if (letter.SendCompleteUtc > DateTime.MinValue)
            {
                log.Error("LetterSendTask SendCompleteUtc already set so ending.");
                ReportStatus();
                return;
            }
            if (letter.SendClickedUtc == DateTime.MinValue)
            {
                log.Error("LetterSendTask SendClickedUtc has an invalid value so ending.");
                ReportStatus();
                return;
            }

            LetterInfo letterInfo = new LetterInfo(letter.LetterInfoGuid);
            SubscriberRepository subscriptions = new SubscriberRepository();

            if (WebConfigSettings.NewsletterTestMode)
            {
                testMode = true;
                log.Info("using NewsletterTestMode=true in config so no real emails will be sent for newsletter " + letterInfo.Title);
            }

            // TODO: this could be a very large recordset if the list is very large
            // might be better to get a page at a time instead of all at once.
            List<LetterSubscriber> subscribers
                = subscriptions.GetSubscribersNotSentYet(
                letter.LetterGuid,
                letter.LetterInfoGuid);

            nextStatusUpdateTime = DateTime.UtcNow.AddSeconds(reportingFrequency);
            totalSubscribersToSend = subscribers.Count;

            if ((totalSubscribersToSend > 0) && (letter.SendStartedUtc == DateTime.MinValue))
            {
                letter.TrackSendStarted();
            }

            if (totalSubscribersToSend < 100) { testSleepMilliseconds = 3000; }
            if (totalSubscribersToSend > 300) { testSleepMilliseconds = 500;}
            if (totalSubscribersToSend > 500) { testSleepMilliseconds = 100; }

            SmtpSettings smtpSettings = new SmtpSettings();
            smtpSettings.Password = password;
            smtpSettings.Port = port;
            smtpSettings.PreferredEncoding = preferredEncoding;
            smtpSettings.RequiresAuthentication = requiresAuthentication;
            smtpSettings.UseSsl = useSsl;
            smtpSettings.User = user;
            smtpSettings.Server = server;
            smtpSettings.AddBulkMailHeader = true;

            if (maxToSendPerMinute == 0) //not limit
            {
                foreach (LetterSubscriber subscriber in subscribers)
                {
                    SendLetter(smtpSettings, letterInfo, letter, subscriber);
                    subscribersSentSoFar += 1;

                    if (DateTime.UtcNow > nextStatusUpdateTime)
                        ReportStatus();

                }
            }
            else
            {
                int sentCount = 0;
                foreach (LetterSubscriber subscriber in subscribers)
                {
                    SendLetter(smtpSettings, letterInfo, letter, subscriber);
                    subscribersSentSoFar += 1;
                    sentCount += 1;

                    if (DateTime.UtcNow > nextStatusUpdateTime)
                        ReportStatus();

                    if (sentCount == maxToSendPerMinute)
                    {
                        ReportSleeping();
                        Thread.Sleep(60000); //sleep 1 minute
                        sentCount = 0;
                    }

                }
            }

            ReportStatus();
        }
Пример #14
0
        private void PopulateControls()
        {
            if (letterInfoGuid == Guid.Empty) return;

            letterInfo = new LetterInfo(letterInfoGuid);

            lnkThisPage.Text = string.Format(CultureInfo.InvariantCulture,
                Resource.NewsletterSubscriberListHeadingFormatString,
                letterInfo.Title);

            lnkThisPage.ToolTip = lnkThisPage.Text;

            heading.Text = lnkThisPage.Text;

            Title = heading.Text;

            int countOfUsersThatCouldOptIn = SubscriberRepository.CountUsersNotSubscribedByLetter(
                siteSettings.SiteGuid,
                letterInfoGuid,
                WebConfigSettings.NewsletterExcludeAllPreviousOptOutsWhenOptingInUsers);

            if (countOfUsersThatCouldOptIn > 0)
            {
                lnkOptIn.Visible = true;
                lnkOptIn.Text = string.Format(CultureInfo.InvariantCulture, Resource.NewsLetterOptInMembersFormat, countOfUsersThatCouldOptIn);
            }

            if (Page.IsPostBack) return;

            BindGrid();
        }
Пример #15
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByAvailableToRoles(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.AvailableToRoles.CompareTo(letterInfo2.AvailableToRoles));
 }
Пример #16
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByDescription(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.Description.CompareTo(letterInfo2.Description));
 }
Пример #17
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByTitle(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.Title.CompareTo(letterInfo2.Title));
 }
Пример #18
0
        private static List<LetterInfo> LoadFromReader(IDataReader reader)
        {
            List<LetterInfo> letterInfoList = new List<LetterInfo>();
            try
            {
                while (reader.Read())
                {
                    LetterInfo letterInfo = new LetterInfo();
                    letterInfo.letterInfoGuid = new Guid(reader["LetterInfoGuid"].ToString());
                    letterInfo.siteGuid = new Guid(reader["SiteGuid"].ToString());
                    letterInfo.title = reader["Title"].ToString();
                    letterInfo.description = reader["Description"].ToString();
                    letterInfo.availableToRoles = reader["AvailableToRoles"].ToString();
                    letterInfo.enabled = Convert.ToBoolean(reader["Enabled"]);
                    letterInfo.allowUserFeedback = Convert.ToBoolean(reader["AllowUserFeedback"]);
                    letterInfo.allowAnonFeedback = Convert.ToBoolean(reader["AllowAnonFeedback"]);
                    letterInfo.fromAddress = reader["FromAddress"].ToString();
                    letterInfo.fromName = reader["FromName"].ToString();
                    letterInfo.replyToAddress = reader["ReplyToAddress"].ToString();
                    letterInfo.sendMode = Convert.ToInt32(reader["SendMode"]);
                    letterInfo.enableViewAsWebPage = Convert.ToBoolean(reader["EnableViewAsWebPage"]);
                    letterInfo.enableSendLog = Convert.ToBoolean(reader["EnableSendLog"]);
                    letterInfo.rolesThatCanEdit = reader["RolesThatCanEdit"].ToString();
                    letterInfo.rolesThatCanApprove = reader["RolesThatCanApprove"].ToString();
                    letterInfo.rolesThatCanSend = reader["RolesThatCanSend"].ToString();
                    letterInfo.createdUTC = Convert.ToDateTime(reader["CreatedUTC"]);
                    letterInfo.createdBy = new Guid(reader["CreatedBy"].ToString());
                    letterInfo.lastModUTC = Convert.ToDateTime(reader["LastModUTC"]);
                    letterInfo.lastModBy = new Guid(reader["LastModBy"].ToString());
                    letterInfo.subscriberCount = Convert.ToInt32(reader["SubscriberCount"]);
                    letterInfo.unVerifiedCount = Convert.ToInt32(reader["UnVerifiedCount"]);
                    letterInfo.AllowArchiveView = Convert.ToBoolean(reader["AllowArchiveView"]);
                    letterInfo.ProfileOptIn = Convert.ToBoolean(reader["ProfileOptIn"]);
                    letterInfo.SortRank = Convert.ToInt32(reader["SortRank"]);

                    letterInfo.displayNameDefault = reader["DisplayNameDefault"].ToString();
                    letterInfo.firstNameDefault = reader["FirstNameDefault"].ToString();
                    letterInfo.lastNameDefault = reader["LastNameDefault"].ToString();

                    letterInfoList.Add(letterInfo);
                }
            }
            finally
            {
                reader.Close();
            }

            return letterInfoList;
        }
Пример #19
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByTitle(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.Title.CompareTo(letterInfo2.Title);
 }
Пример #20
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareBySendMode(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.SendMode.CompareTo(letterInfo2.SendMode);
 }
Пример #21
0
        private void SendLetter(
            SmtpSettings smtpSettings,
            LetterInfo letterInfo, 
            Letter letter, 
            LetterSubscriber subscriber)
        {
            // TODO: use multi part email with both html and plain text body
            // instead of this either or approach

            bool testMode = false;

            if (
                (ConfigurationManager.AppSettings["NewsletterTestMode"] != null)
                && (ConfigurationManager.AppSettings["NewsletterTestMode"] == "true")
                )
            {
                testMode = true;
            }

            LetterSendLog mailLog = new LetterSendLog();
            mailLog.EmailAddress = subscriber.EmailAddress;
            mailLog.LetterGuid = letter.LetterGuid;
            mailLog.UserGuid = subscriber.UserGuid;

            if (testMode)
            {
                Thread.Sleep(3000); // sleep 3 seconds per message to simulate
            }
            else
            {
                try
                {
                    if (subscriber.UseHtml)
                    {
                        Email.SendEmail(
                            smtpSettings,
                            letterInfo.FromAddress,
                            subscriber.EmailAddress,
                            string.Empty,
                            string.Empty,
                            letter.Subject,
                            ReplaceHtmlTokens(letter.HtmlBody, subscriber),
                            subscriber.UseHtml,
                            "Normal");
                    }
                    else
                    {
                        Email.SendEmail(
                            smtpSettings,
                            letterInfo.FromAddress,
                            subscriber.EmailAddress,
                            string.Empty,
                            string.Empty,
                            letter.Subject,
                            ReplaceTextTokens(letter.TextBody, subscriber),
                            subscriber.UseHtml,
                            "Normal");

                    }
                }
                catch (Exception ex)
                {
                    // TODO: catch more specific exception(s) figure out what ones can be thrown here
                    mailLog.ErrorOccurred = true;
                    mailLog.ErrorMessage = ex.ToString();
                    log.Error(ex);

                }
            }

            mailLog.Save();
        }
Пример #22
0
        private void PopulateControls()
        {
            if (letterInfoGuid == Guid.Empty)
            {
                btnOptInUsers.Visible = false;
                return;
            }

            letterInfo = new LetterInfo(letterInfoGuid);
            heading.Text = letterInfo.Title;

            countOfAvailableUsers = SubscriberRepository.CountUsersNotSubscribedByLetter(
                CurrentSite.SiteGuid,
                letterInfoGuid,
                WebConfigSettings.NewsletterExcludeAllPreviousOptOutsWhenOptingInUsers);

            btnOptInUsers.Text = string.Format(CultureInfo.InvariantCulture, Resource.NewsLetterOptInMembersFormat, countOfAvailableUsers);
        }
Пример #23
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByFromAddress(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.FromAddress.CompareTo(letterInfo2.FromAddress));
 }
Пример #24
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByRolesThatCanSend(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.RolesThatCanSend.CompareTo(letterInfo2.RolesThatCanSend);
 }
Пример #25
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByFromName(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.FromName.CompareTo(letterInfo2.FromName));
 }
Пример #26
0
        private void SendLetter(
            SmtpSettings smtpSettings,
            LetterInfo letterInfo,
            Letter letter,
            LetterSubscriber subscriber)
        {
            // TODO: use multi part email with both html and plain text body
            // instead of this either or approach?

            LetterSendLog mailLog = new LetterSendLog();
            mailLog.EmailAddress = subscriber.EmailAddress;
            mailLog.LetterGuid = letter.LetterGuid;
            mailLog.UserGuid = subscriber.UserGuid;
            mailLog.SubscribeGuid = subscriber.SubscribeGuid;

            if (testMode)
            {
                Thread.Sleep(testSleepMilliseconds); // sleep 1 seconds per message to simulate

            }
            else
            {
                try
                {
                    if (subscriber.UseHtml)
                    {
                        Email.Send(
                            smtpSettings,
                            letterInfo.FromAddress.Coalesce(notificationFromEmail),
                            letterInfo.FromName.Coalesce(notificationFromAlias),
                            letterInfo.ReplyToAddress.Coalesce(notificationFromAlias),
                            subscriber.EmailAddress,
                            string.Empty,
                            string.Empty,
                            letter.Subject,
                            ReplaceHtmlTokens(letter.HtmlBody, subscriber, letterInfo),
                            subscriber.UseHtml,
                            "Normal");
                    }
                    else
                    {
                        Email.Send(
                            smtpSettings,
                            letterInfo.FromAddress.Coalesce(notificationFromEmail),
                            letterInfo.FromName.Coalesce(notificationFromAlias),
                            letterInfo.ReplyToAddress.Coalesce(notificationFromEmail),
                            subscriber.EmailAddress,
                            string.Empty,
                            string.Empty,
                            letter.Subject,
                            ReplaceTextTokens(letter.TextBody, subscriber, letterInfo),
                            subscriber.UseHtml,
                            "Normal");

                    }
                }
                catch (Exception ex)
                {
                    // TODO: catch more specific exception(s) figure out what ones can be thrown here
                    mailLog.ErrorOccurred = true;
                    mailLog.ErrorMessage = ex.ToString();
                    log.Error(ex);

                }
            }

            mailLog.Save();
        }
Пример #27
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByReplyToAddress(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.ReplyToAddress.CompareTo(letterInfo2.ReplyToAddress));
 }
Пример #28
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByReplyToAddress(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.ReplyToAddress.CompareTo(letterInfo2.ReplyToAddress);
 }
Пример #29
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareBySendMode(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.SendMode.CompareTo(letterInfo2.SendMode));
 }
Пример #30
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByLastModUtc(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.LastModUtc.CompareTo(letterInfo2.LastModUtc);
 }
Пример #31
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByRolesThatCanEdit(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.RolesThatCanEdit.CompareTo(letterInfo2.RolesThatCanEdit));
 }
Пример #32
0
        private void Save()
        {
            LetterInfo letterInfo = new LetterInfo(letterInfoGuid);

            letterInfo.SiteGuid = siteSettings.SiteGuid;
            letterInfo.Title = txtTitle.Text;
            letterInfo.Description = edDescription.Text;

            letterInfo.Enabled = chkEnabled.Checked;
            letterInfo.AllowUserFeedback = chkAllowUserFeedback.Checked;
            letterInfo.AllowAnonFeedback = chkAllowAnonFeedback.Checked;
            letterInfo.FromAddress = txtFromAddress.Text;
            letterInfo.FromName = txtFromName.Text;
            letterInfo.ReplyToAddress = txtReplyToAddress.Text;

            letterInfo.EnableViewAsWebPage = chkEnableViewAsWebPage.Checked;
            letterInfo.EnableSendLog = chkEnableSendLog.Checked;

            letterInfo.AllowArchiveView = chkAllowArchiveView.Checked;
            letterInfo.ProfileOptIn = chkProfileOptIn.Checked;
            int sort = letterInfo.SortRank;
            int.TryParse(txtSortRank.Text, out sort);
            letterInfo.SortRank = sort;

            letterInfo.DisplayNameDefault = txtDisplayNameDefault.Text;
            letterInfo.FirstNameDefault = txtFirstNameDefault.Text;
            letterInfo.LastNameDefault = txtLastNameDefault.Text;

            if (letterInfoGuid == Guid.Empty)
            {
                letterInfo.CreatedBy = currentUser.UserGuid;
                letterInfo.CreatedUtc = DateTime.UtcNow;
            }
            letterInfo.LastModUtc = DateTime.UtcNow;
            letterInfo.LastModBy = currentUser.UserGuid;

            string availableRoles = string.Empty;
            string editRoles = string.Empty;
            string approveRoles = string.Empty;
            string sendRoles = string.Empty;

            foreach (ListItem item in chkListAvailableToRoles.Items)
            {
                if (item.Selected)
                {
                    availableRoles = availableRoles + item.Value + ";";
                }
            }

            letterInfo.AvailableToRoles = availableRoles;

            foreach (ListItem item in chkListEditRoles.Items)
            {
                if (item.Selected)
                {
                    editRoles = editRoles + item.Value + ";";
                }
            }

            letterInfo.RolesThatCanEdit = editRoles;

            foreach (ListItem item in chkListApproveRoles.Items)
            {
                if (item.Selected)
                {
                    approveRoles = approveRoles + item.Value + ";";
                }
            }

            letterInfo.RolesThatCanApprove = approveRoles;

            foreach (ListItem item in chkListSendMailRoles.Items)
            {
                if (item.Selected)
                {
                    sendRoles = sendRoles + item.Value + ";";
                }
            }

            letterInfo.RolesThatCanSend = sendRoles;

            // TODO:
            //letterInfo.SendMode = txtSendMode.Text;

            letterInfo.Save();

            letterInfoGuid = letterInfo.LetterInfoGuid;
        }
Пример #33
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByRolesThatCanApprove(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.RolesThatCanApprove.CompareTo(letterInfo2.RolesThatCanApprove));
 }
Пример #34
0
        public static void SendSubscriberVerificationEmail(
            string siteRoot,
            string emailAddress,
            Guid subscribeGuid,
            LetterInfo letter,
            SiteSettings siteSettings)
        {
            string verificationTemplate;
            bool useHtml = WebConfigSettings.NewsletterUseHtmlEmailConfirmation;
            if (useHtml)
            {
                verificationTemplate = ResourceHelper.GetMessageTemplate(SiteUtils.GetDefaultUICulture(), "NewsletterVerificationHtmlEmailMessage.config");
            }
            else
            {
                verificationTemplate = ResourceHelper.GetMessageTemplate(SiteUtils.GetDefaultUICulture(), "NewsletterVerificationEmailMessage.config");
            }

            string confirmLink = siteRoot + "/eletter/Confirm.aspx?s=" + subscribeGuid.ToString();
            string messageBody = verificationTemplate.Replace("{NewsletterName}", letter.Title).Replace("{ConfirmationLink}", confirmLink).Replace("{SiteLink}", siteRoot);
            string subject = string.Format(CultureInfo.InvariantCulture, Resource.NewsletterVerifySubjectFormat, letter.Title);

            string fromAddress;
            string fromAlias;
            if (letter.FromAddress.Length > 0)
            {

                fromAddress = letter.FromAddress;
                fromAlias = letter.FromName;
            }
            else
            {

                fromAddress = siteSettings.DefaultEmailFromAddress;
                fromAlias = siteSettings.DefaultFromEmailAlias;
            }

            Email.Send(
                    SiteUtils.GetSmtpSettings(),
                    fromAddress,
                    fromAlias,
                    string.Empty,
                    emailAddress,
                    string.Empty,
                    string.Empty,
                    subject,
                    messageBody,
                    useHtml,
                    Email.PriorityNormal);
        }
Пример #35
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByRolesThatCanSend(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.RolesThatCanSend.CompareTo(letterInfo2.RolesThatCanSend));
 }
Пример #36
0
        private void RunTask()
        {
            Letter letter = new Letter(this.letterGuid);
            if (letter.LetterGuid == Guid.Empty) return;
            if (letter.SendCompleteUtc > DateTime.MinValue) return;
            if (letter.SendClickedUtc == DateTime.MinValue) return;

            LetterInfo letterInfo = new LetterInfo(letter.LetterInfoGuid);

            // TODO: this could be a very large recordset if the kist is very large
            // might be better to get a page at a time instead of all at once.

            List<LetterSubscriber> subscribers
                = LetterSubscriber.GetSubscribersNotSentYet(
                letter.LetterGuid,
                letter.LetterInfoGuid);

            nextStatusUpdateTime = DateTime.UtcNow.AddSeconds(updateFrequency);
            totalSubscribersToSend = subscribers.Count;

            if ((totalSubscribersToSend > 0) && (letter.SendStartedUtc == DateTime.MinValue))
            {
                letter.TrackSendStarted();
            }

            SmtpSettings smtpSettings = new SmtpSettings();
            smtpSettings.Password = password;
            smtpSettings.Port = port;
            smtpSettings.PreferredEncoding = preferredEncoding;
            smtpSettings.RequiresAuthentication = requiresAuthentication;
            smtpSettings.UseSsl = useSsl;
            smtpSettings.User = user;
            smtpSettings.Server = server;

            foreach (LetterSubscriber subscriber in subscribers)
            {
                SendLetter(smtpSettings, letterInfo, letter, subscriber);
                subscribersSentSoFar += 1;

                if (DateTime.UtcNow > nextStatusUpdateTime)
                    ReportStatus();

            }

            ReportStatus();
        }
Пример #37
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByRolesThatCanApprove(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.RolesThatCanApprove.CompareTo(letterInfo2.RolesThatCanApprove);
 }
Пример #38
0
        private void DoSubscribe(LetterInfo letter, string email)
        {
            if (email == "*****@*****.**") { return; } //I've been seeing a lot of this from a bot

            LetterSubscriber s = subscriptions.Fetch(siteSettings.SiteGuid, letter.LetterInfoGuid, email);

            bool needToSendVerification = false;

            if (s == null)
            {
                s = new LetterSubscriber();
                s.SiteGuid = siteSettings.SiteGuid;
                s.EmailAddress = email;
                s.LetterInfoGuid = letter.LetterInfoGuid;
                if (showFormatOptions)
                {
                    s.UseHtml = rbHtmlFormat.Checked;
                }
                else
                {
                    s.UseHtml = htmlIsDefault;
                }

                if ((currentUser != null) && (string.Equals(currentUser.Email, email, StringComparison.InvariantCultureIgnoreCase)))
                {
                    s.UserGuid = currentUser.UserGuid;
                    s.IsVerified = true;
                }
                else
                {
                    // user is not authenticated but may still exist
                    // attach userguid but don't flag as verified
                    // because we don't know that the user who submited the form is the account owner
                    SiteUser siteUser = SiteUser.GetByEmail(siteSettings, email);
                    if (siteUser != null) { s.UserGuid = siteUser.UserGuid; }

                }
                s.IpAddress = SiteUtils.GetIP4Address();
                subscriptions.Save(s);

                LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);

                if (WebConfigSettings.LogNewsletterSubscriptions)
                {
                    log.Info(s.EmailAddress + " just subscribed to newsletter " + letter.Title);
                }

                if(!s.IsVerified)
                {
                    needToSendVerification = true;
                }

            }
            else
            {
                // we found an existing subscription

                if (!s.IsVerified)
                {
                    // if the current authenticated user has the same email mark it as verified
                    if ((currentUser != null) && (string.Equals(currentUser.Email, email, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        s.UserGuid = currentUser.UserGuid;
                        if (showFormatOptions)
                        {
                            s.UseHtml = rbHtmlFormat.Checked;
                        }
                        subscriptions.Save(s);
                        subscriptions.Verify(s.SubscribeGuid, true, Guid.Empty);
                    }
                    else if (s.BeginUtc < DateTime.UtcNow.AddDays(-WebConfigSettings.NewsletterReVerifcationAfterDays))
                    {
                        // if the user never verifed before and its been at least x days go ahead and send another chance to verify
                        needToSendVerification = true;
                        // TODO: maybe we should log this in case some spam script is using the same email over and over
                        // or maybe we should add a verification sent count on subscription
                    }
                }
            }

            //added 2012-05-16 to support intranet scenarios where verification is not required
            if (!WebConfigSettings.NewsletterRequireVerification)
            {
                if (!s.IsVerified)
                {
                    s.IsVerified = true;
                    subscriptions.Save(s);
                }
                needToSendVerification = false;
            }

            if (needToSendVerification)
            {
                NewsletterHelper.SendSubscriberVerificationEmail(
                    siteRoot,
                    email,
                    s.SubscribeGuid,
                    letter,
                    siteSettings);

            }
        }
Пример #39
0
        private void LoadSettings()
        {
            letterInfoGuid = WebUtils.ParseGuidFromQueryString("l", letterInfoGuid);
            pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            timeOffset = SiteUtils.GetUserTimeOffset();
            timeZone = SiteUtils.GetUserTimeZone();
            pageSize = WebConfigSettings.NewsletterArchivePageSize;
            ScriptConfig.IncludeColorBox = true;

            letterInfo = new LetterInfo(letterInfoGuid);
            if ((letterInfo.LetterInfoGuid == Guid.Empty) || (letterInfo.SiteGuid != siteSettings.SiteGuid)) { letterInfo = null; }

            if (letterInfo != null)
            {
                canView = WebUser.IsInRoles(letterInfo.AvailableToRoles);
            }

            lnkNewsletters.NavigateUrl = SiteRoot + "/eletter/";

            AddClassToBody("administration");
            AddClassToBody("eletterarchive");
        }
Пример #40
0
        void grdSubscribers_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            string strG = e.CommandArgument.ToString();
            switch (e.CommandName)
            {
                case "DeleteSubscriber":

                    if (strG.Length == 36)
                    {
                        Guid subscriptionGuid = new Guid(strG);
                        LetterSubscriber s = subscriptions.Fetch(subscriptionGuid);
                        if (s != null) { subscriptions.Delete(s); }

                        LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);

                        WebUtils.SetupRedirect(this, Request.RawUrl);
                    }

                    break;

                case "SendVerification":

                    if (strG.Length == 36)
                    {
                        Guid subscriptionGuid = new Guid(strG);
                        LetterSubscriber s = subscriptions.Fetch(subscriptionGuid);
                        LetterInfo letterInfo = new LetterInfo(letterInfoGuid);

                        NewsletterHelper.SendSubscriberVerificationEmail(
                            SiteRoot,
                            s.EmailAddress,
                            s.SubscribeGuid,
                            letterInfo,
                            siteSettings);
                    }

                    WebUtils.SetupRedirect(this, Request.RawUrl);

                    break;
            }
        }
Пример #41
0
        private string ReplaceTextTokens(string textBody, LetterSubscriber subscriber, LetterInfo letterInfo)
        {
            StringBuilder mergedMessage = new StringBuilder();
            mergedMessage.Append(textBody);
            // mail merge
            if (unsubscribeUrl.Length > 0)
            {
                if (subscriber.UserGuid != Guid.Empty)
                {
                    mergedMessage.Replace(
                        Letter.UnsubscribeToken,
                        unsubscribeUrl
                        + "?u=" + subscriber.UserGuid.ToString()
                        + "&l=" + subscriber.LetterInfoGuid.ToString());
                }
                else
                {
                    mergedMessage.Replace(
                        Letter.UnsubscribeToken,
                        unsubscribeUrl
                        + "?s=" + subscriber.SubscribeGuid.ToString()
                        + "&l=" + subscriber.LetterInfoGuid.ToString());

                }

            }

            if (webPageUrl.Length > 0)
            {
                mergedMessage.Replace(Letter.WebPageLinkToken, webPageUrl);

            }
            else
            {
                mergedMessage.Replace(Letter.WebPageLinkToken, string.Empty);
            }

            mergedMessage.Replace(Letter.UserNameToken, subscriber.Name.Coalesce(subscriber.EmailAddress));
            mergedMessage.Replace(Letter.UserEmailToken, subscriber.EmailAddress);

            if (subscriber.UserGuid != Guid.Empty)
            {
                // site member

                if ((subscriber.FirstName.Length > 0) && (subscriber.LastName.Length > 0))
                {
                    // if both first and last have values replace the tokens
                    mergedMessage.Replace(Letter.UserFirstNameToken, subscriber.FirstName);
                    mergedMessage.Replace(Letter.UserLastNameToken, subscriber.LastName);

                }
                else if (subscriber.FirstName.Length > 0)
                {
                    // if only first name has a value then replace last name with empty string and first name with first name
                    mergedMessage.Replace(Letter.UserFirstNameToken, subscriber.FirstName);
                    mergedMessage.Replace(Letter.UserLastNameToken, string.Empty);
                }
                else
                {
                    // if neither first name nor last name has a value replace last with empty string and first with display name
                    mergedMessage.Replace(Letter.UserFirstNameToken, subscriber.Name);
                    mergedMessage.Replace(Letter.UserLastNameToken, string.Empty);

                }

            }
            else
            {
                //non site member

                // currently non site members do not have first or last name data fields
                // but in case we add those this logic will already be here

                if ((subscriber.FirstName.Length > 0) && (subscriber.LastName.Length > 0))
                {
                    // if both first and last have values replace the tokens
                    mergedMessage.Replace(Letter.UserFirstNameToken, subscriber.FirstName);
                    mergedMessage.Replace(Letter.UserLastNameToken, subscriber.LastName);

                }
                else if (subscriber.FirstName.Length > 0)
                {
                    // if only first name has a value then replace last name with empty string and first name with first name
                    mergedMessage.Replace(Letter.UserFirstNameToken, subscriber.FirstName);
                    mergedMessage.Replace(Letter.UserLastNameToken, string.Empty);
                }
                else
                {
                    // this is the expected path for non site members since we don't have data fields for first and last

                    // replace with token defaults from letterInfo (ie Valued Customer could be the first and last token defaults)
                    mergedMessage.Replace(Letter.UserFirstNameToken, letterInfo.FirstNameDefault);
                    mergedMessage.Replace(Letter.UserLastNameToken, letterInfo.LastNameDefault);

                }

            }

            mergedMessage.Replace(Letter.UserDisplayNameToken, subscriber.Name.Coalesce(letterInfo.DisplayNameDefault));

            return mergedMessage.ToString();
        }
Пример #42
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByCreatedUtc(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.CreatedUtc.CompareTo(letterInfo2.CreatedUtc));
 }
Пример #43
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByRolesThatCanEdit(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return letterInfo1.RolesThatCanEdit.CompareTo(letterInfo2.RolesThatCanEdit);
 }
Пример #44
0
        private void DoSubscribe(LetterInfo letter, SiteUser siteUser)
        {
            LetterSubscriber s = new LetterSubscriber();
            s.SiteGuid = siteSettings.SiteGuid;
            s.EmailAddress = siteUser.Email;
            s.UserGuid = siteUser.UserGuid;
            s.LetterInfoGuid = letter.LetterInfoGuid;
            s.UseHtml = rbHtmlFormat.Checked;
            s.IsVerified = (!siteSettings.UseSecureRegistration);
            s.IpAddress = SiteUtils.GetIP4Address();
            subscriptions.Save(s);

            LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);
        }
Пример #45
0
 /// <summary>
 /// Compares 2 instances of LetterInfo.
 /// </summary>
 public static int CompareByLastModUtc(LetterInfo letterInfo1, LetterInfo letterInfo2)
 {
     return(letterInfo1.LastModUtc.CompareTo(letterInfo2.LastModUtc));
 }