void btnSendPreview_Click(object sender, EventArgs e)
        {
            Page.Validate("preview");
            if (!Page.IsValid)
            {
                return;
            }

            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.ChangeRelativeUrlsToFullyQuailifiedUrls(baseUrl, ImageSiteRoot, edContent.Text);

            //log.Info(content);

            Email.SendEmail(
                SiteUtils.GetSmtpSettings(),
                siteSettings.DefaultEmailFromAddress,
                txtPreviewAddress.Text,
                string.Empty,
                string.Empty,
                txtTitle.Text,
                content,
                true,
                "Normal");
        }
Exemple #2
0
        private void SaveLetter()
        {
            if (letter == null)
            {
                return;
            }
            if (currentUser == null)
            {
                return;
            }
            // no edits after sending
            if (letter.SendCompleteUtc > DateTime.MinValue)
            {
                return;
            }

            letter.HtmlBody  = SiteUtils.ChangeRelativeUrlsToFullyQuailifiedUrls(SiteRoot, imageSiteRoot, edContent.Text);
            letter.TextBody  = txtPlainText.Text;
            letter.Subject   = txtSubject.Text;
            letter.LastModBy = currentUser.UserGuid;
            if (letter.LetterGuid == Guid.Empty)
            {
                // new letter
                letter.LetterInfoGuid = letterInfoGuid;
                letter.CreatedBy      = currentUser.UserGuid;
            }

            letter.Save();
            letterGuid = letter.LetterGuid;
        }
Exemple #3
0
        private void RenderRss(RssGroup rssGroup)
        {
            Response.ContentType     = "application/xml";
            Response.ContentEncoding = System.Text.Encoding.UTF8;

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(rssGroup.ModuleId);

            rssGroup.MaximumDays = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedMaxDaysOldSetting", 90);

            int entriesLimit = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedMaxPostsSetting", 90);

            int entryCount = 0;

            Rss.RssChannel channel = new Rss.RssChannel();
            string         baseUrl = Request.Url.ToString().Replace("RSS.aspx", "Topic.aspx");

            using (IDataReader posts = rssGroup.GetPostsForRss())
            {
                while ((posts.Read()) && (entryCount <= entriesLimit))
                {
                    Rss.RssItem item = new Rss.RssItem();

                    item.Title       = posts["Subject"].ToString();
                    item.Description = SiteUtils.ChangeRelativeUrlsToFullyQuailifiedUrls(navigationSiteRoot, imageSiteRoot, posts["Post"].ToString());
                    item.PubDate     = Convert.ToDateTime(posts["PostDate"]);

                    string target = baseUrl;

                    if (target.IndexOf("&topic=") < 0 && target.IndexOf("?topic=") < 0)
                    {
                        if (target.IndexOf("?") < 0)
                        {
                            target += "?topic=" + posts["TopicID"].ToString() + "#post" + posts["PostID"].ToString();
                        }
                        else
                        {
                            target += "&topic=" + posts["TopicID"].ToString() + "#post" + posts["PostID"].ToString();
                        }
                    }
                    item.Link = new System.Uri(target);

                    item.Author = posts["StartedBy"].ToString();

                    channel.Items.Add(item);
                    entryCount += 1;
                }
            }

            object value = GetModule();
            Module m;

            channel.LastBuildDate = channel.Items.LatestPubDate();
            channel.Link          = new System.Uri(groupUrl);

            if (value != null)
            {
                m = (Module)value;

                channel.Title       = m.ModuleTitle;
                channel.Description = m.ModuleTitle;
            }
            else
            {
                channel.Title       = siteSettings.SiteName;
                channel.Description = siteSettings.SiteName;
            }

            if (channel.Items.Count == 0)
            {
                Rss.RssItem item = new Rss.RssItem();

                item.Title       = "No Items Found";
                item.Description = "No items found";
                item.PubDate     = DateTime.UtcNow;

                item.Link = new System.Uri(navigationSiteRoot);

                item.Author = "system";

                channel.Items.Add(item);
            }


            Rss.RssFeed rss = new Rss.RssFeed();
            rss.BaseUrl = cssBaseUrl;

            rss.Encoding = System.Text.Encoding.UTF8;
            rss.Channels.Add(channel);
            rss.Write(Response.OutputStream);
            //Response.End();
        }
Exemple #4
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.ChangeRelativeUrlsToFullyQuailifiedUrls(baseUrl, ImageSiteRoot, 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.UnsubscribeUrl        = SiteRoot + "/eletter/Unsubscribe.aspx";
            letterSender.NotificationFromEmail = siteSettings.DefaultEmailFromAddress;
            letterSender.NotifyOnCompletion    = true;
            letterSender.NotificationToEmail   = currentUser.Email;

            SmtpSettings smtpSettings = SiteUtils.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;

            //localizing the task name can cause deserialization errors
            //letterSender.TaskName = string.Format(CultureInfo.InvariantCulture,
            //        Resource.NewsletterTaskNameFormatString, letterInfo.Title);

            //letterSender.NotificationSubject = string.Format(CultureInfo.InvariantCulture,
            //    Resource.TaskQueueCompletedTaskNotificationFormatString, letterSender.TaskName);

            //letterSender.StatusCompleteMessage = Resource.NewsletterStatusCompleteMessage;
            //letterSender.StatusQueuedMessage = Resource.NewsletterStatusQueuedMessage;
            //letterSender.StatusStartedMessage = Resource.NewsletterStatusStartedMessage;
            //letterSender.StatusRunningMessage = Resource.NewsletterStatusRunningMessageFormatString;
            //letterSender.TaskCompleteMessage = string.Format(CultureInfo.InvariantCulture,
            //    Resource.TaskQueueCompletedTaskNotificationFormatString, letterSender.TaskName);

            letterSender.QueueTask();

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

            WebTaskManager.StartOrResumeTasks();

            WebUtils.SetupRedirect(this, redirectUrl);
        }
Exemple #5
0
        private void RenderItems(XmlTextWriter xmlTextWriter)
        {
            string blogCommentLabel = ConfigurationManager.AppSettings["BlogCommentCountLabel"];

            using (IDataReader dr = Blog.GetBlogs(moduleId, DateTime.UtcNow, _categoryId))
            {
                //write channel items
                while (dr.Read())
                {
                    string inFeed = dr["IncludeInFeed"].ToString();
                    if (inFeed == "True" || inFeed == "1")
                    {
                        //beginning of blog entry
                        xmlTextWriter.WriteStartElement("item");

                        string blogItemUrl = FormatBlogUrl(dr["ItemUrl"].ToString(), Convert.ToInt32(dr["ItemID"]));

                        /*
                         * RSS 2.0
                         * All elements of an item are optional, however at least one of title or description
                         * must be present.
                         */

                        xmlTextWriter.WriteStartElement("title");
                        xmlTextWriter.WriteString(dr["Heading"].ToString());
                        xmlTextWriter.WriteEndElement();

                        xmlTextWriter.WriteStartElement("link");
                        xmlTextWriter.WriteString(blogItemUrl);
                        xmlTextWriter.WriteEndElement();

                        xmlTextWriter.WriteStartElement("pubDate");
                        xmlTextWriter.WriteString(Convert.ToDateTime(dr["StartDate"]).ToString("r"));
                        xmlTextWriter.WriteEndElement();

                        xmlTextWriter.WriteStartElement("guid");
                        xmlTextWriter.WriteString(blogItemUrl);
                        xmlTextWriter.WriteEndElement();

                        if (ShowPostAuthorSetting)
                        {
                            xmlTextWriter.WriteStartElement("author");
                            // techically this is supposed to be an email address
                            // but wouldn't that lead to a lot of spam?
                            xmlTextWriter.WriteString(dr["Name"].ToString());
                            xmlTextWriter.WriteEndElement();
                        }

                        xmlTextWriter.WriteStartElement("comments");
                        xmlTextWriter.WriteString(blogItemUrl);
                        xmlTextWriter.WriteEndElement();

                        string signature = string.Empty;

                        if (addSignature)
                        {
                            signature = String.Format("<br /><a href='{0}'>{1}</a>", imageSiteRoot, dr["Name"]);
                        }

                        if (addCommentsLink)
                        {
                            signature += String.Format("&nbsp;&nbsp;<a href='{0}'>{1}...</a>", blogItemUrl, blogCommentLabel);
                        }


                        string blogPost = SiteUtils.ChangeRelativeUrlsToFullyQuailifiedUrls(navigationSiteRoot, imageSiteRoot, dr["Description"].ToString());

                        if ((!useExcerptInFeed) || (blogPost.Length <= excerptLength))
                        {
                            xmlTextWriter.WriteStartElement("description");
                            xmlTextWriter.WriteCData(blogPost + signature);
                            xmlTextWriter.WriteEndElement();
                        }
                        else
                        {
                            string excerpt = SiteUtils.ChangeRelativeUrlsToFullyQuailifiedUrls(navigationSiteRoot, imageSiteRoot, dr["Abstract"].ToString());

                            if ((excerpt.Length > 0) && (excerpt != "<p>&#160;</p>"))
                            {
                                excerpt = String.Format("{0}{1} <a href='{2}'>{3}</a><div>&nbsp;</div>", excerpt, ExcerptSuffix, blogItemUrl, MoreLinkText);
                            }
                            else
                            {
                                excerpt = String.Format("{0} <a href='{1}'>{2}</a><div>&nbsp;</div>", UIHelper.CreateExcerpt(dr["Description"].ToString(), excerptLength, ExcerptSuffix), blogItemUrl, MoreLinkText);;
                            }

                            xmlTextWriter.WriteStartElement("description");
                            xmlTextWriter.WriteCData(excerpt);
                            xmlTextWriter.WriteEndElement();
                        }


                        //end blog entry
                        xmlTextWriter.WriteEndElement();
                    }
                }
            }
        }