diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLManager.cs | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs index fe4ca77..9cd9eca 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/MSSQL/MSSQLManager.cs | |||
@@ -354,7 +354,7 @@ namespace OpenSim.Data.MSSQL | |||
354 | // Agent Who? | 354 | // Agent Who? |
355 | retval.AgentIP = (string)reader["agentIP"]; | 355 | retval.AgentIP = (string)reader["agentIP"]; |
356 | retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | 356 | retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString()); |
357 | retval.AgentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); | 357 | retval.AgentOnline = Convert.ToInt32(reader["agentOnline"].ToString()) != 0; |
358 | 358 | ||
359 | // Login/Logout times (UNIX Epoch) | 359 | // Login/Logout times (UNIX Epoch) |
360 | retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString()); | 360 | retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString()); |
@@ -528,5 +528,63 @@ namespace OpenSim.Data.MSSQL | |||
528 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, | 528 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, |
529 | dllVersion.Revision); | 529 | dllVersion.Revision); |
530 | } | 530 | } |
531 | |||
532 | public bool insertAgentRow(UserAgentData agentdata) | ||
533 | { | ||
534 | string sql = @" | ||
535 | |||
536 | IF EXISTS (SELECT * FROM agents WHERE UUID = @UUID) | ||
537 | BEGIN | ||
538 | UPDATE agents SET UUID = @UUID, sessionID = @sessionID, secureSessionID = @secureSessionID, agentIP = @agentIP, agentPort = @agentPort, agentOnline = @agentOnline, loginTime = @loginTime, logoutTime = @logoutTime, currentRegion = @currentRegion, currentHandle = @currentHandle, currentPos = @currentPos | ||
539 | WHERE UUID = @UUID | ||
540 | END | ||
541 | ELSE | ||
542 | BEGIN | ||
543 | INSERT INTO | ||
544 | agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES | ||
545 | (@UUID, @sessionID, @secureSessionID, @agentIP, @agentPort, @agentOnline, @loginTime, @logoutTime, @currentRegion, @currentHandle, @currentPos) | ||
546 | END | ||
547 | "; | ||
548 | |||
549 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
550 | |||
551 | parameters["@UUID"] = agentdata.ProfileID.ToString(); | ||
552 | parameters["@sessionID"] = agentdata.SessionID.ToString(); | ||
553 | parameters["@secureSessionID"] = agentdata.SecureSessionID.ToString(); | ||
554 | parameters["@agentIP"] = agentdata.AgentIP.ToString(); | ||
555 | parameters["@agentPort"] = agentdata.AgentPort.ToString(); | ||
556 | parameters["@agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0"; | ||
557 | parameters["@loginTime"] = agentdata.LoginTime.ToString(); | ||
558 | parameters["@logoutTime"] = agentdata.LogoutTime.ToString(); | ||
559 | parameters["@currentRegion"] = agentdata.Region.ToString(); | ||
560 | parameters["@currentHandle"] = agentdata.Handle.ToString(); | ||
561 | parameters["@currentPos"] = "<" + ((int)agentdata.Position.X).ToString() + "," + ((int)agentdata.Position.Y).ToString() + "," + ((int)agentdata.Position.Z).ToString() + ">"; | ||
562 | |||
563 | |||
564 | using (IDbCommand result = Query(sql, parameters)) | ||
565 | { | ||
566 | result.Transaction = result.Connection.BeginTransaction(IsolationLevel.Serializable); | ||
567 | try | ||
568 | { | ||
569 | if (result.ExecuteNonQuery() > 0) | ||
570 | { | ||
571 | result.Transaction.Commit(); | ||
572 | return true; | ||
573 | } | ||
574 | else | ||
575 | { | ||
576 | result.Transaction.Rollback(); | ||
577 | return false; | ||
578 | } | ||
579 | } | ||
580 | catch (Exception e) | ||
581 | { | ||
582 | result.Transaction.Rollback(); | ||
583 | m_log.Error(e.ToString()); | ||
584 | return false; | ||
585 | } | ||
586 | } | ||
587 | |||
588 | } | ||
531 | } | 589 | } |
532 | } | 590 | } |