Click here to Skip to main content
15,885,546 members
Articles / Web Development / ASP.NET

Open Source Extensible Enterprise n-tier Application Framework with Multilayered Architecture

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
3 Dec 2010MIT3 min read 36.9K   770   41  
Xenta architecture overview
using SiberTek.Xenta.Entities;
using SiberTek.Xenta.Enums;
using SiberTek.Xenta.Managers;
using SiberTek.Xenta.Utils;

namespace SiberTek.Xenta.Extensions
{
    /// <summary>
    /// Contains message manager extension methods
    /// </summary>
    public static class ForumMessageManagerExtesion
    {
        #region Methods
        public static bool SendForumPostNotification(this MessageManager mgr, int postID)
        {
            ForumPostInfo post = ForumPostManager.Instance.GetForumPost(postID);

            if(post == null)
            {
                return false;
            }

            ForumTopicInfo topic = post.Topic;

            if(topic == null)
            {
                return false;
            }

            ForumInfo forum = topic.Forum;

            if(forum == null)
            {
                return false;
            }

            int msgCount = 0;

            foreach(ForumSubscriptionInfo subscription in topic.Subscriptions)
            {
                UserInfo user = subscription.User;
                MessageTemplateInfo template = mgr.GetMessageTemplateByName(user.LanguageID, "forum-post-notification");

                if(template == null)
                {
                    continue;
                }

                string subject = template.Subject;
                string text = template.Text;

                subject = subject.Replace("[Token:Forum.Title]", forum.Title);
                subject = subject.Replace("[Token:ForumTopic.Title]", topic.Title);
                subject = subject.Replace("[Token:ForumPost.Title]", post.Title);
                subject = subject.Replace("[Token:ForumPost.Author]", post.Author.Username);
                text = text.Replace("[Token:Forum.ID]", forum.ForumID.ToString());
                text = text.Replace("[Token:Forum.Title]", forum.Title);
                text = text.Replace("[Token:Forum.Description]", StringHelper.ConvertBBCodeToHtml(forum.Description));
                text = text.Replace("[Token:ForumTopic.ID]", topic.TopicID.ToString());
                text = text.Replace("[Token:ForumTopic.Title]", topic.Title);
                text = text.Replace("[Token:ForumTopic.Description]", StringHelper.ConvertBBCodeToHtml(topic.Description));
                text = text.Replace("[Token:ForumPost.ID]", post.PostID.ToString());
                text = text.Replace("[Token:ForumPost.Title]", post.Title);
                text = text.Replace("[Token:ForumPost.Text]", StringHelper.ConvertBBCodeToHtml(post.Text));
                text = text.Replace("[Token:ForumPost.Author]", post.Author.Username);

                MessageInfo message = mgr.CreateMessage(MessageType.Email, template.From, user.Email, template.BccTo, subject, text);

                msgCount++;
            }

            return msgCount > 0;
        }


        public static bool SendForumTopicNotification(this MessageManager mgr, int topicID)
        {
            ForumTopicInfo topic = ForumTopicManager.Instance.GetForumTopic(topicID);

            if(topic == null)
            {
                return false;
            }

            ForumInfo forum = topic.Forum;

            if(topic == null)
            {
                return false;
            }

            int msgCount = 0;

            foreach(ForumSubscriptionInfo subscription in forum.Subscriptions)
            {
                UserInfo user = subscription.User;
                MessageTemplateInfo template = mgr.GetMessageTemplateByName(user.LanguageID, "forum-topic-notification");

                if(template == null)
                {
                    continue;
                }

                string subject = template.Subject;
                string text = template.Text;

                subject = subject.Replace("[Token:Forum.Title]", forum.Title);
                subject = subject.Replace("[Token:ForumTopic.Title]", topic.Title);
                subject = subject.Replace("[Token:ForumTopic.Author]", topic.Author.Username);
                text = text.Replace("[Token:Forum.ID]", forum.ForumID.ToString());
                text = text.Replace("[Token:Forum.Title]", forum.Title);
                text = text.Replace("[Token:Forum.Description]", StringHelper.ConvertBBCodeToHtml(forum.Description));
                text = text.Replace("[Token:ForumTopic.ID]", topic.TopicID.ToString());
                text = text.Replace("[Token:ForumTopic.Title]", topic.Title);
                text = text.Replace("[Token:ForumTopic.Author]", topic.Author.Username);
                text = text.Replace("[Token:ForumTopic.Description]", StringHelper.ConvertBBCodeToHtml(topic.Description));

                MessageInfo message = mgr.CreateMessage(MessageType.Email, template.From, user.Email, template.BccTo, template.Subject, text);

                msgCount++;
            }

            return msgCount > 0;
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions