public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
//sendData["SCOPEID"] = scopeID.ToString();
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "getaccounts";
sendData["ScopeID"] = scopeID.ToString();
sendData["query"] = query;
string reply = string.Empty;
string reqString = ServerUtils.BuildQueryString(sendData);
// m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/accounts",
reqString);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply");
return null;
}
}
catch (Exception e)
{
m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting accounts server: {0}", e.Message);
}
List<UserAccount> accounts = new List<UserAccount>();
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData != null)
{
if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null")
{
return accounts;
}
Dictionary<string, object>.ValueCollection accountList = replyData.Values;
//m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
foreach (object acc in accountList)
{
if (acc is Dictionary<string, object>)
{
UserAccount pinfo = new UserAccount((Dictionary<string, object>)acc);
accounts.Add(pinfo);
}
else
m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received invalid response type {0}",
acc.GetType());
}
}
else
m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccounts received null response");
return accounts;
}