* Completed read-only inventory data operations

* Working on write support
zircon^2
Adam Frisby 2007-06-01 18:36:26 +00:00
parent 931adbcc43
commit c60166f3c3
2 changed files with 179 additions and 5 deletions

View File

@ -39,27 +39,177 @@ namespace OpenGrid.Framework.Data.MySQL
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
{
return null;
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = folderID.ToStringHyphenated();
System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param);
System.Data.IDataReader reader = result.ExecuteReader();
List<InventoryItemBase> items = database.readInventoryItems(reader);
reader.Close();
result.Dispose();
return items;
}
}
catch (Exception e)
{
database.Reconnect();
Console.WriteLine(e.ToString());
return null;
}
}
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
{
return null;
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
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<InventoryFolderBase> items = database.readInventoryFolders(reader);
reader.Close();
result.Dispose();
return items;
}
}
catch (Exception e)
{
database.Reconnect();
Console.WriteLine(e.ToString());
return null;
}
}
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
{
return null;
try
{
lock (database)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = parentID.ToStringHyphenated();
System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param);
System.Data.IDataReader reader = result.ExecuteReader();
List<InventoryFolderBase> 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<string, string> param = new Dictionary<string, string>();
param["?uuid"] = item.ToStringHyphenated();
System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param);
System.Data.IDataReader reader = result.ExecuteReader();
List<InventoryItemBase> 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<string, string> param = new Dictionary<string, string>();
param["?uuid"] = folder.ToStringHyphenated();
System.Data.IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param);
System.Data.IDataReader reader = result.ExecuteReader();
List<InventoryFolderBase> 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);
}
}
}

View File

@ -84,5 +84,29 @@ namespace OpenGrid.Framework.Data
/// <param name="folder">The UUID of the folder to be returned</param>
/// <returns>A class containing folder information</returns>
InventoryFolderBase getInventoryFolder(LLUUID folder);
/// <summary>
/// Creates a new inventory item based on item
/// </summary>
/// <param name="item">The item to be created</param>
void addInventoryItem(InventoryItemBase item);
/// <summary>
/// Updates an inventory item with item (updates based on ID)
/// </summary>
/// <param name="item">The updated item</param>
void updateInventoryItem(InventoryItemBase item);
/// <summary>
/// Adds a new folder specified by folder
/// </summary>
/// <param name="folder">The inventory folder</param>
void addInventoryFolder(InventoryFolderBase folder);
/// <summary>
/// Updates a folder based on its ID with folder
/// </summary>
/// <param name="folder">The inventory folder</param>
void updateInventoryFolder(InventoryFolderBase folder);
}
}