Mantis#1796. Thank you kindly, StrawberryFride for a patch that:
Agent table code (INSERT / UPDATE, etc) now added to MSSQL provider.0.6.0-stable
parent
09641bd999
commit
681433c4b7
|
@ -354,7 +354,7 @@ namespace OpenSim.Data.MSSQL
|
||||||
// Agent Who?
|
// Agent Who?
|
||||||
retval.AgentIP = (string)reader["agentIP"];
|
retval.AgentIP = (string)reader["agentIP"];
|
||||||
retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString());
|
retval.AgentPort = Convert.ToUInt32(reader["agentPort"].ToString());
|
||||||
retval.AgentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
|
retval.AgentOnline = Convert.ToInt32(reader["agentOnline"].ToString()) != 0;
|
||||||
|
|
||||||
// Login/Logout times (UNIX Epoch)
|
// Login/Logout times (UNIX Epoch)
|
||||||
retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString());
|
retval.LoginTime = Convert.ToInt32(reader["loginTime"].ToString());
|
||||||
|
@ -528,5 +528,63 @@ namespace OpenSim.Data.MSSQL
|
||||||
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
|
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
|
||||||
dllVersion.Revision);
|
dllVersion.Revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool insertAgentRow(UserAgentData agentdata)
|
||||||
|
{
|
||||||
|
string sql = @"
|
||||||
|
|
||||||
|
IF EXISTS (SELECT * FROM agents WHERE UUID = @UUID)
|
||||||
|
BEGIN
|
||||||
|
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
|
||||||
|
WHERE UUID = @UUID
|
||||||
|
END
|
||||||
|
ELSE
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO
|
||||||
|
agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos) VALUES
|
||||||
|
(@UUID, @sessionID, @secureSessionID, @agentIP, @agentPort, @agentOnline, @loginTime, @logoutTime, @currentRegion, @currentHandle, @currentPos)
|
||||||
|
END
|
||||||
|
";
|
||||||
|
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
parameters["@UUID"] = agentdata.ProfileID.ToString();
|
||||||
|
parameters["@sessionID"] = agentdata.SessionID.ToString();
|
||||||
|
parameters["@secureSessionID"] = agentdata.SecureSessionID.ToString();
|
||||||
|
parameters["@agentIP"] = agentdata.AgentIP.ToString();
|
||||||
|
parameters["@agentPort"] = agentdata.AgentPort.ToString();
|
||||||
|
parameters["@agentOnline"] = (agentdata.AgentOnline == true) ? "1" : "0";
|
||||||
|
parameters["@loginTime"] = agentdata.LoginTime.ToString();
|
||||||
|
parameters["@logoutTime"] = agentdata.LogoutTime.ToString();
|
||||||
|
parameters["@currentRegion"] = agentdata.Region.ToString();
|
||||||
|
parameters["@currentHandle"] = agentdata.Handle.ToString();
|
||||||
|
parameters["@currentPos"] = "<" + ((int)agentdata.Position.X).ToString() + "," + ((int)agentdata.Position.Y).ToString() + "," + ((int)agentdata.Position.Z).ToString() + ">";
|
||||||
|
|
||||||
|
|
||||||
|
using (IDbCommand result = Query(sql, parameters))
|
||||||
|
{
|
||||||
|
result.Transaction = result.Connection.BeginTransaction(IsolationLevel.Serializable);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (result.ExecuteNonQuery() > 0)
|
||||||
|
{
|
||||||
|
result.Transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
result.Transaction.Rollback();
|
||||||
|
m_log.Error(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,7 +610,14 @@ namespace OpenSim.Data.MSSQL
|
||||||
/// <param name="agent">The agent to create</param>
|
/// <param name="agent">The agent to create</param>
|
||||||
override public void AddNewUserAgent(UserAgentData agent)
|
override public void AddNewUserAgent(UserAgentData agent)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
try
|
||||||
|
{
|
||||||
|
database.insertAgentRow(agent);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error(e.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -190,28 +190,15 @@ namespace OpenSim.Grid.UserServer
|
||||||
{
|
{
|
||||||
// ulong cregionhandle = 0;
|
// ulong cregionhandle = 0;
|
||||||
LLUUID regionUUID = LLUUID.Zero;
|
LLUUID regionUUID = LLUUID.Zero;
|
||||||
LLUUID AvatarID = LLUUID.Zero;
|
LLUUID avatarUUID = LLUUID.Zero;
|
||||||
|
|
||||||
Helpers.TryParse((string)requestData["avatar_id"], out AvatarID);
|
Helpers.TryParse((string)requestData["avatar_id"], out avatarUUID);
|
||||||
Helpers.TryParse((string)requestData["region_uuid"], out regionUUID);
|
Helpers.TryParse((string)requestData["region_uuid"], out regionUUID);
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// cregionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
|
|
||||||
// }
|
|
||||||
// catch (ArgumentException)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// catch (OverflowException)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// catch (FormatException)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (AvatarID != LLUUID.Zero)
|
if (avatarUUID != LLUUID.Zero)
|
||||||
{
|
{
|
||||||
UserProfileData userProfile = GetUserProfile(new LLUUID((string)requestData["avatar_id"]));
|
UserProfileData userProfile = GetUserProfile(avatarUUID);
|
||||||
userProfile.CurrentAgent.Region = new LLUUID((string)requestData["region_uuid"]);
|
userProfile.CurrentAgent.Region = regionUUID;
|
||||||
userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
|
userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
|
||||||
//userProfile.CurrentAgent.
|
//userProfile.CurrentAgent.
|
||||||
CommitAgent(ref userProfile);
|
CommitAgent(ref userProfile);
|
||||||
|
|
Loading…
Reference in New Issue