public IList<Core.Business.ChatList> GetAllChatList() { IList<Core.Business.ChatList> chatListlist = new List<Core.Business.ChatList>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSPReader("usp_SelectChatListsAll"); if (reader != null) { while (reader.Read()) { Core.Business.ChatList chatList = new Core.Business.ChatList(); if (!reader.IsDBNull(0)) chatList.Id = reader.GetGuid(0); if (!reader.IsDBNull(1)) chatList.SenderID = reader.GetGuid(1); if (!reader.IsDBNull(2)) chatList.RobotChat = reader.GetInt32(2); if (!reader.IsDBNull(3)) chatList.KeyWords = reader.GetString(3); if (!reader.IsDBNull(4)) chatList.ReciverID = reader.GetGuid(4); if (!reader.IsDBNull(5)) chatList.Content = reader.GetString(5); if (!reader.IsDBNull(6)) chatList.ChatDateTime = reader.GetDateTime(6); chatList.MarkOld(); chatListlist.Add(chatList); } reader.Close(); } return chatListlist; }
public List<ChatList> SelectChatListsByUserId(Guid guid) { List<Core.Business.ChatList> chatListlist = new List<Core.Business.ChatList>(); System.Text.StringBuilder sbFilter = new StringBuilder(); sbFilter.Append("SenderID='" + guid.ToString() + "'"); sbFilter.Append(" OR ReciverID='" + guid.ToString() + "'"); SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@WhereCondition", SqlDbType.NVarChar, sbFilter.ToString()); sql.AddParameter("@OrderByExpression", SqlDbType.NVarChar, "Id desc"); SqlDataReader reader = sql.ExecuteSPReader("usp_SelectChatListsDynamic"); if (reader != null) { while (reader.Read()) { Core.Business.ChatList chatList = new Core.Business.ChatList(); if (!reader.IsDBNull(0)) chatList.Id = reader.GetGuid(0); if (!reader.IsDBNull(1)) chatList.SenderID = reader.GetGuid(1); if (!reader.IsDBNull(2)) chatList.RobotChat = reader.GetInt32(2); if (!reader.IsDBNull(3)) chatList.KeyWords = reader.GetString(3); if (!reader.IsDBNull(4)) chatList.ReciverID = reader.GetGuid(4); if (!reader.IsDBNull(5)) chatList.Content = reader.GetString(5); if (!reader.IsDBNull(6)) chatList.ChatDateTime = reader.GetDateTime(6); chatList.MarkOld(); chatListlist.Add(chatList); } reader.Close(); } return chatListlist; }
public List<ChatList> GetChatLists(Guid? senderid, Guid? recieverid, bool isrobotchat, string keyword, string time, int pagesize, int pagenum) { System.Text.StringBuilder sbFilter = new StringBuilder(); List<CY.CSTS.Core.Business.ChatList> chatListlist = new List<ChatList>(); sbFilter.Append(" 1=1 "); if (senderid.HasValue) { sbFilter.Append(" and SenderId='"); sbFilter.Append(senderid); sbFilter.Append("'"); } if (recieverid.HasValue) { sbFilter.Append(" and ReciverId='"); sbFilter.Append(recieverid); sbFilter.Append("'"); } if (isrobotchat) { sbFilter.Append(" and RobotChat="); sbFilter.Append(1); } else { sbFilter.Append(" and RobotChat="); sbFilter.Append(2); } if (!string.IsNullOrEmpty(keyword)) { sbFilter.Append(" and Keywords like '%"); sbFilter.Append(keyword.Replace("'", "").Replace("\"", "")); sbFilter.Append("%'"); } DateTime date = new DateTime(); if (!string.IsNullOrEmpty(time) && CY.Utility.Common.ParseUtility.TryParseDateTime(time, out date) && date > DateTime.MinValue) { sbFilter.Append(" and ChatDateTime >"); sbFilter.Append(time); } string tables = "ChatList"; string pK = "Id"; string sort = "Id Desc"; int pageNum = pagenum; int pageSize = pagesize; string fields = " * "; string filter = sbFilter.ToString(); SqlServerUtility sql = new SqlServerUtility(); 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); SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount"); if (reader != null && !reader.IsClosed) { Core.Business.ChatList chatList = null; while (reader.Read()) { chatList = new Core.Business.ChatList(); if (!reader.IsDBNull(0)) chatList.Id = reader.GetGuid(0); if (!reader.IsDBNull(1)) chatList.SenderID = reader.GetGuid(1); if (!reader.IsDBNull(2)) chatList.RobotChat = reader.GetInt32(2); if (!reader.IsDBNull(3)) chatList.KeyWords = reader.GetString(3); if (!reader.IsDBNull(4)) chatList.ReciverID = reader.GetGuid(4); if (!reader.IsDBNull(5)) chatList.Content = reader.GetString(5); if (!reader.IsDBNull(6)) chatList.ChatDateTime = reader.GetDateTime(6); chatList.MarkOld(); chatListlist.Add(chatList); } reader.Close(); } return chatListlist; }