public IUserProfileInfo GetUserProfile(UUID PrincipalID) { Dictionary<string, object> sendData = new Dictionary<string, object>(); sendData["PRINCIPALID"] = PrincipalID.ToString(); sendData["METHOD"] = "getprofile"; string reqString = WebUtils.BuildXmlResponse(sendData); try { foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auroradata", reqString); if (reply != string.Empty) { Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData != null) { if (!replyData.ContainsKey("result")) return null; IUserProfileInfo profile = null; foreach (object f in replyData.Values) { if (f is Dictionary<string, object>) { profile = new IUserProfileInfo(); profile.FromKVP((Dictionary<string, object>)f); } else m_log.DebugFormat("[AuroraRemoteProfileConnector]: GetProfile {0} received invalid response type {1}", PrincipalID, f.GetType()); } // Success return profile; } else m_log.DebugFormat("[AuroraRemoteProfileConnector]: GetProfile {0} received null response", PrincipalID); } } } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString()); } return null; }
protected void HandleLoadAvatarProfile(string[] cmdparams) { if (cmdparams.Length != 6) { m_log.Info("[AvatarProfileArchiver] Not enough parameters!"); return; } StreamReader reader = new StreamReader(cmdparams[5]); string document = reader.ReadToEnd(); reader.Close(); reader.Dispose(); string[] lines = document.Split('\n'); List<string> file = new List<string>(lines); Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(file[1]); Dictionary<string, object> results = replyData["result"] as Dictionary<string, object>; UserAccount UDA = new UserAccount(); UDA.Name = cmdparams[3] + cmdparams[4]; UDA.PrincipalID = UUID.Random(); UDA.ScopeID = UUID.Zero; UDA.UserFlags = int.Parse(results["UserFlags"].ToString()); UDA.UserLevel = 0; //For security... Don't want everyone loading full god mode. UDA.UserTitle = results["UserTitle"].ToString(); UDA.Email = results["Email"].ToString(); UDA.Created = int.Parse(results["Created"].ToString()); UserAccountService.StoreUserAccount(UDA); replyData = WebUtils.ParseXmlResponse(file[2]); IUserProfileInfo UPI = new IUserProfileInfo(); UPI.FromKVP(replyData["result"] as Dictionary<string, object>); //Update the principle ID to the new user. UPI.PrincipalID = UDA.PrincipalID; IProfileConnector profileData = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector>(); if (profileData.GetUserProfile(UPI.PrincipalID) == null) profileData.CreateNewProfile(UPI.PrincipalID); profileData.UpdateUserProfile(UPI); m_log.Info("[AvatarProfileArchiver] Loaded Avatar Profile from " + cmdparams[5]); }
public byte[] UpdateProfile(Dictionary<string, object> request) { Dictionary<string, object> result = new Dictionary<string, object>(); UUID principalID = UUID.Zero; if (request.ContainsKey("PRINCIPALID")) UUID.TryParse(request["PRINCIPALID"].ToString(), out principalID); else { m_log.WarnFormat("[AuroraDataServerPostHandler]: no principalID in request to get profile"); result["result"] = "null"; string FailedxmlString = WebUtils.BuildXmlResponse(result); m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", FailedxmlString); UTF8Encoding Failedencoding = new UTF8Encoding(); return Failedencoding.GetBytes(FailedxmlString); } IUserProfileInfo UserProfile = new IUserProfileInfo(); UserProfile.FromKVP(request); ProfileConnector.UpdateUserProfile(UserProfile); result["result"] = "Successful"; string xmlString = WebUtils.BuildXmlResponse(result); //m_log.DebugFormat("[AuroraDataServerPostHandler]: resp string: {0}", xmlString); UTF8Encoding encoding = new UTF8Encoding(); return encoding.GetBytes(xmlString); }
protected void HandleLoadAvatarProfile(string module, string[] cmdparams) { if (cmdparams.Length != 6) { m_log.Debug("[AvatarProfileArchiver] Not enough parameters!"); return; } StreamReader reader = new StreamReader(cmdparams[5]); string document = reader.ReadToEnd(); string[] lines = document.Split('\n'); List<string> file = new List<string>(lines); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(file[1]); Dictionary<string, object> results = replyData["result"] as Dictionary<string, object>; UserAccount UDA = new UserAccount(); UDA.FirstName = cmdparams[3]; UDA.LastName = cmdparams[4]; UDA.PrincipalID = UUID.Random(); UDA.ScopeID = UUID.Zero; UDA.UserFlags = int.Parse(results["UserFlags"].ToString()); UDA.UserLevel = 0; //For security... Don't want everyone loading full god mode. UDA.UserTitle = ""; UDA.Email = results["Email"].ToString(); UDA.Created = int.Parse(results["Created"].ToString()); if (results.ContainsKey("ServiceURLs") && results["ServiceURLs"] != null) { UDA.ServiceURLs = new Dictionary<string, object>(); string str = results["ServiceURLs"].ToString(); if (str != string.Empty) { string[] parts = str.Split(new char[] { ';' }); Dictionary<string, object> dic = new Dictionary<string, object>(); foreach (string s in parts) { string[] parts2 = s.Split(new char[] { '*' }); if (parts2.Length == 2) UDA.ServiceURLs[parts2[0]] = parts2[1]; } } } m_scene.UserAccountService.StoreUserAccount(UDA); replyData = ServerUtils.ParseXmlResponse(file[2]); IUserProfileInfo UPI = new IUserProfileInfo(); UPI.FromKVP(replyData["result"] as Dictionary<string, object>); //Update the principle ID to the new user. UPI.PrincipalID = UDA.PrincipalID; IProfileConnector profileData = DataManager.DataManager.RequestPlugin<IProfileConnector>(); if (profileData.GetUserProfile(UPI.PrincipalID) == null) profileData.CreateNewProfile(UPI.PrincipalID); profileData.UpdateUserProfile(UPI); reader.Close(); reader.Dispose(); m_log.Debug("[AvatarProfileArchiver] Loaded Avatar Profile from " + cmdparams[5]); }