/// <summary> /// Gets the y value. /// </summary> /// <returns>System.Double.</returns> internal double GetYValue() { return(TextHandling.Combine(lengthX, lengthY)); }
/// <summary> /// Generates the database shit. /// </summary> /// <returns>System.String.</returns> internal string GenerateDbShit() { return("x: " + TextHandling.Combine(widthX, widthY) + " y: " + TextHandling.Combine(lengthX, lengthY)); }
/// <summary> /// Gets the x value. /// </summary> /// <returns>System.Double.</returns> internal double GetXValue() { return(TextHandling.Combine(widthX, widthY)); }
internal void SaveFurniture(IQueryAdapter dbClient) { try { if (mAddedItems.Count > 0 || mRemovedItems.Count > 0 || mMovedItems.Count > 0 || room.GetRoomUserManager().PetCount > 0) { QueryChunk standardQueries = new QueryChunk(); QueryChunk itemInserts = new QueryChunk("REPLACE INTO items_rooms (item_id,room_id,x,y,n) VALUES "); QueryChunk extradataInserts = new QueryChunk("REPLACE INTO items_extradata (item_id,data_type,data) VALUES "); foreach (RoomItem Item in mRemovedItems.Values) { standardQueries.AddQuery("DELETE FROM items_rooms WHERE item_id = " + Item.Id + " AND room_id = " + room.RoomId); //Do join + function } if (mAddedItems.Count > 0) { foreach (RoomItem Item in mAddedItems.Values) { //if (!string.IsNullOrEmpty((string)Item.data.GetData())) { extradataInserts.AddQuery("(" + Item.Id + ",@data_type_id" + Item.Id + ",@data_id" + Item.Id + ")"); extradataInserts.AddParameter("@data_type_id" + Item.Id, Item.data.GetTypeID()); extradataInserts.AddParameter("@data_id" + Item.Id, Item.data.ToString()); } if (Item.IsFloorItem) { double combinedCoords = TextHandling.Combine(Item.GetX, Item.GetY); itemInserts.AddQuery("(" + Item.Id + "," + Item.RoomId + "," + TextHandling.GetString(combinedCoords) + "," + TextHandling.GetString(Item.GetZ) + "," + Item.Rot + ")"); } else { itemInserts.AddQuery("(" + Item.Id + "," + Item.RoomId + "," + TextHandling.GetString(Item.wallCoord.GetXValue()) + "," + TextHandling.GetString(Item.wallCoord.GetYValue()) + "," + Item.wallCoord.n() + ")"); } } } foreach (RoomItem Item in mMovedItems.Values) { //if (!string.IsNullOrEmpty((string)Item.data.GetData())) { extradataInserts.AddQuery("(" + Item.Id + ",@data_type_id" + Item.Id + ",@data_id" + Item.Id + ")"); extradataInserts.AddParameter("@data_type_id" + Item.Id, Item.data.GetTypeID()); extradataInserts.AddParameter("@data_id" + Item.Id, Item.data.ToString()); //standardQueries.AddQuery("UPDATE items_extradata SET data = @data" + Item.Id + " WHERE item_id = " + Item.Id); //standardQueries.AddParameter("data" + Item.Id, ((StringData)Item.data).Data); } if (Item.IsWallItem) { standardQueries.AddQuery("UPDATE items_rooms SET x=" + TextHandling.GetString(Item.wallCoord.GetXValue()) + ", y=" + TextHandling.GetString(Item.wallCoord.GetYValue()) + ", n=" + Item.wallCoord.n() + " WHERE item_id = " + Item.Id); } else { double combinedCoords = TextHandling.Combine(Item.GetX, Item.GetY); standardQueries.AddQuery("UPDATE items_rooms SET x=" + TextHandling.GetString(combinedCoords) + ", y=" + TextHandling.GetString(Item.GetZ) + ", n=" + Item.Rot + " WHERE item_id = " + Item.Id); } } //room.GetRoomUserManager().AppendPetsUpdateString(dbClient); mAddedItems.Clear(); mRemovedItems.Clear(); mMovedItems.Clear(); standardQueries.Execute(dbClient); itemInserts.Execute(dbClient); extradataInserts.Execute(dbClient); standardQueries.Dispose(); itemInserts.Dispose(); extradataInserts.Dispose(); standardQueries = null; itemInserts = null; extradataInserts = null; } } catch (Exception e) { Logging.LogCriticalException("Error during saving furniture for room " + room.RoomId + ". Stack: " + e.ToString()); } }