public IList<Core.Business.Blog> GetAllBlog() { IList<Core.Business.Blog> bloglist = new List<Core.Business.Blog>(); SqlServerUtility sql = new SqlServerUtility(SqlConnection); SqlDataReader reader = sql.ExecuteSPReader("USP_Blog_Select_All"); if (reader != null) { while (reader.Read()) { Core.Business.Blog blog = new Core.Business.Blog(); if (!reader.IsDBNull(0)) blog.Id = reader.GetInt64(0); if (!reader.IsDBNull(1)) blog.BlogContent = reader.GetString(1); if (!reader.IsDBNull(2)) blog.TypeId = reader.GetInt64(2); if (!reader.IsDBNull(3)) blog.ViewNum = reader.GetInt32(3); if (!reader.IsDBNull(4)) blog.ReplyNum = reader.GetInt32(4); if (!reader.IsDBNull(5)) blog.TraceNum = reader.GetInt32(5); if (!reader.IsDBNull(6)) blog.ViewSet = reader.GetInt32(6); if (!reader.IsDBNull(7)) blog.DateCreated = reader.GetDateTime(7); if (!reader.IsDBNull(8)) blog.NoReply = reader.GetBoolean(8); if (!reader.IsDBNull(9)) blog.AccountId = reader.GetInt64(9); if (!reader.IsDBNull(10)) blog.AccountName = reader.GetString(10); if (!reader.IsDBNull(11)) blog.Subject = reader.GetString(11); if (!reader.IsDBNull(12)) blog.Password = reader.GetString(12); if (!reader.IsDBNull(13)) blog.IP = reader.GetString(13); if (!reader.IsDBNull(14)) blog.Tag = reader.GetString(14); blog.MarkOld(); bloglist.Add(blog); } reader.Close(); } return bloglist; }
//������־���⡢���ݹؼ��֡���ʼʱ��ͽ���ʱ���ѯ public IList<Blog> GetAllBlogsBySubjectKeyDate(CY.UME.Core.PagingInfo pagingInfo, string Subject, string Key, string BeginTime, string EndTime) { IList<Core.Business.Blog> bloglist = new List<Core.Business.Blog>(); SqlServerUtility sql = new SqlServerUtility(SqlConnection); sql.AddParameter("@Tables", SqlDbType.NVarChar, "Blog"); sql.AddParameter("@PK", SqlDbType.NVarChar, "Id"); sql.AddParameter("@Sort", SqlDbType.NVarChar, "Id DESC"); sql.AddParameter("@PageNumber", SqlDbType.Int, pagingInfo.CurrentPage); sql.AddParameter("@PageSize", SqlDbType.Int, pagingInfo.PageSize); sql.AddParameter("@Fields", SqlDbType.NVarChar, "[Id], [BlogContent],[TypeId],[ViewNum],[ReplyNum],[TraceNum],[ViewSet],[DateCreated],[NoReply],[AccountId],[AccountName],[Subject],[Password],[IP],[Tag]"); string where = " 1=1 "; if (Subject.Length != 0) where += " AND [Subject] like '%" + Subject + "%' "; if (Key.Length != 0) where += " AND [BlogContent] like '" + Key + "' "; if (BeginTime.Length != 0) where += " AND [DateCreated] BETWEEN '" + BeginTime + "' AND '" + EndTime + "' "; sql.AddParameter("@Filter", SqlDbType.NVarChar, where); SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount"); if (reader != null) { while (reader.Read()) { Core.Business.Blog blog = new Core.Business.Blog(); if (!reader.IsDBNull(0)) blog.Id = reader.GetInt64(0); if (!reader.IsDBNull(1)) blog.BlogContent = reader.GetString(1); if (!reader.IsDBNull(2)) blog.TypeId = reader.GetInt64(2); if (!reader.IsDBNull(3)) blog.ViewNum = reader.GetInt32(3); if (!reader.IsDBNull(4)) blog.ReplyNum = reader.GetInt32(4); if (!reader.IsDBNull(5)) blog.TraceNum = reader.GetInt32(5); if (!reader.IsDBNull(6)) blog.ViewSet = reader.GetInt32(6); if (!reader.IsDBNull(7)) blog.DateCreated = reader.GetDateTime(7); if (!reader.IsDBNull(8)) blog.NoReply = reader.GetBoolean(8); if (!reader.IsDBNull(9)) blog.AccountId = reader.GetInt64(9); if (!reader.IsDBNull(10)) blog.AccountName = reader.GetString(10); if (!reader.IsDBNull(11)) blog.Subject = reader.GetString(11); if (!reader.IsDBNull(12)) blog.Password = reader.GetString(12); if (!reader.IsDBNull(13)) blog.IP = reader.GetString(13); if (!reader.IsDBNull(14)) blog.Tag = reader.GetString(14); blog.MarkOld(); bloglist.Add(blog); } reader.Close(); } return bloglist; }
public IList<CY.UME.Core.Business.Blog> GetTopBlogsByAccountId(CY.UME.Core.Business.Account account, CY.UME.Core.PagingInfo pagingInfo, int viewSet, long type) { IList<Core.Business.Blog> bloglist = new List<Core.Business.Blog>(); SqlServerUtility sql = new SqlServerUtility(SqlConnection); #region ���� string tables = "Blog"; string pK = "Id"; string sort = "Id Desc"; int pageNum = pagingInfo.CurrentPage; int pageSize = pagingInfo.PageSize; string fields = "[Id], [BlogContent],[TypeId],[ViewNum],[ReplyNum],[TraceNum],[ViewSet],[DateCreated],[NoReply],[AccountId],[AccountName],[Subject],[Password],[IP],[Tag]"; string filter = "[AccountId]=" + account.Id.ToString(); if (viewSet == 1) { filter += " and [ViewSet] in (0,1)"; } else if (viewSet == 2) { filter += " and [ViewSet] =0"; } if (type > -1) { filter += " and [TypeId] =" + type.ToString(); } string group = String.Empty; #endregion sql.AddParameter("@Tables", SqlDbType.VarChar, tables); sql.AddParameter("@PK", SqlDbType.VarChar, pK); sql.AddParameter("@Sort", SqlDbType.VarChar, sort); sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum); sql.AddParameter("@PageSize", SqlDbType.Int, pageSize); sql.AddParameter("@Fields", SqlDbType.VarChar, fields); sql.AddParameter("@Filter", SqlDbType.VarChar, filter); sql.AddParameter("@Group", SqlDbType.VarChar, group); SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount"); if (reader != null) { while (reader.Read()) { Core.Business.Blog blog = new Core.Business.Blog(); long id = reader.GetInt64(0); blog = Core.Business.Blog.Load(id); blog.MarkOld(); bloglist.Add(blog); } reader.Close(); } return bloglist; }
public IList<Core.Business.Blog> GetSettleBlogs(String StrId, int PageSize) { IList<Core.Business.Blog> bloglist = new List<Core.Business.Blog>(); SqlServerUtility sql = new SqlServerUtility(SqlConnection); String Column = "[Id],[BlogContent],[TypeId],[ViewNum],[ReplyNum],[TraceNum],[ViewSet],[DateCreated],[NoReply],[AccountId],[AccountName],[Subject],[Password],[IP],[Tag]"; string[] Id = StrId.Split(','); for (int i = 0; i < Id.Length; i++) { String SelSQL = "SELECT " + Column + " FROM [Blog] WHERE [Id] = " + Id[i].ToString(); SqlDataReader reader = sql.ExecuteSqlReader(SelSQL); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.Blog blog = new Core.Business.Blog(); if (!reader.IsDBNull(0)) blog.Id = reader.GetInt64(0); if (!reader.IsDBNull(1)) blog.BlogContent = reader.GetString(1); if (!reader.IsDBNull(2)) blog.TypeId = reader.GetInt64(2); if (!reader.IsDBNull(3)) blog.ViewNum = reader.GetInt32(3); if (!reader.IsDBNull(4)) blog.ReplyNum = reader.GetInt32(4); if (!reader.IsDBNull(5)) blog.TraceNum = reader.GetInt32(5); if (!reader.IsDBNull(6)) blog.ViewSet = reader.GetInt32(6); if (!reader.IsDBNull(7)) blog.DateCreated = reader.GetDateTime(7); if (!reader.IsDBNull(8)) blog.NoReply = reader.GetBoolean(8); if (!reader.IsDBNull(9)) blog.AccountId = reader.GetInt64(9); if (!reader.IsDBNull(10)) blog.AccountName = reader.GetString(10); if (!reader.IsDBNull(11)) blog.Subject = reader.GetString(11); if (!reader.IsDBNull(12)) blog.Password = reader.GetString(12); if (!reader.IsDBNull(13)) blog.IP = reader.GetString(13); if (!reader.IsDBNull(14)) blog.Tag = reader.GetString(14); blog.MarkOld(); bloglist.Add(blog); reader.Close(); } else { if (reader != null && !reader.IsClosed) reader.Close(); } } // ������������ﲻ��Ԥ��ֵ if (bloglist != null && bloglist.Count < PageSize) { PageSize = PageSize - bloglist.Count; String SelSQL = "SELECT TOP (" + PageSize + ") " + Column + " FROM [Blog] WHERE [Id] NOT IN ('" + StrId + "') ORDER BY [ReplyNum] DESC"; SqlDataReader reader = sql.ExecuteSqlReader(SelSQL); if (reader != null) { while (reader.Read()) { Core.Business.Blog blog = new Core.Business.Blog(); if (!reader.IsDBNull(0)) blog.Id = reader.GetInt64(0); if (!reader.IsDBNull(1)) blog.BlogContent = reader.GetString(1); if (!reader.IsDBNull(2)) blog.TypeId = reader.GetInt64(2); if (!reader.IsDBNull(3)) blog.ViewNum = reader.GetInt32(3); if (!reader.IsDBNull(4)) blog.ReplyNum = reader.GetInt32(4); if (!reader.IsDBNull(5)) blog.TraceNum = reader.GetInt32(5); if (!reader.IsDBNull(6)) blog.ViewSet = reader.GetInt32(6); if (!reader.IsDBNull(7)) blog.DateCreated = reader.GetDateTime(7); if (!reader.IsDBNull(8)) blog.NoReply = reader.GetBoolean(8); if (!reader.IsDBNull(9)) blog.AccountId = reader.GetInt64(9); if (!reader.IsDBNull(10)) blog.AccountName = reader.GetString(10); if (!reader.IsDBNull(11)) blog.Subject = reader.GetString(11); if (!reader.IsDBNull(12)) blog.Password = reader.GetString(12); if (!reader.IsDBNull(13)) blog.IP = reader.GetString(13); if (!reader.IsDBNull(14)) blog.Tag = reader.GetString(14); blog.MarkOld(); bloglist.Add(blog); } reader.Close(); } } return bloglist; }
// ��¼ʹ�� public IList<Blog> GetBlogsByViewNum(String Column, int Num) { IList<Core.Business.Blog> bloglist = new List<Core.Business.Blog>(); SqlServerUtility sql = new SqlServerUtility(SqlConnection); string sqlStr = "SELECT TOP (" + Num + ") [Id], [BlogContent],[TypeId],[ViewNum],[ReplyNum],[TraceNum],[ViewSet],[DateCreated],[NoReply],[AccountId],[AccountName],[Subject],[Password],[IP],[Tag] FROM [Blog] ORDER BY " + Column + " DESC"; SqlDataReader reader = sql.ExecuteSqlReader(sqlStr); if (reader != null) { while (reader.Read()) { Core.Business.Blog blog = new Core.Business.Blog(); if (!reader.IsDBNull(0)) blog.Id = reader.GetInt64(0); if (!reader.IsDBNull(1)) blog.BlogContent = reader.GetString(1); if (!reader.IsDBNull(2)) blog.TypeId = reader.GetInt64(2); if (!reader.IsDBNull(3)) blog.ViewNum = reader.GetInt32(3); if (!reader.IsDBNull(4)) blog.ReplyNum = reader.GetInt32(4); if (!reader.IsDBNull(5)) blog.TraceNum = reader.GetInt32(5); if (!reader.IsDBNull(6)) blog.ViewSet = reader.GetInt32(6); if (!reader.IsDBNull(7)) blog.DateCreated = reader.GetDateTime(7); if (!reader.IsDBNull(8)) blog.NoReply = reader.GetBoolean(8); if (!reader.IsDBNull(9)) blog.AccountId = reader.GetInt64(9); if (!reader.IsDBNull(10)) blog.AccountName = reader.GetString(10); if (!reader.IsDBNull(11)) blog.Subject = reader.GetString(11); if (!reader.IsDBNull(12)) blog.Password = reader.GetString(12); if (!reader.IsDBNull(13)) blog.IP = reader.GetString(13); if (!reader.IsDBNull(14)) blog.Tag = reader.GetString(14); blog.MarkOld(); bloglist.Add(blog); } reader.Close(); } return bloglist; }