public override ArrayList LoadUsers() { ArrayList retUsers = new ArrayList(); try { string s = @"<?xml version=""1.0"" encoding=""utf-8""?> <request version=""2.71828""> <function name=""LoadUsers""> <argument>" + BotName + @"</argument> </function> </request> "; XmlDocument dataDoc = GetDataDocument(s); XmlNodeList userList = dataDoc.SelectNodes(@"/users/user"); if (userList == null) { // yeah, we neeed exceptions return(retUsers); } foreach (XmlNode userNode in userList) { Hashtable userinfo = new Hashtable(); ArrayList contacts = new ArrayList(); foreach (XmlNode userElementNode in userNode.ChildNodes) { if (userElementNode.Name.ToLower() != "contact") { userinfo[userElementNode.Name.ToLower()] = userElementNode.InnerText; } else { XmlDocument tempDoc = new XmlDocument(); tempDoc.LoadXml(userElementNode.OuterXml); XmlNode serviceNode = tempDoc.SelectSingleNode(@"/contact/service"); if (serviceNode == null) { // ignore this of throw an exception? ignore it for now continue; } XmlNode loginNode = tempDoc.SelectSingleNode(@"/contact/login"); if (loginNode == null) { // same as above? continue; } IMContact cont = new IMContact( loginNode.InnerText, (ConnectionType)Enum.Parse(typeof(ConnectionType), serviceNode.InnerText, true), contacts.Count); contacts.Add(cont); } } UserClassType uct = new UserClassType(); uct = (UserClassType)Enum.Parse(typeof(UserClassType), userinfo["class"].ToString(), true); User newUser = new User( int.Parse(userinfo[@"userid"].ToString()), userinfo[@"username"].ToString(), userinfo[@"email"].ToString(), uct, userinfo[@"timezone"].ToString(), userinfo[@"dls"].ToString() == @"1", int.Parse(userinfo[@"plan"].ToString()), int.Parse(userinfo[@"num_reminders"].ToString()), int.Parse(userinfo[@"num_ptp_reminders"].ToString()), userinfo[@"bot"].ToString()); newUser.Contacts = contacts; retUsers.Add(newUser); } } catch (Exception ex) { } return(retUsers); }
public void AddContact(IMContact cont) { _contacts.Add(cont); }