Пример #1
0
        /// <summary>
        /// 获得热门主题列表
        /// </summary>
        /// <returns></returns>
        //[Task("ListForwardItem", "获取列表")]
        public IList <ThreadsDspModel> GetHotThreadList()
        {
            IList <ThreadsDspModel> list           = new List <ThreadsDspModel>();
            IForumThreadRepository  forumThreadRep = Factory.Factory <IForumThreadRepository> .GetConcrete();

            IAccountRepository accountRep = Factory.Factory <IAccountRepository> .GetConcrete();

            //转换为显示模型
            foreach (ForumThread th in forumThreadRep.FindAll(new Specification <ForumThread>(s => s.ForumID != Guid.Empty).Skip(0).Take(5).OrderByDescending(sf => sf.State.MessageCount)))
            {
                ThreadsDspModel tmp = new ThreadsDspModel();
                tmp.ID           = th.Id;
                tmp.ClickCount   = th.State.ClickCount;
                tmp.MessageCount = th.State.MessageCount;
                tmp.Title        = th.RootMessage.MessageVO.Subject;
                tmp.UserID       = th.RootMessage.Account;
                try
                {
                    tmp.UserName = accountRep.GetByKey(th.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    ///账户不存在
                    tmp.UserName = "******";
                }

                tmp.LastModified = th.State.ModifiedDate;
                tmp.CreationDate = th.CreationDate;

                list.Add(tmp);
            }
            return(list);
        }
Пример #2
0
        /// <summary>
        /// 获得最近10天内发表的主题列表
        /// </summary>
        /// <returns></returns>
        //[Task("ListForwardItem", "获取列表")]
        public IList <ThreadsDspModel> GetRecentThreadList(int days)
        {
            IList <ThreadsDspModel> list           = new List <ThreadsDspModel>();
            IForumThreadRepository  forumThreadRep = FBS.Factory.Factory <IForumThreadRepository> .GetConcrete();

            //ISpecification<ForumThread> nameSpec = new Specification<ForumThread>(o => o.CreationDate.CompareTo(DateTime.Now.AddDays(-10)) >= 0);
            DateTime            formal          = DateTime.Now.AddDays(days * (-1));
            IList <ForumThread> forumThreadList = forumThreadRep.GetThread("select * from fbs_ForumThread inner join fbs_Message on fbs_ForumThread.RootMessageID=fbs_Message.MessageID where fbs_ForumThread.CreationDate > '" + formal + "' order by fbs_ForumThread.CreationDate DESC");
            IAccountRepository  accRep          = FBS.Factory.Factory <IAccountRepository> .GetConcrete();

            foreach (ForumThread ft in forumThreadList)
            {
                ThreadsDspModel temp = new ThreadsDspModel();
                temp.ID           = ft.Id;
                temp.ClickCount   = ft.State.ClickCount;
                temp.MessageCount = ft.State.MessageCount;
                temp.Title        = ft.RootMessage.MessageVO.Subject;
                temp.UserID       = ft.RootMessage.Account;
                temp.ForumID      = ft.ForumID;
                try
                {
                    temp.UserName = accRep.GetByKey(ft.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    temp.UserName = "******";
                }
                temp.LastModified = ft.State.ModifiedDate;
                temp.CreationDate = ft.CreationDate;

                list.Add(temp);
            }
            return(list);
        }
Пример #3
0
        /// <summary>
        /// 获得最近10天内发表的主题列表
        /// </summary>
        /// <returns></returns>
        //[Task("ListForwardItem", "获取列表")]
        public IList <ThreadsDspModel> GetRecentThreadList(Guid aid)
        {
            IList <ThreadsDspModel> list           = new List <ThreadsDspModel>();
            IForumThreadRepository  forumThreadRep = FBS.Factory.Factory <IForumThreadRepository> .GetConcrete();

            ISpecification <ForumThread> nameSpec        = new Specification <ForumThread>(o => o.CreationDate.CompareTo(DateTime.Now.AddDays(-10)) >= 0 && o.ForumID == aid);
            IList <ForumThread>          forumThreadList = forumThreadRep.FindAll(nameSpec);
            IAccountRepository           accRep          = FBS.Factory.Factory <IAccountRepository> .GetConcrete();

            foreach (ForumThread ft in forumThreadList)
            {
                ThreadsDspModel temp = new ThreadsDspModel();
                temp.ID           = ft.Id;
                temp.ClickCount   = ft.State.ClickCount;
                temp.MessageCount = ft.State.MessageCount;
                temp.Title        = ft.RootMessage.MessageVO.Subject;
                temp.UserID       = ft.RootMessage.Account;
                try
                {
                    temp.UserName = accRep.GetByKey(ft.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    temp.UserName = "******";
                }
                temp.LastModified = ft.State.ModifiedDate;
                temp.CreationDate = ft.CreationDate;

                list.Add(temp);
            }
            return(list);
        }
Пример #4
0
        /// <summary>
        /// 根据板块ID获得板块中的主题列表(分页)
        /// </summary>
        /// <param name="forumID">板块ID</param>
        /// <returns>主题列表</returns>
        public IList <ThreadsDspModel> GetForumThreadListByForumID(Guid forumID, int startIndex, int count)
        {
            IList <ThreadsDspModel> list = new List <ThreadsDspModel>();
            //创建主题仓储
            IForumThreadRepository forumThreadRep = FBS.Factory.Factory <IForumThreadRepository> .GetConcrete();

            IList <ForumThread> forumThreadList = forumThreadRep.GetThreadsInOneForum(forumID, startIndex, count);
            IAccountRepository  accRep          = FBS.Factory.Factory <IAccountRepository> .GetConcrete();

            //      return forumThreadRep.FindAll();

            foreach (ForumThread ft in forumThreadList)
            {
                ThreadsDspModel temp = new ThreadsDspModel();
                temp.ID           = ft.Id;
                temp.ClickCount   = ft.State.ClickCount;
                temp.MessageCount = ft.State.MessageCount;
                temp.Title        = ft.RootMessage.MessageVO.Subject;
                temp.UserID       = ft.RootMessage.Account;
                try
                {
                    temp.UserName = accRep.GetByKey(ft.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    temp.UserName = "******";
                }
                temp.LastModified = ft.State.ModifiedDate;
                temp.CreationDate = ft.CreationDate;
                temp.ForumID      = ft.ForumID;
                list.Add(temp);
            }
            return(list);
        }
Пример #5
0
        /// <summary>
        /// 通过关键字查找帖子
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="index">分页起始点</param>
        /// <param name="count">取数据条数</param>
        /// <returns>查找的帖子列表集合</returns>
        public IList <ThreadsDspModel> FetchThreadsDspModelByKeyWords(string keywords, int index, int count)
        {
            IList <ThreadsDspModel> mylist   = new List <ThreadsDspModel>();
            DbDataReader            reader   = helper.GetPageList("fbs_Message", "CreationDate", "Subject like '%" + keywords + "%' and ParentMessageID='" + Guid.Empty + "'", index, count);
            IForumsRepository       forumRep = FBS.Factory.Factory <IForumsRepository> .GetConcrete();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    ThreadsDspModel model = new ThreadsDspModel();
                    Forum           forum = forumRep.GetByKey(new Guid(reader["ForumID"].ToString()));
                    model.Body         = reader["Body"].ToString();
                    model.ClickCount   = System.Int16.Parse(reader["RewardPoints"].ToString());
                    model.CreationDate = DateTime.Parse(reader["CreationDate"].ToString());
                    model.ID           = new Guid(reader["ThreadID"].ToString());
                    model.LastModified = DateTime.Parse(reader["ModifiedDate"].ToString());
                    model.MessageCount = 0;
                    //model.MessageID =new Guid( reader["MessageID"].ToString());
                    model.Title     = reader["Subject"].ToString();
                    model.UserID    = new Guid(reader["AccountID"].ToString());
                    model.UserName  = forum.Name; //注意这里借用变量了,注意呀
                    model.MessageID = forum.Id;   //注意这里同样借用变量了,注意
                    mylist.Add(model);
                }
            }
            return(mylist);
        }
Пример #6
0
        /// <summary>
        /// 根据板块ID获得板块中所有的主题列表
        /// </summary>
        /// <param name="forumID"></param>
        /// <returns></returns>
        public IList <ThreadsDspModel> GetAllForumThreadListByForumID(Guid forumID)
        {
            IList <ThreadsDspModel> list = new List <ThreadsDspModel>();
            //创建主题仓储
            //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete();

            IForumThreadRepository forumThreadRep = Factory.Factory <IForumThreadRepository> .GetConcrete();

            IRepository <ForumMessage> msgRep = Factory.Factory <IRepository <ForumMessage> > .GetConcrete <ForumMessage>();

            //IList<ForumThread> forumThreadList = forumThreadRep.GetAllThreadsInOneForum(forumID);
            //IList<ForumThread> forumThreadList = forumThreadRep.FindAll(new Specification<ForumThread>(t => t.ForumID == forumID).OrderByDescending(t => t.CreationDate).Skip(0).Take(100));
            IList <ForumThread>   forumThreadList = forumThreadRep.GetThreadsInOneForum(forumID, 0, 100);
            IRepository <Account> accRep          = FBS.Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            foreach (ForumThread ft in forumThreadList)
            {
                ThreadsDspModel temp = new ThreadsDspModel();
                temp.ID           = ft.Id;
                temp.ClickCount   = ft.State.ClickCount;
                temp.MessageCount = ft.State.MessageCount;
                temp.Title        = ft.RootMessage.MessageVO.Subject;
                temp.UserID       = ft.RootMessage.Account;
                temp.ForumID      = ft.ForumID;
                try
                {
                    temp.UserName = accRep.GetByKey(ft.RootMessage.Account).UserName;
                }
                catch (InvalidOperationException)
                {
                    temp.UserName = "******";
                }
                temp.LastModified = ft.State.ModifiedDate;
                temp.CreationDate = ft.CreationDate;
                list.Add(temp);
            }
            return(list);
        }
Пример #7
0
        /// <summary>
        /// 读取主题所有内容(主贴+回复)
        /// </summary>
        /// <param name="id">主题编号</param>
        public ThreadDetailsModel GetThreadAllContent(Guid id, int pageIndex)
        {
            //IForumThreadRepository threadsRep = Factory.Factory<IForumThreadRepository>.GetConcrete();
            //IAccountRepository accountRep = Factory.Factory<IAccountRepository>.GetConcrete();
            //IForumMessageRepository msgRep = Factory.Factory<IForumMessageRepository>.GetConcrete();
            //IForumsRepository forumsRep = Factory.Factory<IForumsRepository>.GetConcrete();

            //主题读取仓储
            IForumThreadRepository threadRep = Factory.Factory <IForumThreadRepository> .GetConcrete();

            //主题更改仓储
            IRepository <ForumThread> threadWriteRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>();

            IRepository <ForumMessageReply> msgRep = Factory.Factory <IRepository <ForumMessageReply> > .GetConcrete <ForumMessageReply>();

            IRepository <Forum> forumRep = Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>();

            IRepository <Account> accountRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            //IRepository<ForumMessageReply> replyRep = Factory.Factory<IRepository<ForumMessageReply>>.GetConcrete<ForumMessageReply>();

            ForumThread thread = null;

            thread = threadRep.GetByKey(id);
            //thread.RootMessage = msgRep.GetByKey(thread.RootMessage.Id);

            //不存在该主题
            if (thread == null)
            {
                return(null);
            }

            Forum forum = forumRep.GetByKey(thread.ForumID);

            //要返回的对象,包括根帖及回复
            ThreadDetailsModel target = new ThreadDetailsModel();

            target.ClickCount      = thread.State.ClickCount;
            target.Body            = thread.RootMessage.MessageVO.Body;
            target.CreationDate    = thread.CreationDate;
            target.MessageCount    = thread.State.MessageCount;
            target.Title           = thread.RootMessage.MessageVO.Subject;
            target.UserId          = thread.RootMessage.Account;
            target.RootMessageID   = thread.RootMessage.Id;
            target.ForumID         = thread.ForumID;
            target.ForumName       = forum.Name;
            target.UserName        = accountRep.GetByKey(thread.RootMessage.Account).UserName;
            target.LastModified    = thread.State.ModifiedDate;
            target.ForumMessageSum = forum.ThreadCount;

            //创建回复列表
            IList <ThreadsDspModel> list = new List <ThreadsDspModel>();

            //从仓储中取出
            IList <ForumMessageReply> replylist = msgRep.FindAll(new Specification <ForumMessageReply>(m => m.ForumThreadID == thread.Id).OrderBy(m => m.CreationDate).Skip((pageIndex - 1) * 15).Take(15));

            //IList<ForumMessageReply> replylist = msgRep.GetReplyByRootMsgID(thread.RootMessage.Id, (pageIndex-1)*15, 15);

            //转换回复
            foreach (ForumMessage msg in replylist)
            {
                if (msg.Id == thread.RootMessage.Id)
                {
                    continue;
                }
                ThreadsDspModel model = new ThreadsDspModel();
                model.Body         = msg.MessageVO.Body;
                model.CreationDate = msg.CreationDate;
                model.UserID       = msg.Account;
                model.UserName     = accountRep.GetByKey(msg.Account).UserName;
                model.MessageID    = msg.Id;
                list.Add(model);
            }

            //加到帖子详细模型中
            target.ReplyList = list;


            //点击增加计数
            thread.AddClickCount();
            //更新thread
            threadWriteRep.Update(thread);
            //持久化
            threadWriteRep.PersistAll();


            return(target);
        }