* MySQL Inventory data interfaces written - can now write an inventory server (yay!)

zircon^2
Adam Frisby 2007-06-01 18:58:20 +00:00
parent c60166f3c3
commit 30f810a03e
2 changed files with 73 additions and 2 deletions

View File

@ -194,7 +194,10 @@ namespace OpenGrid.Framework.Data.MySQL
public void addInventoryItem(InventoryItemBase item) public void addInventoryItem(InventoryItemBase item)
{ {
lock (database)
{
database.insertItem(item);
}
} }
public void updateInventoryItem(InventoryItemBase item) public void updateInventoryItem(InventoryItemBase item)
@ -204,7 +207,10 @@ namespace OpenGrid.Framework.Data.MySQL
public void addInventoryFolder(InventoryFolderBase folder) public void addInventoryFolder(InventoryFolderBase folder)
{ {
lock (database)
{
database.insertFolder(folder);
}
} }
public void updateInventoryFolder(InventoryFolderBase folder) public void updateInventoryFolder(InventoryFolderBase folder)

View File

@ -377,6 +377,71 @@ namespace OpenGrid.Framework.Data.MySQL
return returnval; return returnval;
} }
public bool insertItem(InventoryItemBase item)
{
string sql = "REPLACE INTO inventoryitems (inventoryID, assetID, type, parentFolderID, avatarID, inventoryName, inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions) VALUES ";
sql += "(?inventoryID, ?assetID, ?type, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription, ?inventoryNextPermissions, ?inventoryCurrentPermissions)";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["?inventoryID"] = item.inventoryID.ToStringHyphenated();
parameters["?assetID"] = item.assetID.ToStringHyphenated();
parameters["?type"] = item.type.ToString();
parameters["?parentFolderID"] = item.parentFolderID.ToStringHyphenated();
parameters["?avatarID"] = item.avatarID.ToStringHyphenated();
parameters["?inventoryName"] = item.inventoryName;
parameters["?inventoryDescription"] = item.inventoryDescription;
parameters["?inventoryNextPermissions"] = item.inventoryNextPermissions.ToString();
parameters["?inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString();
bool returnval = false;
try
{
IDbCommand result = Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
return returnval;
}
public bool insertFolder(InventoryFolderBase folder)
{
string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName) VALUES ";
sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName)";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["?folderID"] = folder.folderID.ToStringHyphenated();
parameters["?agentID"] = folder.agentID.ToStringHyphenated();
parameters["?parentFolderID"] = folder.parentID.ToStringHyphenated();
parameters["?folderName"] = folder.name;
bool returnval = false;
try
{
IDbCommand result = Query(sql, parameters);
if (result.ExecuteNonQuery() == 1)
returnval = true;
result.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
return returnval;
}
public bool insertRow(SimProfileData profile) public bool insertRow(SimProfileData profile)
{ {
string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";