Ejemplo n.º 1
0
        public IList<Core.Business.Topic> GetAllTopic()
        {
            IList<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            SqlDataReader reader = sql.ExecuteSPReader("USP_Topic_SelectAll");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }
Ejemplo n.º 2
0
        public Core.Business.Topic Select(Guid id)
        {
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            sql.AddParameter("@Id", SqlDbType.UniqueIdentifier, id);
            SqlDataReader reader = sql.ExecuteSPReader("USP_Topic_Select_By_Id");

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.Topic topic = new Core.Business.Topic();

                if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                reader.Close();
                return topic;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
Ejemplo n.º 3
0
        public List<CY.UME.Core.Business.Topic> SearchTopices(string InstanceId, string topicExtendType, string authorName, string title, int? minViewNum, int? maxViewNum, int? minReplyNum, int? maxReplyNum, DateTime? minPubDate, DateTime? maxPubDate, int? level, int? type, PagingInfo pageInfo)
        {
            List<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();

            SqlServerUtility sql = new SqlServerUtility(connectionString);
            string filter = String.Empty;
            string fields = String.Empty;

            filter += "1=1";

            bool topicExtendCheck = false;
            if (InstanceId.Length > 0 || topicExtendType.Length > 0)
            {
                topicExtendCheck = true;
            }

            if (topicExtendCheck)
            {
                filter += " and [Id] in (Select [Id] FROM [TopicExtend] Where 1=1";
            }

            if (InstanceId.Length > 0)
            {
                filter += " and InstanceId = '" + InstanceId + "'";
            }
            if (topicExtendType.Length > 0)
            {
                filter += " and [Type]='" + topicExtendType + "'";
            }

            if (topicExtendCheck)
            {
                filter += ")";
            }

            bool accountCheck = false;
            if (authorName.Length > 0)
            {
                accountCheck = true;
            }

            if (accountCheck)
            {
                filter += " and AccountId in (select [Id] From Account Where 1=1";
            }
            if (authorName.Length > 0)
            {
                filter += " and [Name] like '%" + authorName + "%'";
            }
            if (accountCheck)
            {
                filter += ")";
            }

            if (title.Length > 0)
            {
                filter += " and [Title] like '%" + title + "%'";
            }
            if (minViewNum != null)
            {
                filter += " and [ViewNum] >= " + minViewNum.ToString();
            }
            if (maxViewNum != null)
            {
                filter += " and [ViewNum] <= " + minViewNum.ToString();
            }
            if (minReplyNum != null)
            {
                filter += " and [ReplyNum] >= " + minReplyNum.ToString();
            }
            if (maxReplyNum != null)
            {
                filter += " and [ReplyNum] <= " + maxReplyNum.ToString();
            }
            if (minPubDate != null)
            {
                filter += " and [DateCreated] >= '" + minPubDate.ToString() + "'";
            }
            if (maxPubDate != null)
            {
                filter += " and [DateCreated] <= '" + maxPubDate.ToString() + "'";
            }
            if (level != null)
            {
                filter += " and [Level] =" + level.ToString();
            }
            if (type != null)
            {
                filter += " and [type]=" + type.ToString();
            }
            fields = "[Id], [Content],[ViewNum],[ReplyNum],[TypeId],[DateCreated],[LastReplyDate],[AccountId],[LastAuthorId],[Title],[IP],[Level]";

            sql.AddParameter("@PageNumber", SqlDbType.Int, pageInfo.CurrentPage);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageInfo.PageSize);

            sql.AddParameter("@Tables", SqlDbType.NVarChar, "Topic");
            sql.AddParameter("@PK", SqlDbType.NVarChar, "Id");
            sql.AddParameter("@Sort", SqlDbType.NVarChar, "LastReplyDate desc");
            sql.AddParameter("@Fields", SqlDbType.NVarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.NVarChar, filter);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }
Ejemplo n.º 4
0
        public IList<CY.UME.Core.Business.Topic> GetTopicsByInstanceIdAndType(string topicExtendType, string instanceId, PagingInfo pageInfo, string field, string sort, int level)
        {
            IList<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);
            string sorts = String.Empty;
            string filter = String.Empty;
            string fields = String.Empty;

            sorts = field + " " + sort;

            filter = "[Id] in (Select [Id] FROM [TopicExtend] Where 1=1 ";
            if (instanceId.Length != 0)
            {
                filter += " and [InstanceId] = '" + instanceId + "'";
            }
            if (topicExtendType.Length != 0)
            {
                filter += " and [Type] = '" + topicExtendType + "'";
            }
            filter += ")";

            if (level != -1)
            {
                filter += " AND [Level] = " + level.ToString();
            }
            fields = "[Id],[Content],[ViewNum],[ReplyNum],[TypeId],[DateCreated],[LastReplyDate],[AccountId],[LastAuthorId],[Title],[IP],[Level]";

            sql.AddParameter("@PageNumber", SqlDbType.Int, pageInfo.CurrentPage);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageInfo.PageSize);

            sql.AddParameter("@Tables", SqlDbType.NVarChar, "Topic");
            sql.AddParameter("@PK", SqlDbType.NVarChar, "Id");
            sql.AddParameter("@Sort", SqlDbType.NVarChar, sorts);
            sql.AddParameter("@Fields", SqlDbType.NVarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.NVarChar, filter);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }
Ejemplo n.º 5
0
        // ��̨����
        public IList<Core.Business.Topic> GetAllTopic(string GroupName, string strAccountIds, string Title, string Content, string StartTime, string EndTime, string Sort, Core.PagingInfo pageInfo)
        {
            List<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();

            SqlServerUtility sql = new SqlServerUtility(connectionString);

            String strFilter = SetStrFilter(GroupName, strAccountIds, Title, Content, StartTime, EndTime);
            /*
            sql.AddParameter("@PageNumber", SqlDbType.Int, pagingInfo.CurrentPage);
            sql.AddParameter("@PageSize", SqlDbType.Int, pagingInfo.PageSize);
            sql.AddParameter("@Tables", SqlDbType.NVarChar, "Topic,[Group],TopicExtend");
            sql.AddParameter("@PK", SqlDbType.NVarChar, "Id");
            sql.AddParameter("@Sort", SqlDbType.NVarChar, Sort + " DESC");
            sql.AddParameter("@Fields", SqlDbType.NVarChar, "[Topic].[Id],[Topic].[Content],[Topic].[ViewNum],[Topic].[ReplyNum],[Topic].[TypeId],[Topic].[DateCreated],[Topic].[LastReplyDate],[Topic].[AccountId],[Topic].[LastAuthorId],[Topic].[Title],[Topic].[IP],[Topic].[Level]");
            sql.AddParameter("@Filter", SqlDbType.NVarChar, strFilter);*/

            int pageSize = int.MaxValue;
            int pageNumber = 1;
            if (pageInfo != null)
            {
                pageSize = pageInfo.PageSize;
                pageNumber = pageInfo.CurrentPage;
            }

            sql.AddParameter("@PageNum", SqlDbType.Int, pageSize);
            sql.AddParameter("@Num", SqlDbType.Int, pageSize * (pageNumber - 1));
            string SqlGetUC = "SELECT Top (@PageNum) [Topic].[Id],[Topic].[Content],[Topic].[ViewNum],[Topic].[ReplyNum],[Topic].[TypeId],[Topic].[DateCreated],[Topic].[LastReplyDate],[Topic].[AccountId],[Topic].[LastAuthorId],[Topic].[Title],[Topic].[IP],[Topic].[Level] ";
            SqlGetUC += "FROM [Topic],[Group],[TopicExtend] ";
            SqlGetUC += "WHERE [Topic].[Id] not in(SELECT Top (@Num) [Topic].[Id] ";
            SqlGetUC += "FROM [Topic],[Group],[TopicExtend] ";
            SqlGetUC += "WHERE ";
            SqlGetUC += strFilter.ToString() + "ORDER BY " + Sort + "  DESC) and " + strFilter.ToString() + " ORDER BY " + Sort + " DESC";

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetUC);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }
Ejemplo n.º 6
0
        public IList<Core.Business.Topic> GetSettleGroupTopice(string strId, int PageSize)
        {
            List<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();

            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string[] Id = strId.Split(',');
            String Column = "[Id], [Content],[ViewNum],[ReplyNum],[TypeId],[DateCreated],[LastReplyDate],[AccountId],[LastAuthorId],[Title],[IP],[Level]";

            for (int i = 0; i < Id.Length; i++)
            {
                String SelSQL = "SELECT " + Column + " FROM [Topic] WHERE [Id] = '" + Id[i].ToString() + "'";
                SqlDataReader reader = sql.ExecuteSqlReader(SelSQL);

                if (reader != null && !reader.IsClosed && reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                    reader.Close();
                }
                else
                {
                    if (reader != null && !reader.IsClosed)
                        reader.Close();
                }
            }
            // ������������ﲻ��Ԥ��ֵ
            if (topiclist != null && topiclist.Count < PageSize)
            {
                PageSize = PageSize - topiclist.Count;

                String SelSQL = "SELECT TOP (" + PageSize + ") " + Column + " FROM [Topic] WHERE [Id] NOT IN ('" + strId + "') ORDER BY [ReplyNum] DESC";
                SqlDataReader reader = sql.ExecuteSqlReader(SelSQL);

                if (reader != null)
                {
                    while (reader.Read())
                    {
                        Core.Business.Topic topic = new Core.Business.Topic();

                        if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                        if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                        if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                        if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                        if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                        if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                        if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                        if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                        if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                        if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                        if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                        if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                        topic.MarkOld();
                        topiclist.Add(topic);
                    }
                    reader.Close();
                }
            }

            return topiclist;
        }
Ejemplo n.º 7
0
        public IList<CY.UME.Core.Business.Topic> GetReplyedTopicesByAccount(CY.UME.Core.Business.Account account, int level, string type, PagingInfo pageInfo)
        {
            IList<CY.UME.Core.Business.Topic> topiclist = new List<CY.UME.Core.Business.Topic>();

            if (account == null)
            {
                return topiclist;
            }

            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string filter = "Id in (select InstanceId from TopicReply where [AuthorId] = " + account.Id + ")";
            filter += "and Id in (select Id from TopicExtend where InstanceId NOT IN(SELECT [Id] FROM [Group] WHERE [IsChecked] = 0) and [Type]='" + type + "')"; //����˹��˽�ɢȺ��ʱ��ʾ����ظ�����--2010/12/25
            if (level != -1)
            {
                filter += " and [level]=" + level;
            }

            sql.AddParameter("@PageNumber", SqlDbType.Int, pageInfo.CurrentPage);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageInfo.PageSize);

            sql.AddParameter("@Tables", SqlDbType.NVarChar, "Topic");
            sql.AddParameter("@PK", SqlDbType.NVarChar, "Id");
            sql.AddParameter("@Sort", SqlDbType.NVarChar, "LastReplyDate desc");
            sql.AddParameter("@Fields", SqlDbType.NVarChar, "[Id], [Content],[ViewNum],[ReplyNum],[TypeId],[DateCreated],[LastReplyDate],[AccountId],[LastAuthorId],[Title],[IP],[Level]");
            sql.AddParameter("@Filter", SqlDbType.NVarChar, filter);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }
Ejemplo n.º 8
0
        public IList<Topic> GetLastTopic(string type, int InstanceId, long AccountId)
        {
            List<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();

            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string sqlwhere = "select t.[Id],t.[AccountId],t.[Title],t.[Content],t.[DateCreated],t.[ViewNum],t.[ReplyNum],t.[LastReplyDate],t.[LastAuthorId],t.[IP],t.[TypeId],t.[Level] from Topic t inner join(select Id from TopicExtend where [Type]='" + type + "' and InstanceId=" + InstanceId + " and AccountId=" + AccountId + ") te on te.Id=t.Id order by DateCreated desc";

            SqlDataReader reader = sql.ExecuteSqlReader(sqlwhere);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }
Ejemplo n.º 9
0
        public List<CY.UME.Core.Business.Topic> GetGroupsTopicesByGroupTypeAndAccountId(CY.UME.Core.Business.Account account, PagingInfo pageInfo, int type, bool? IsRecommend, bool? IsManage, string field)
        {
            List<Core.Business.Topic> topiclist = new List<Core.Business.Topic>();

            SqlServerUtility sql = new SqlServerUtility(connectionString);
            string filter = String.Empty;
            string fields = String.Empty;

            filter = "[Id] in (Select [Id] FROM [TopicExtend] Where [Type]='group'";
            if (account != null)
            {
                filter += " and [InstanceId] in (select GroupId from accountgroup where accountId = " + account.Id;

                if (IsManage != null)
                {
                    if (IsManage.Value)
                    {
                        filter += " and [Role] = 1";
                    }
                    else
                    {
                        filter += " and [Role] <> 1";
                    }
                }

                filter += ")";
            }

            if (type != -1)
            {
                filter += " and [InstanceId] in (select [Id] from [Group] where 1=1 and [IsChecked]=1";
                if (type == -2)
                {
                    filter += " and [Type] <>0 ";
                }
                else
                {
                    filter += " and [Type] = " + type.ToString();
                }
                filter += ")";
            }

            if (IsRecommend != null)
            {
                filter += " and [InstanceId] in (select [Id] from [Group] where [IsRecommended]=" + (IsRecommend.Value ? "1" : "0") + " and [IsChecked]=1)";
            }

            filter += ")";
            fields = "[Id], [Content],[ViewNum],[ReplyNum],[TypeId],[DateCreated],[LastReplyDate],[AccountId],[LastAuthorId],[Title],[IP],[Level]";

            sql.AddParameter("@PageNumber", SqlDbType.Int, pageInfo.CurrentPage);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageInfo.PageSize);

            sql.AddParameter("@Tables", SqlDbType.NVarChar, "Topic");
            sql.AddParameter("@PK", SqlDbType.NVarChar, "Id");
            sql.AddParameter("@Sort", SqlDbType.NVarChar, field + " desc");
            sql.AddParameter("@Fields", SqlDbType.NVarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.NVarChar, filter);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Topic topic = new Core.Business.Topic();

                    if (!reader.IsDBNull(0)) topic.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) topic.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) topic.ViewNum = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) topic.ReplyNum = reader.GetInt32(3);
                    if (!reader.IsDBNull(4)) topic.TypeId = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) topic.DateCreated = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) topic.LastReplyDate = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) topic.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) topic.LastAuthorId = reader.GetInt64(8);
                    if (!reader.IsDBNull(9)) topic.Title = reader.GetString(9);
                    if (!reader.IsDBNull(10)) topic.IP = reader.GetString(10);
                    if (!reader.IsDBNull(11)) topic.Level = reader.GetInt32(11);

                    topic.MarkOld();
                    topiclist.Add(topic);
                }
                reader.Close();
            }
            return topiclist;
        }