public override ChatMessageCollection GetLastChatMessages(int userID, int targetUserID, int lastMessageID, int MessageCount) { ChatMessageCollection result; using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_Chat_GetLastMessages"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); query.CreateParameter <int>("@TargetUserID", targetUserID, SqlDbType.Int); query.CreateParameter <int>("@LastMessageID", lastMessageID, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { result = new ChatMessageCollection(); while (reader.Read()) { result.Insert(0, new ChatMessage(reader)); } } return(result); } }
public override ChatMessageCollection GetLastChatMessages(int userID, int targetUserID, int lastMessageID, int MessageCount) { ChatMessageCollection result; using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_Chat_GetLastMessages"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter<int>("@UserID", userID, SqlDbType.Int); query.CreateParameter<int>("@TargetUserID", targetUserID, SqlDbType.Int); query.CreateParameter<int>("@LastMessageID", lastMessageID, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { result = new ChatMessageCollection(); while (reader.Read()) { result.Insert(0, new ChatMessage(reader)); } } return result; } }
public override ChatMessageCollection SendMessage(int userID, int targetUserID, string content, string ip, bool getNewMessages, int lastMessageID) { ChatMessageCollection messages = new ChatMessageCollection(); using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_Chat_SendMessage"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter <int>("@UserID", userID, SqlDbType.Int); query.CreateParameter <int>("@TargetUserID", targetUserID, SqlDbType.Int); query.CreateParameter <string>("@Content", content, SqlDbType.NVarChar, 3000); query.CreateParameter <string>("@CreateIP", ip, SqlDbType.VarChar, 50); query.CreateParameter <bool>("@GetNewMessages", getNewMessages, SqlDbType.Bit); query.CreateParameter <int>("@LastMessageID", lastMessageID, SqlDbType.Int); if (getNewMessages) { using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { messages.Insert(0, new ChatMessage(reader)); } } } else { query.ExecuteNonQuery(); } } return(messages); }
public override ChatMessageCollection SendMessage(int userID, int targetUserID, string content, string ip, bool getNewMessages, int lastMessageID) { ChatMessageCollection messages = new ChatMessageCollection(); using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_Chat_SendMessage"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter<int>("@UserID", userID, SqlDbType.Int); query.CreateParameter<int>("@TargetUserID", targetUserID, SqlDbType.Int); query.CreateParameter<string>("@Content", content, SqlDbType.NVarChar, 3000); query.CreateParameter<string>("@CreateIP", ip, SqlDbType.VarChar, 50); query.CreateParameter<bool>("@GetNewMessages", getNewMessages, SqlDbType.Bit); query.CreateParameter<int>("@LastMessageID", lastMessageID, SqlDbType.Int); if (getNewMessages) { using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) messages.Insert(0, new ChatMessage(reader)); } } else query.ExecuteNonQuery(); } return messages; }