public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, uint category, int queryStart)
        {
            List <DirClassifiedReplyData> ReturnValues = new List <DirClassifiedReplyData>(directoryService.FindClassifieds(queryText, category.ToString(), queryFlags, queryStart, remoteClient.ScopeID));

#if (!ISWIN)
            SplitPackets <DirClassifiedReplyData>(ReturnValues, delegate(DirClassifiedReplyData[] data)
            {
                remoteClient.SendDirClassifiedReply(queryID, data);
            });
#else
            SplitPackets(ReturnValues,
                         data => remoteClient.SendDirClassifiedReply(queryID, data));
#endif
        }
Exemple #2
0
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID,
                                       string queryText, uint queryFlags, uint category, int queryStart)
        {
            Hashtable ReqHash = new Hashtable();

            ReqHash["text"]        = queryText;
            ReqHash["flags"]       = queryFlags.ToString();
            ReqHash["category"]    = category.ToString();
            ReqHash["query_start"] = queryStart.ToString();

            Hashtable result = GenericXMLRPCRequest(ReqHash, "dir_classified_query");

            if (!Convert.ToBoolean(result["success"]))
            {
                remoteClient.SendAgentAlertMessage(result["errorMessage"].ToString(), false);
                return;
            }

            ArrayList dataArray = (ArrayList)result["data"];

            int count = dataArray.Count;

            if (count > 100)
            {
                count = 101;
            }

            DirClassifiedReplyData[] data = new DirClassifiedReplyData[count];

            int i = 0;

            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                string name = d["name"].ToString();
                if (Enc != null)
                {
                    name = Enc.GetString(Convert.FromBase64String(name));
                }

                data[i] = new DirClassifiedReplyData();
                data[i].classifiedID    = new UUID(d["classifiedid"].ToString());
                data[i].name            = name;
                data[i].classifiedFlags = Convert.ToByte(d["classifiedflags"]);
                data[i].creationDate    = Convert.ToUInt32(d["creation_date"]);
                data[i].expirationDate  = Convert.ToUInt32(d["expiration_date"]);
                data[i].price           = Convert.ToInt32(d["priceforlisting"]);
                i++;
                if (i >= count)
                {
                    break;
                }
            }

            remoteClient.SendDirClassifiedReply(queryID, data);
        }
        /// <summary>
        ///     Find Classifieds
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="queryID"></param>
        /// <param name="queryText"></param>
        /// <param name="queryFlags"></param>
        /// <param name="category"></param>
        /// <param name="queryStart"></param>
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags,
                                       uint category, int queryStart)
        {
            List <DirClassifiedReplyData> ReturnValues =
                new List <DirClassifiedReplyData> (DirectoryService.FindClassifieds(queryText.Trim(), category.ToString(),
                                                                                    queryFlags, queryStart,
                                                                                    remoteClient.ScopeID));

            SplitPackets(ReturnValues,
                         data => remoteClient.SendDirClassifiedReply(queryID, data));
        }
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID,
                                       string queryText, uint queryFlags, uint category,
                                       int queryStart)
        {
            DirClassifiedReplyData[] ReturnValues = directoryService.FindClassifieds(queryText, category.ToString(), queryFlags.ToString(), queryStart);
            
            //Split into sets of 10 packets
            if (ReturnValues.Length > 10)
            {
                DirClassifiedReplyData[] data = new DirClassifiedReplyData[10];
                int i = 0;

                foreach (DirClassifiedReplyData d in ReturnValues)
                {
                    data[i] = d;
                    i++;
                    if (i == 10)
                    {
                        remoteClient.SendDirClassifiedReply(queryID, data);
                        i = 0;
                        if (data.Length - i < 10)
                            data = new DirClassifiedReplyData[data.Length - i];
                        else
                            data = new DirClassifiedReplyData[10];
                    }
                }
                //Send the remaining packets
                if (data.Length != 0)
                    remoteClient.SendDirClassifiedReply(queryID, data);
            }
            else //Send the remaining as they are under 10
                remoteClient.SendDirClassifiedReply(queryID, ReturnValues);
        }
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID,
                string queryText, uint queryFlags, uint category,
                int queryStart)
        {
            Hashtable ReqHash = new Hashtable();
            ReqHash["text"] = queryText;
            ReqHash["flags"] = queryFlags.ToString();
            ReqHash["category"] = category.ToString();
            ReqHash["query_start"] = queryStart.ToString();

            Hashtable result = GenericXMLRPCRequest(ReqHash,
                    "dir_classified_query");

            if (!Convert.ToBoolean(result["success"]))
            {
                remoteClient.SendAgentAlertMessage(
                        result["errorMessage"].ToString(), false);
                return;
            }

            ArrayList dataArray = (ArrayList)result["data"];

            int count = dataArray.Count;
            if (count > 100)
                count = 101;

            DirClassifiedReplyData[] data = new DirClassifiedReplyData[count];

            int i = 0;

            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                data[i] = new DirClassifiedReplyData();
                data[i].classifiedID = new UUID(d["classifiedid"].ToString());
                data[i].name = d["name"].ToString();
                data[i].classifiedFlags = Convert.ToByte(d["classifiedflags"]);
                data[i].creationDate = Convert.ToUInt32(d["creation_date"]);
                data[i].expirationDate = Convert.ToUInt32(d["expiration_date"]);
                data[i].price = Convert.ToInt32(d["priceforlisting"]);

                if (++i >= count)
                    break;
            }

            remoteClient.SendDirClassifiedReply(queryID, data);
        }
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, uint category,
                int queryStart)
        {
            // This is pretty straightforward here, get the input, set up the query, run it through, send back to viewer.
            string query = String.Empty;
            string sqlAddTerms = String.Empty;
            string userText = queryText.Trim(); // newer viewers sometimes append a space

            string searchStart = Convert.ToString(queryStart);
            int count = MAX_RESULTS + 1;    // +1 so that the viewer knows to enable the NEXT button (it seems)
            string searchEnd = Convert.ToString(queryStart + count);
            int i = 0;

            // There is a slight issue with the parcel data not coming from land first so the
            //  parcel information is never displayed correctly within in the classified ad.

            //stop blank queries here before they explode mysql
            if (String.IsNullOrEmpty(userText))
            {
                remoteClient.SendDirClassifiedReply(queryID, new DirClassifiedReplyData[0]);
                return;
            }

            if (queryFlags == 0)
            {
                sqlAddTerms = " AND (classifiedflags='2' OR classifiedflags='34') ";
            }

            if (category != 0)
            {
                sqlAddTerms = " AND category=?category ";
            }

             Dictionary<string, object> parms = new Dictionary<string, object>();
             parms.Add("?matureFlag", queryFlags);
             parms.Add("?category", category);
             parms.Add("?userText", userText);

            // Ok a test cause the query pulls fine direct in MySQL, but not from here, so WTF?!
             //query = "select classifieduuid, name, classifiedflags, creationdate, expirationdate, priceforlisting from classifieds " +
             //        "where name LIKE '" + userText + "' OR description LIKE '" + userText + "' " + sqlAddTerms;

            query = "select classifieduuid, name, classifiedflags, creationdate, expirationdate, priceforlisting from classifieds " +
                    "where (description REGEXP ?userText OR name REGEXP ?userText) " +sqlAddTerms + " order by priceforlisting DESC limit " + searchStart + ", " + searchEnd + String.Empty;

            using (ISimpleDB db = _connFactory.GetConnection())
            {
                List<Dictionary<string, string>> results = db.QueryWithResults(query, parms);
                count = results.Count;
                DirClassifiedReplyData[] data = new DirClassifiedReplyData[count];
                foreach (Dictionary<string, string> row in results)
                {
                    data[i] = new DirClassifiedReplyData();
                    data[i].classifiedID = new UUID(row["classifieduuid"].ToString());
                    data[i].name = row["name"].ToString();
                    data[i].classifiedFlags = Convert.ToByte(row["classifiedflags"]);
                    data[i].creationDate = Convert.ToUInt32(row["creationdate"]);
                    data[i].expirationDate = Convert.ToUInt32(row["expirationdate"]);
                    data[i].price = Convert.ToInt32(row["priceforlisting"]);
                    i++;
                }
                remoteClient.SendDirClassifiedReply(queryID, data);
            }
        }
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID,
                                       string queryText, uint queryFlags, uint category,
                                       int queryStart)
        {
            DirClassifiedReplyData[] ReturnValues = DSC.FindClassifieds(queryText, category.ToString(), queryFlags.ToString(), queryStart);
            if (ReturnValues.Length > 10)
            {
                DirClassifiedReplyData[] data = new DirClassifiedReplyData[10];
                int i = 0;

                foreach (DirClassifiedReplyData d in ReturnValues)
                {
                    data[i] = d;
                    i++;
                    if (i == 10)
                    {
                        remoteClient.SendDirClassifiedReply(queryID, data);
                        i = 0;
                        if (data.Length - i < 10)
                        {
                            data = new DirClassifiedReplyData[data.Length - i];
                        }
                        else
                        {
                            data = new DirClassifiedReplyData[10];
                        }
                    }
                }
                remoteClient.SendDirClassifiedReply(queryID, data);
            }
            else
                remoteClient.SendDirClassifiedReply(queryID, ReturnValues);
        }
Exemple #8
0
        public void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, uint category,
                                       int queryStart)
        {
            // This is pretty straightforward here, get the input, set up the query, run it through, send back to viewer.
            string query       = "";
            string sqlAddTerms = "";
            string userText    = queryText.Trim(); // newer viewers sometimes append a space

            string searchStart = Convert.ToString(queryStart);
            int    count       = MAX_RESULTS + 1; // +1 so that the viewer knows to enable the NEXT button (it seems)
            string searchEnd   = Convert.ToString(queryStart + count);
            int    i           = 0;

            // There is a slight issue with the parcel data not coming from land first so the
            //  parcel information is never displayed correctly within in the classified ad.

            //stop blank queries here before they explode mysql
            if (userText == "")
            {
                remoteClient.SendDirClassifiedReply(queryID, new DirClassifiedReplyData[0]);
                return;
            }

            if (queryFlags == 0)
            {
                sqlAddTerms = " AND (classifiedflags='2' OR classifiedflags='34') ";
            }

            if (category != 0)
            {
                sqlAddTerms = " AND category=?category ";
            }

            Dictionary <string, object> parms = new Dictionary <string, object>();

            parms.Add("?matureFlag", queryFlags);
            parms.Add("?category", category);
            parms.Add("?userText", userText);

            // Ok a test cause the query pulls fine direct in MySQL, but not from here, so WTF?!
            //query = "select classifieduuid, name, classifiedflags, creationdate, expirationdate, priceforlisting from classifieds " +
            //        "where name LIKE '" + userText + "' OR description LIKE '" + userText + "' " + sqlAddTerms;

            query = "select classifieduuid, name, classifiedflags, creationdate, expirationdate, priceforlisting from classifieds " +
                    "where (description REGEXP ?userText OR name REGEXP ?userText) " + sqlAddTerms + " order by priceforlisting DESC limit " + searchStart + ", " + searchEnd + "";

            using (ISimpleDB db = _connFactory.GetConnection())
            {
                List <Dictionary <string, string> > results = db.QueryWithResults(query, parms);
                count = results.Count;
                DirClassifiedReplyData[] data = new DirClassifiedReplyData[count];
                foreach (Dictionary <string, string> row in results)
                {
                    data[i] = new DirClassifiedReplyData();
                    data[i].classifiedID    = new UUID(row["classifieduuid"].ToString());
                    data[i].name            = row["name"].ToString();
                    data[i].classifiedFlags = Convert.ToByte(row["classifiedflags"]);
                    data[i].creationDate    = Convert.ToUInt32(row["creationdate"]);
                    data[i].expirationDate  = Convert.ToUInt32(row["expirationdate"]);
                    data[i].price           = Convert.ToInt32(row["priceforlisting"]);
                    i++;
                }
                remoteClient.SendDirClassifiedReply(queryID, data);
            }
        }