示例#1
0
        public IList<Core.Business.Messages> GetAllMessages()
        {
            IList<Core.Business.Messages> messageslist = new List<Core.Business.Messages>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllMessages);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Messages messages = new Core.Business.Messages();

                    if (!reader.IsDBNull(0)) messages.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) messages.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) messages.Type = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) messages.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) messages.SendDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) messages.IsRead = reader.GetInt32(5);
                    if (!reader.IsDBNull(6)) messages.AuthorId = reader.GetInt64(6);
                    if (!reader.IsDBNull(7)) messages.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) messages.Title = reader.GetString(8);
                    if (!reader.IsDBNull(9)) messages.Attachments = reader.GetString(9);
                    if (!reader.IsDBNull(10)) messages.AuthorName = reader.GetString(10);
                    if (!reader.IsDBNull(11)) messages.AccountName = reader.GetString(11);

                    messages.MarkOld();
                    messageslist.Add(messages);
                }
                reader.Close();
            }
            return messageslist;
        }
示例#2
0
        //根据作者Id,类型,是否已读查询邮件
        public IList<Core.Business.Messages> GetMessagesByAccountIdOrAuthorId(CY.UME.Core.Business.Messages messages, PagingInfo pageInfo, String Sorts)
        {
            IList<Core.Business.Messages> messageslist = new List<Core.Business.Messages>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string filter = SetStrFilter(messages);

            if (Sorts.Length <= 0)
                Sorts = "Id DESC";

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

            sql.AddParameter("@Tables", SqlDbType.NVarChar, "Messages");
            sql.AddParameter("@PK", SqlDbType.NVarChar, "Id");
            sql.AddParameter("@Sort", SqlDbType.NVarChar, Sorts);
            sql.AddParameter("@Fields", SqlDbType.NVarChar, "[Id],[Content],[Type],[DateCreated],[SendDate],[IsRead],[AuthorId],[AccountId],[Title],[Attachments],[AuthorName],[AccountName]");
            sql.AddParameter("@Filter", SqlDbType.NVarChar, filter);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Messages message = new Core.Business.Messages();

                    if (!reader.IsDBNull(0)) message.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) message.Content = reader.GetString(1);
                    if (!reader.IsDBNull(2)) message.Type = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) message.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) message.SendDate = reader.GetDateTime(4);
                    if (!reader.IsDBNull(5)) message.IsRead = reader.GetInt32(5);
                    if (!reader.IsDBNull(6)) message.AuthorId = reader.GetInt64(6);
                    if (!reader.IsDBNull(7)) message.AccountId = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) message.Title = reader.GetString(8);
                    if (!reader.IsDBNull(9)) message.Attachments = reader.GetString(9);
                    if (!reader.IsDBNull(10)) message.AuthorName = reader.GetString(10);
                    if (!reader.IsDBNull(11)) message.AccountName = reader.GetString(11);

                    message.MarkOld();
                    messageslist.Add(message);
                }
                reader.Close();
            }
            return messageslist;
        }