aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLManager.cs')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs52
1 files changed, 50 insertions, 2 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index 0410643..46fd1bc 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -397,14 +397,14 @@ namespace OpenSim.Framework.Data.MySQL
397 // Agent Who? 397 // Agent Who?
398 retval.agentIP = (string) reader["agentIP"]; 398 retval.agentIP = (string) reader["agentIP"];
399 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); 399 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
400 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); 400 retval.agentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString()));
401 401
402 // Login/Logout times (UNIX Epoch) 402 // Login/Logout times (UNIX Epoch)
403 retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); 403 retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString());
404 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); 404 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
405 405
406 // Current position 406 // Current position
407 retval.currentRegion = (string) reader["currentRegion"]; 407 retval.currentRegion = new LLUUID((string)reader["currentRegion"]);
408 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); 408 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
409 LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); 409 LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos);
410 } 410 }
@@ -859,5 +859,53 @@ namespace OpenSim.Framework.Data.MySQL
859 859
860 return returnval; 860 return returnval;
861 } 861 }
862
863 /// <summary>
864 /// Creates a new agent and inserts it into the database
865 /// </summary>
866 /// <param name="agentdata">The agent data to be inserted</param>
867 /// <returns>Success?</returns>
868 public bool insertAgentRow(UserAgentData agentdata)
869 {
870 string sql = String.Empty;
871 sql += "REPLACE INTO ";
872 sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES ";
873 sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos);";
874 Dictionary<string, string> parameters = new Dictionary<string, string>();
875
876 parameters["?UUID"] = agentdata.UUID.ToString();
877 parameters["?sessionID"] = agentdata.sessionID.ToString();
878 parameters["?secureSessionID"] = agentdata.secureSessionID.ToString();
879 parameters["?agentIP"] = agentdata.agentIP.ToString();
880 parameters["?agentPort"] = agentdata.agentPort.ToString();
881 parameters["?agentOnline"] = (agentdata.agentOnline == true) ? "1" : "0";
882 parameters["?loginTime"] = agentdata.loginTime.ToString();
883 parameters["?logoutTime"] = agentdata.logoutTime.ToString();
884 parameters["?currentRegion"] = agentdata.currentRegion.ToString();
885 parameters["?currentHandle"] = agentdata.currentHandle.ToString();
886 parameters["?currentPos"] = "<" + ((int)agentdata.currentPos.X).ToString() + "," + ((int)agentdata.currentPos.Y).ToString() + "," + ((int)agentdata.currentPos.Z).ToString() + ">";
887
888 bool returnval = false;
889
890 try
891 {
892 IDbCommand result = Query(sql, parameters);
893
894 //Console.WriteLine(result.CommandText);
895 int x;
896 if ((x = result.ExecuteNonQuery()) > 0)
897 {
898 returnval = true;
899 }
900 result.Dispose();
901 }
902 catch (Exception e)
903 {
904 m_log.Error(e.ToString());
905 return false;
906 }
907
908 return returnval;
909 }
862 } 910 }
863} 911}