public override void SaveUserPreferences(UserPreferencesData userPrefs) { try { Dictionary<string, object> parms = new Dictionary<string, object>(); parms["?user_id"] = userPrefs.UserId; // RetrieveUserPreferences tests for "0" and "1" parms["?recv_ims_via_email"] = userPrefs.ReceiveIMsViaEmail ? "1" : "0"; parms["?listed_in_directory"] = userPrefs.ListedInDirectory ? "1" : "0"; using (ISimpleDB conn = _connFactory.GetConnection()) { string query = "INSERT INTO userpreferences(user_id, recv_ims_via_email, listed_in_directory) "; query += "VALUES (?user_id, ?recv_ims_via_email, ?listed_in_directory) "; query += "ON DUPLICATE KEY UPDATE user_id=VALUES(user_id), recv_ims_via_email=VALUES(recv_ims_via_email), listed_in_directory=VALUES(listed_in_directory) "; conn.QueryNoResults(query, parms); } } catch (Exception e) { m_log.Error("[MySQLUserData.InWorldz]: Could not save user preferences: " + e.ToString()); } }
public abstract void SaveUserPreferences(UserPreferencesData userPrefs);
/// <summary> /// Returns the default set of preferences and marks them as being owned by the given user /// </summary> /// <param name="userId"></param> /// <returns></returns> public static UserPreferencesData GetDefaultPreferences(UUID userId) { UserPreferencesData defaultPrefs = new UserPreferencesData(userId, true, false); return defaultPrefs; }
public override UserPreferencesData RetrieveUserPreferences(UUID userId) { try { Dictionary<string, object> parms = new Dictionary<string, object>(); parms["?userId"] = userId; using (ISimpleDB conn = _connFactory.GetConnection()) { string query = "SELECT * FROM userpreferences WHERE user_id = ?userId"; List<Dictionary<string, string>> results = conn.QueryWithResults(query, parms); if (results.Count > 0) { UserPreferencesData foundPrefs = new UserPreferencesData(userId, Util.String2Bool(results[0]["recv_ims_via_email"]), Util.String2Bool(results[0]["listed_in_directory"])); return foundPrefs; } else { return UserPreferencesData.GetDefaultPreferences(userId); } } } catch (Exception e) { m_log.Error("[MySQLUserData.InWorldz]: Could not retrieve user preferences: " + e.ToString()); return null; } }
public UserPreferencesData RetrieveUserPreferences(UUID userId) { Hashtable param = new Hashtable(); param["userId"] = userId.ToString(); IList parameters = new ArrayList(); parameters.Add(param); string methodName = "get_user_preferences"; XmlRpcRequest req = new XmlRpcRequest(methodName, parameters); XmlRpcResponse resp = req.Send(Util.XmlRpcRequestURI(m_commsManager.NetworkServersInfo.UserURL, methodName), 8000); Hashtable respData = (Hashtable)resp.Value; if (respData.Contains("error_type")) { if ((string)respData["error_type"] != "unknown_user") m_log.Warn("[GRID]: " + "Error sent by user server when trying to get user preferences: (" + respData["error_type"] + "): " + respData["error_desc"]); return null; } else { UserPreferencesData prefs = new UserPreferencesData(userId, ((string)respData["recvIMsViaEmail"]) == "1" ? true : false, ((string)respData["listedInDirectory"]) == "1" ? true : false); return prefs; } }
public void SaveUserPreferences(UserPreferencesData userPrefs) { Hashtable param = new Hashtable(); param["userId"] = userPrefs.UserId.ToString(); param["recvIMsViaEmail"] = userPrefs.ReceiveIMsViaEmail ? "1" : "0"; param["listedInDirectory"] = userPrefs.ListedInDirectory ? "1" : "0"; IList parameters = new ArrayList(); parameters.Add(param); string methodName = "save_user_preferences"; XmlRpcRequest req = new XmlRpcRequest(methodName, parameters); XmlRpcResponse resp = req.Send(Util.XmlRpcRequestURI(m_commsManager.NetworkServersInfo.UserURL, methodName), 3000); Hashtable respData = (Hashtable)resp.Value; if (respData == null || !respData.Contains("returnString") || ((string) respData["returnString"] != "OK")) { m_log.Warn("[OGS1 USER SERVICES]: Got invalid response to preference save from user server"); } }
/// <summary> /// Returns the default set of preferences and marks them as being owned by the given user /// </summary> /// <param name="userId"></param> /// <returns></returns> public static UserPreferencesData GetDefaultPreferences(UUID userId) { UserPreferencesData defaultPrefs = new UserPreferencesData(userId, true, false); return(defaultPrefs); }