示例#1
0
        /// <summary>
        /// 获取帖子
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>帖子</returns>
        public ForumThread GetByKey(Guid id)
        {
            ForumThread tmp = null;

            try
            {
                var list = ForumThreadPersist.GetThread("select * from fbs_ForumThread inner join fbs_Message on fbs_ForumThread.RootMessageID=fbs_Message.MessageID where fbs_ForumThread.ThreadID='" + id.ToString() + "'");
                if (list != null && list.Count == 1)
                {
                    tmp = list.SingleOrDefault();
                }
            }
            catch (InvalidOperationException error)
            { }
            return(tmp);
        }
示例#2
0
 public IList <ForumThread> GetThread(string cmdText)
 {
     return(ForumThreadPersist.GetThread(cmdText).ToList());
 }
示例#3
0
 /// <summary>
 /// 获取论坛下的帖子
 /// </summary>
 /// <param name="forumId"></param>
 /// <param name="startIndex"></param>
 /// <param name="count"></param>
 /// <returns></returns>
 public IList <ForumThread> GetThreadsInOneForum(Guid forumId, int startIndex, int count)
 {
     //return this._forumThread.Where(t => t.ForumID == forumId).Skip(startIndex).Take(count).OrderByDescending(f => f.ModifiedDate).ToList();
     return(ForumThreadPersist.GetAllForumThread(forumId, startIndex, count).ToList());
 }
示例#4
0
        /// <summary>
        /// 持久化所有.....还有部分未实现
        /// </summary>
        public void PersistAll()
        {
            #region 转换成DataTable
            //新添加元素
            DataTable newThreadsTable  = new DataTable("NewForumThreads");
            DataTable newMessagesTable = new DataTable("NewMessages");

            //修改过的元素
            DataTable modifiedThreadsTable = new DataTable("ModifiedForumThreads");


            //被删除的元素
            DataTable removedThreadsTable = new DataTable("RemovedForumThreads");


            foreach (ForumThread th in this._newThreads)
            {
                th.AlterToRow(newThreadsTable);
                th.RootMessage.AlterToRow(newMessagesTable);
            }

            foreach (ForumThread th in this._modifiedThreads)
            {
                th.AlterToRow(modifiedThreadsTable);
            }

            foreach (ForumThread th in this._removedThreads)
            {
                th.AlterToRow(removedThreadsTable);
            }



            #endregion

            #region 持久化

            //添加
            if (newThreadsTable.Rows.Count != 0)
            {
                ForumThreadPersist.AddAll(newThreadsTable);
            }

            if (newMessagesTable.Rows.Count != 0)
            {
                ForumMessagePersist.AddAll(newMessagesTable);
            }

            //更新
            if (modifiedThreadsTable.Rows.Count != 0)
            {
                ForumThreadPersist.UpdateAll(modifiedThreadsTable);
            }

            //删除
            if (removedThreadsTable.Rows.Count != 0)
            {
                ForumThreadPersist.RemoveAll(removedThreadsTable);
            }


            #endregion

            #region 释放内存

            this._newThreads.Clear();
            this._removedThreads.Clear();
            this._modifiedThreads.Clear();
            #endregion
        }