Ejemplo n.º 1
0
        private static void RunTaskOnNewThread(object oTask)
        {
            if (oTask == null)
            {
                return;
            }
            LetterSendTask task = (LetterSendTask)oTask;

            log.Info("deserialized LetterSendTask task");

            // give a little time to make sure the taskqueue was updated after spawning the thread
            Thread.Sleep(10000); // 10 seconds

            task.RunTask();

            log.Info("started LetterSendTask task");
        }
Ejemplo n.º 2
0
        void btnSendToList_Click(object sender, EventArgs e)
        {
            SaveLetter();

            if (!LetterIsValidForSending()) return;

            if (letter.SendCompleteUtc > DateTime.MinValue) return;

            // TODO: implement approval process
            letter.ApprovedBy = currentUser.UserGuid;
            letter.IsApproved = true;

            string baseUrl = WebUtils.GetHostRoot();
            if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites)
            {
                // in folder based sites the relative urls in the editor will already have the folder name
                // so we want to use just the raw site root not the navigation root
                baseUrl = WebUtils.GetSiteRoot();
            }

            string content = SiteUtils.ChangeRelativeUrlsToFullyQualifiedUrls(baseUrl, WebUtils.GetSiteRoot(), letter.HtmlBody);
            letter.HtmlBody = content;

            SaveLetter();

            letter.TrackSendClicked();

            LetterSendTask letterSender = new LetterSendTask();
            letterSender.SiteGuid = siteSettings.SiteGuid;
            letterSender.QueuedBy = currentUser.UserGuid;
            letterSender.LetterGuid = letter.LetterGuid;
            letterSender.UnsubscribeLinkText = Resource.NewsletterUnsubscribeLink;
            letterSender.ViewAsWebPageText = Resource.NewsletterViewAsWebPageLink;
            letterSender.UnsubscribeUrl = SiteRoot + "/eletter/Unsubscribe.aspx";
            if (letterInfo.AllowArchiveView)
            {
                letterSender.WebPageUrl = SiteRoot + "/eletter/LetterView.aspx?l=" + letter.LetterInfoGuid.ToString() + "&letter=" + letter.LetterGuid.ToString();
            }
            letterSender.NotificationFromEmail = siteSettings.DefaultEmailFromAddress;
            letterSender.NotifyOnCompletion = true;
            letterSender.NotificationToEmail = currentUser.Email;

            SmtpSettings smtpSettings = GetSmtpSettings();
            letterSender.User = smtpSettings.User;
            letterSender.Password = smtpSettings.Password;
            letterSender.Server = smtpSettings.Server;
            letterSender.Port = smtpSettings.Port;
            letterSender.RequiresAuthentication = smtpSettings.RequiresAuthentication;
            letterSender.UseSsl = smtpSettings.UseSsl;
            letterSender.PreferredEncoding = smtpSettings.PreferredEncoding;
            letterSender.TaskUpdateFrequency = 65;
            letterSender.MaxToSendPerMinute = WebConfigSettings.NewsletterMaxToSendPerMinute;

            letterSender.QueueTask();

            string redirectUrl = SiteRoot + "/eletter/SendProgress.aspx?l=" + letterInfoGuid.ToString()
                + "&letter=" + letterGuid.ToString()
                + "&t=" + letterSender.TaskGuid.ToString();

            WebTaskManager.StartOrResumeTasks();

            WebUtils.SetupRedirect(this, redirectUrl);
        }