Пример #1
0
        /// <summary>
        /// Generates the room data.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <returns>RoomData.</returns>
        internal RoomData GenerateRoomData(uint roomId)
        {
            if (LoadedRoomData.ContainsKey(roomId))
            {
                LoadedRoomData[roomId].LastUsed = DateTime.Now;
                return LoadedRoomData[roomId];
            }

            var roomData = new RoomData();

            if (LoadedRooms.ContainsKey(roomId))
                return GetRoom(roomId).RoomData;

            using (var queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Format("SELECT * FROM rooms_data WHERE id = {0} LIMIT 1", roomId));

                DataRow dataRow = queryReactor.GetRow();
                if (dataRow == null)
                    return null;

                roomData.Fill(dataRow);
            }

            LoadedRoomData.TryAdd(roomId, roomData);

            return roomData;
        }
Пример #2
0
 /// <summary>
 /// Fetches the room data.
 /// </summary>
 /// <param name="roomId">The room identifier.</param>
 /// <param name="dRow">The d row.</param>
 /// <returns>RoomData.</returns>
 internal RoomData FetchRoomData(uint roomId, DataRow dRow)
 {
     if (LoadedRoomData.ContainsKey(roomId))
     {
         LoadedRoomData[roomId].LastUsed = DateTime.Now;
         return LoadedRoomData[roomId];
     }
     var roomData = new RoomData();
     roomData.Fill(dRow);
     LoadedRoomData.TryAdd(roomId, roomData);
     return roomData;
 }