示例#1
0
        public IList<Core.Business.SpaceComment> GetAllSpaceComment()
        {
            IList<Core.Business.SpaceComment> spaceCommentlist = new List<Core.Business.SpaceComment>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

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

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.SpaceComment spaceComment = new Core.Business.SpaceComment();

                    long id = reader.GetInt64(0);
                    spaceComment = Core.Business.SpaceComment.Load(id);

                    /*
                    if (!reader.IsDBNull(0)) spaceComment.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) spaceComment.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) spaceComment.InstanceId = reader.GetInt64(2);
                    if (!reader.IsDBNull(3)) spaceComment.AccountId = reader.GetInt64(3);
                    if (!reader.IsDBNull(4)) spaceComment.AuthorId = reader.GetInt64(4);
                    if (!reader.IsDBNull(5)) spaceComment.ReferedId = reader.GetInt64(5);
                    if (!reader.IsDBNull(6)) spaceComment.DateCreated = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) spaceComment.IsPublic = reader.GetBoolean(7);
                    if (!reader.IsDBNull(8)) spaceComment.IP = reader.GetString(8);
                    */

                    spaceComment.MarkOld();
                    spaceCommentlist.Add(spaceComment);
                }
                reader.Close();
            }
            return spaceCommentlist;
        }
示例#2
0
        public Core.Business.SpaceComment Select(long id)
        {
            SqlServerUtility sql = new SqlServerUtility(connectionString);

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

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

                if (!reader.IsDBNull(0)) spaceComment.Id = reader.GetInt64(0);
                if (!reader.IsDBNull(1)) spaceComment.Content = reader.GetString(1);
                if (!reader.IsDBNull(2)) spaceComment.InstanceId = reader.GetInt64(2);
                if (!reader.IsDBNull(3)) spaceComment.AccountId = reader.GetInt64(3);
                if (!reader.IsDBNull(4)) spaceComment.AuthorId = reader.GetInt64(4);
                if (!reader.IsDBNull(5)) spaceComment.ReferedId = reader.GetInt64(5);
                if (!reader.IsDBNull(6)) spaceComment.DateCreated = reader.GetDateTime(6);
                if (!reader.IsDBNull(7)) spaceComment.IsPublic = reader.GetBoolean(7);
                if (!reader.IsDBNull(8)) spaceComment.IP = reader.GetString(8);

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

                return null;
            }
        }
示例#3
0
        public List<Core.Business.SpaceComment> SearchAllUnionSpecifiedAccountRelated(
            long? accountId,
            long? instanceId,
            bool? isPublic,
            long specifiedAccountId,
            Core.PagingInfo pagingInfo)
        {
            List<SpaceComment> comments = new List<SpaceComment>();

            StringBuilder sbFilter = new StringBuilder();
            sbFilter.Append(" 1=1");

            if (accountId.HasValue)
            {
                sbFilter.Append(" And [AccountId] = ");
                sbFilter.Append(accountId.Value);
            }
            if (instanceId.HasValue)
            {
                sbFilter.Append(" And [InstanceId] = ");
                sbFilter.Append(instanceId.Value);
            }
            if (isPublic.HasValue)
            {
                sbFilter.Append(" And ([IsPublic] = '");
                sbFilter.Append(isPublic.Value);
                sbFilter.Append("'");

                sbFilter.Append(" OR [AuthorId] = ");
                sbFilter.Append(specifiedAccountId);
                sbFilter.Append(")");
            }

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

            SqlServerUtility sql = new SqlServerUtility(connectionString);

            sql.AddParameter("@Tables", SqlDbType.VarChar, "SpaceComment");
            sql.AddParameter("@PK", SqlDbType.VarChar, "Id");
            sql.AddParameter("@Fields", SqlDbType.VarChar, "[Id]");
            sql.AddParameter("@Filter", SqlDbType.VarChar, sbFilter.ToString());
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNumber);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            sql.AddParameter("@Sort", SqlDbType.VarChar, "Id desc", 200);

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

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.SpaceComment spaceComment = new Core.Business.SpaceComment();

                    long id = reader.GetInt64(0);
                    spaceComment = Core.Business.SpaceComment.Load(id);

                    /*
                    if (!reader.IsDBNull(0)) spaceComment.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) spaceComment.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) spaceComment.InstanceId = reader.GetInt64(2);
                    if (!reader.IsDBNull(3)) spaceComment.AccountId = reader.GetInt64(3);
                    if (!reader.IsDBNull(4)) spaceComment.AuthorId = reader.GetInt64(4);
                    if (!reader.IsDBNull(5)) spaceComment.ReferedId = reader.GetInt64(5);
                    if (!reader.IsDBNull(6)) spaceComment.DateCreated = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) spaceComment.IsPublic = reader.GetBoolean(7);
                    if (!reader.IsDBNull(8)) spaceComment.IP = reader.GetString(8);
                    */

                    spaceComment.MarkOld();
                    comments.Add(spaceComment);
                }
                reader.Close();
            }

            return comments;
        }