Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryID"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        override public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
        {
            List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
            string[] querysplit = query.Split(' ');
            if (querysplit.Length == 2)
            {
                try
                {
                    string sql = string.Format(@"SELECT UUID,username,lastname FROM {0} 
                                                 WHERE username LIKE @first AND lastname LIKE @second", m_usersTableName);
                    using (AutoClosingSqlCommand command = database.Query(sql))
                    {
                        //Add wildcard to the search
                        command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%"));
                        command.Parameters.Add(database.CreateParameter("second", querysplit[1] + "%"));
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                AvatarPickerAvatar user = new AvatarPickerAvatar();
                                user.AvatarID = new UUID((Guid)reader["UUID"]);
                                user.firstName = (string)reader["username"];
                                user.lastName = (string)reader["lastname"];
                                returnlist.Add(user);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Error(e.ToString());
                }
            }
            else if (querysplit.Length == 1)
            {
                try
                {
                    string sql = string.Format(@"SELECT UUID,username,lastname FROM {0} 
                                                 WHERE username LIKE @first OR lastname LIKE @first", m_usersTableName);
                    using (AutoClosingSqlCommand command = database.Query(sql))
                    {
                        command.Parameters.Add(database.CreateParameter("first", querysplit[0] + "%"));

                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                AvatarPickerAvatar user = new AvatarPickerAvatar();
                                user.AvatarID = new UUID((Guid)reader["UUID"]);
                                user.firstName = (string)reader["username"];
                                user.lastName = (string)reader["lastname"];
                                returnlist.Add(user);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Error(e.ToString());
                }
            }
            return returnlist;
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryID"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        override public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
        {
            List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
            string[] querysplit;
            querysplit = query.Split(' ');
            if (querysplit.Length == 2)
            {
                using (SqliteCommand cmd = new SqliteCommand(AvatarPickerAndSQL, g_conn))
                {
                    cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
                    cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[1] + "%"));

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            AvatarPickerAvatar user = new AvatarPickerAvatar();
                            user.AvatarID = new UUID((string) reader["UUID"]);
                            user.firstName = (string) reader["username"];
                            user.lastName = (string) reader["surname"];
                            returnlist.Add(user);
                        }
                        reader.Close();
                    }
                }
            }
            else if (querysplit.Length == 1)
            {
                using (SqliteCommand cmd = new SqliteCommand(AvatarPickerOrSQL, g_conn))
                {
                    cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
                    cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[0] + "%"));

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            AvatarPickerAvatar user = new AvatarPickerAvatar();
                            user.AvatarID = new UUID((string) reader["UUID"]);
                            user.firstName = (string) reader["username"];
                            user.lastName = (string) reader["surname"];
                            returnlist.Add(user);
                        }
                        reader.Close();
                    }
                }
            }
            return returnlist;
        }
Exemple #3
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;
        }
Exemple #4
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;
 }
        private static List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(UUID queryID, Hashtable data)
        {
            try
            {

            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;

            }
            catch (Exception except)
            {
                m_log.Error("[AUTHENTICATION SERVICE]: ConvertXMLRPCDataToAvatarPickerList", except);
            }

            return null;
        }
        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) + "%";

                try
                {
                    using (ISimpleDB conn = _connFactory.GetConnection())
                    {
                        string squery = "SELECT UUID,username,lastname FROM " + m_usersTableName +
                                " WHERE username like ?first AND lastname like ?second LIMIT 100";

                        using (IDataReader reader = conn.QueryAndUseReader(squery, param))
                        {
                            while (reader.Read())
                            {
                                AvatarPickerAvatar user = new AvatarPickerAvatar();
                                user.AvatarID = new UUID(Convert.ToString(reader["UUID"]));
                                user.firstName = (string)reader["username"];
                                user.lastName = (string)reader["lastname"];
                                returnlist.Add(user);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Error(e.ToString());
                    return returnlist;
                }
            }
            else
            {
                try
                {
                    Dictionary<string, object> param = new Dictionary<string, object>();
                    param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";

                    using (ISimpleDB conn = _connFactory.GetConnection())
                    {
                        string squery = "SELECT UUID,username,lastname FROM " + m_usersTableName +
                            " WHERE username like ?first OR lastname like ?first LIMIT 100";

                        using (IDataReader reader = conn.QueryAndUseReader(squery, param))
                        {
                            while (reader.Read())
                            {
                                AvatarPickerAvatar user = new AvatarPickerAvatar();
                                user.AvatarID = new UUID(Convert.ToString(reader["UUID"]));
                                user.firstName = (string)reader["username"];
                                user.lastName = (string)reader["lastname"];
                                returnlist.Add(user);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Error(e.ToString());
                    return returnlist;
                }
            }
            return returnlist;
        }
        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
                {
                    using (IDbCommand result = dbm.Manager.Query(
                        "SELECT UUID,username,lastname FROM " + m_usersTableName +
                        " WHERE username like ?first AND lastname like ?second LIMIT 100",
                        param))
                    {
                        using (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);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    dbm.Manager.Reconnect();
                    m_log.Error(e.Message, e);
                    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) + "%";

                    using (IDbCommand result = dbm.Manager.Query(
                        "SELECT UUID,username,lastname FROM " + m_usersTableName +
                        " WHERE username like ?first OR lastname like ?first LIMIT 100",
                        param))
                    {
                        using (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);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    dbm.Manager.Reconnect();
                    m_log.Error(e.Message, e);
                    return returnlist;
                }
                finally
                {
                    dbm.Release();
                }
            }
            return returnlist;
        }