Exemplo n.º 1
0
        protected List <AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
        {
            List <AvatarPickerAvatar> pickerlist = new List <AvatarPickerAvatar>();
            int  pickercount = Convert.ToInt32((string)data["avcount"]);
            UUID respqueryID = new UUID((string)data["queryid"]);

            if (queryID == respqueryID)
            {
                for (int i = 0; i < pickercount; i++)
                {
                    AvatarPickerAvatar apicker = new AvatarPickerAvatar();
                    UUID   avatarID            = new UUID((string)data["avatarid" + i.ToString()]);
                    string firstname           = (string)data["firstname" + i.ToString()];
                    string lastname            = (string)data["lastname" + i.ToString()];
                    apicker.AvatarID  = avatarID;
                    apicker.firstName = firstname;
                    apicker.lastName  = lastname;
                    pickerlist.Add(apicker);
                }
            }
            else
            {
                m_log.Warn("[OGS1 USER SERVICES]: Got invalid queryID from userServer");
            }
            return(pickerlist);
        }
Exemplo n.º 2
0
        override public List <AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
        {
            List <AvatarPickerAvatar> results = new List <AvatarPickerAvatar>();

            string[] querysplit;
            querysplit = query.Split(' ');

            if (querysplit.Length == 2)
            {
                ICriteria criteria = manager.GetSession().CreateCriteria(typeof(UserProfileData));
                criteria.Add(Expression.Like("FirstName", querysplit[0]));
                criteria.Add(Expression.Like("SurName", querysplit[1]));

                foreach (UserProfileData profile in criteria.List())
                {
                    AvatarPickerAvatar user = new AvatarPickerAvatar();
                    user.AvatarID  = profile.ID;
                    user.firstName = profile.FirstName;
                    user.lastName  = profile.SurName;
                    results.Add(user);
                }
            }

            return(results);
        }
Exemplo n.º 3
0
        public override List <AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
        {
            List <AvatarPickerAvatar> returnlist = new List <AvatarPickerAvatar>();

            Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");

            string[] querysplit;
            querysplit = query.Split(' ');
            if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty)
            {
                Dictionary <string, object> param = new Dictionary <string, object>();
                param["?first"]  = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
                param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
                MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults");

                try
                {
                    IDbCommand result =
                        dbm.Manager.Query(
                            "SELECT UUID,username,lastname FROM " + m_usersTableName +
                            " WHERE username like ?first AND lastname like ?second LIMIT 100",
                            param);
                    IDataReader reader = result.ExecuteReader();

                    while (reader.Read())
                    {
                        AvatarPickerAvatar user = new AvatarPickerAvatar();
                        user.AvatarID  = new UUID((string)reader["UUID"]);
                        user.firstName = (string)reader["username"];
                        user.lastName  = (string)reader["lastname"];
                        returnlist.Add(user);
                    }
                    reader.Dispose();
                    result.Dispose();
                }
                catch (Exception e)
                {
                    dbm.Manager.Reconnect();
                    m_log.Error(e.ToString());
                    return(returnlist);
                }
                finally
                {
                    dbm.Release();
                }
            }
            else
            {
                MySQLSuperManager dbm = GetLockedConnection("GeneratePickerResults");

                try
                {
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";

                    IDbCommand result =
                        dbm.Manager.Query(
                            "SELECT UUID,username,lastname FROM " + m_usersTableName +
                            " WHERE username like ?first OR lastname like ?first LIMIT 100",
                            param);
                    IDataReader reader = result.ExecuteReader();

                    while (reader.Read())
                    {
                        AvatarPickerAvatar user = new AvatarPickerAvatar();
                        user.AvatarID  = new UUID((string)reader["UUID"]);
                        user.firstName = (string)reader["username"];
                        user.lastName  = (string)reader["lastname"];
                        returnlist.Add(user);
                    }
                    reader.Dispose();
                    result.Dispose();
                }
                catch (Exception e)
                {
                    dbm.Manager.Reconnect();
                    m_log.Error(e.ToString());
                    return(returnlist);
                }
                finally
                {
                    dbm.Release();
                }
            }
            return(returnlist);
        }