From c60166f3c3c73e25a1bd5a2a3e6f0fab0ae738bf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 1 Jun 2007 18:36:26 +0000 Subject: * Completed read-only inventory data operations * Working on write support --- .../MySQLInventoryData.cs | 160 ++++++++++++++++++++- .../OpenGrid.Framework.Data/InventoryData.cs | 24 ++++ 2 files changed, 179 insertions(+), 5 deletions(-) diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs index 72c0139..48d8e93 100644 --- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLInventoryData.cs @@ -39,27 +39,177 @@ namespace OpenGrid.Framework.Data.MySQL public List getInventoryInFolder(LLUUID folderID) { - return null; + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = folderID.ToStringHyphenated(); + + System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param); + System.Data.IDataReader reader = result.ExecuteReader(); + + List items = database.readInventoryItems(reader); + + reader.Close(); + result.Dispose(); + + return items; + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } } public List getUserRootFolders(LLUUID user) { - return null; + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = user.ToStringHyphenated(); + param["?zero"] = LLUUID.Zero.ToStringHyphenated(); + + System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); + System.Data.IDataReader reader = result.ExecuteReader(); + + List items = database.readInventoryFolders(reader); + + reader.Close(); + result.Dispose(); + + return items; + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } } public List getInventoryFolders(LLUUID parentID) { - return null; + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = parentID.ToStringHyphenated(); + + System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param); + System.Data.IDataReader reader = result.ExecuteReader(); + + List items = database.readInventoryFolders(reader); + + reader.Close(); + result.Dispose(); + + return items; + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } } public InventoryItemBase getInventoryItem(LLUUID item) { - return null; + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = item.ToStringHyphenated(); + + System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param); + System.Data.IDataReader reader = result.ExecuteReader(); + + List items = database.readInventoryItems(reader); + + reader.Close(); + result.Dispose(); + + if (items.Count > 0) + { + return items[0]; + } + else + { + return null; + } + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } } public InventoryFolderBase getInventoryFolder(LLUUID folder) { - return null; + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = folder.ToStringHyphenated(); + + System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param); + System.Data.IDataReader reader = result.ExecuteReader(); + + List items = database.readInventoryFolders(reader); + + reader.Close(); + result.Dispose(); + + if (items.Count > 0) + { + return items[0]; + } + else + { + return null; + } + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } + } + + public void addInventoryItem(InventoryItemBase item) + { + + } + + public void updateInventoryItem(InventoryItemBase item) + { + addInventoryItem(item); + } + + public void addInventoryFolder(InventoryFolderBase folder) + { + + } + + public void updateInventoryFolder(InventoryFolderBase folder) + { + addInventoryFolder(folder); } } } diff --git a/OpenGridServices/OpenGrid.Framework.Data/InventoryData.cs b/OpenGridServices/OpenGrid.Framework.Data/InventoryData.cs index 2b3d826..b43557d 100644 --- a/OpenGridServices/OpenGrid.Framework.Data/InventoryData.cs +++ b/OpenGridServices/OpenGrid.Framework.Data/InventoryData.cs @@ -84,5 +84,29 @@ namespace OpenGrid.Framework.Data /// The UUID of the folder to be returned /// A class containing folder information InventoryFolderBase getInventoryFolder(LLUUID folder); + + /// + /// Creates a new inventory item based on item + /// + /// The item to be created + void addInventoryItem(InventoryItemBase item); + + /// + /// Updates an inventory item with item (updates based on ID) + /// + /// The updated item + void updateInventoryItem(InventoryItemBase item); + + /// + /// Adds a new folder specified by folder + /// + /// The inventory folder + void addInventoryFolder(InventoryFolderBase folder); + + /// + /// Updates a folder based on its ID with folder + /// + /// The inventory folder + void updateInventoryFolder(InventoryFolderBase folder); } } -- cgit v1.1