public void DirLandQuery(IClientAPI remoteClient, UUID queryID,
                                 uint queryFlags, uint searchType, int price, int area,
                                 int queryStart)
        {
            Hashtable ReqHash = new Hashtable();

            ReqHash["flags"]       = queryFlags.ToString();
            ReqHash["type"]        = searchType.ToString();
            ReqHash["price"]       = price.ToString();
            ReqHash["area"]        = area.ToString();
            ReqHash["query_start"] = queryStart.ToString();

            Hashtable result = GenericXMLRPCRequest(ReqHash,
                                                    "dir_land_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;
            }

            DirLandReplyData[] data = new DirLandReplyData[count];

            int i = 0;

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

                if (d["name"] == null)
                {
                    continue;
                }

                data[i]            = new DirLandReplyData();
                data[i].parcelID   = new UUID(d["parcel_id"].ToString());
                data[i].name       = d["name"].ToString();
                data[i].auction    = Convert.ToBoolean(d["auction"]);
                data[i].forSale    = Convert.ToBoolean(d["for_sale"]);
                data[i].salePrice  = Convert.ToInt32(d["sale_price"]);
                data[i].actualArea = Convert.ToInt32(d["area"]);
                i++;
                if (i >= count)
                {
                    break;
                }
            }

            remoteClient.SendDirLandReply(queryID, data);
        }
Пример #2
0
        /// <summary>
        ///     Land for sale request
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="queryID"></param>
        /// <param name="queryFlags"></param>
        /// <param name="searchType"></param>
        /// <param name="price"></param>
        /// <param name="area"></param>
        /// <param name="queryStart"></param>
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, uint price,
                                 uint area, int queryStart)
        {
            List <DirLandReplyData> ReturnValues =
                new List <DirLandReplyData> (DirectoryService.FindLandForSale(searchType.ToString(), price, area,
                                                                              queryStart, queryFlags, remoteClient.ScopeID));

            SplitPackets(ReturnValues,
                         data => remoteClient.SendDirLandReply(queryID, data));
        }
Пример #3
0
        /// <summary>
        /// Land for sale request
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="queryID"></param>
        /// <param name="queryFlags"></param>
        /// <param name="searchType"></param>
        /// <param name="price"></param>
        /// <param name="area"></param>
        /// <param name="queryStart"></param>
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID,
                                 uint queryFlags, uint searchType, int price, int area,
                                 int queryStart)
        {
            List <DirLandReplyData> ReturnValues = new List <DirLandReplyData>(directoryService.FindLandForSale(searchType.ToString(), price.ToString(), area.ToString(), queryStart, queryFlags));

            SplitPackets <DirLandReplyData> (ReturnValues, delegate(DirLandReplyData[] data)
            {
                remoteClient.SendDirLandReply(queryID, data);
            });
        }
Пример #4
0
 /// <summary>
 /// Land for sale request
 /// </summary>
 /// <param name="remoteClient"></param>
 /// <param name="queryID"></param>
 /// <param name="queryFlags"></param>
 /// <param name="searchType"></param>
 /// <param name="price"></param>
 /// <param name="area"></param>
 /// <param name="queryStart"></param>
 public void DirLandQuery(IClientAPI remoteClient, UUID queryID,
                          uint queryFlags, uint searchType, int price, int area,
                          int queryStart)
 {
     DirLandReplyData[] ReturnValues = directoryService.FindLandForSale(searchType.ToString(), price.ToString(), area.ToString(), queryStart, queryFlags);
     //Send only 10 at a time
     if (ReturnValues.Length > 10)
     {
         DirLandReplyData[] data = new DirLandReplyData[10];
         
         int i = 0;
         foreach (DirLandReplyData d in ReturnValues)
         {
             data[i] = d;
             i++;
             if (i == 10)
             {
                 //Rebuild every 10 packets
                 remoteClient.SendDirLandReply(queryID, data);
                 i = 0;
                 if (ReturnValues.Length - i < 10)
                     data = new DirLandReplyData[ReturnValues.Length - i];
                 else
                     data = new DirLandReplyData[10];
             }
         }
         //Send the remaining
         if(data.Length != 0)
             remoteClient.SendDirLandReply(queryID, data);
     }
     else //Send all the rest
         remoteClient.SendDirLandReply(queryID, ReturnValues);
 }
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID,
                uint queryFlags, uint searchType, int price, int area,
                int queryStart)
        {
            Hashtable ReqHash = new Hashtable();
            ReqHash["flags"] = queryFlags.ToString();
            ReqHash["type"] = searchType.ToString();
            ReqHash["price"] = price.ToString();
            ReqHash["area"] = area.ToString();
            ReqHash["query_start"] = queryStart.ToString();

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

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

            ArrayList dataArray = (ArrayList)result["data"];
            int count = 0;

            /* Count entries in dataArray with valid region name to */
            /* prevent allocating data array with too many entries. */
            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                if (d["name"] != null)
                    ++count;
            }

            if (count > 100)
                count = 101;

            DirLandReplyData[] data = new DirLandReplyData[count];

            int i = 0;

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

                if (d["name"] == null)
                    continue;

                data[i] = new DirLandReplyData();
                data[i].parcelID = new UUID(d["parcel_id"].ToString());
                data[i].name = d["name"].ToString();
                data[i].auction = Convert.ToBoolean(d["auction"]);
                data[i].forSale = Convert.ToBoolean(d["for_sale"]);
                data[i].salePrice = Convert.ToInt32(d["sale_price"]);
                data[i].actualArea = Convert.ToInt32(d["area"]);

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

            remoteClient.SendDirLandReply(queryID, data);
        }
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, int price, int area,
                int queryStart)
        {
            //m_log.DebugFormat("[LAND SEARCH]: In Land Search, queryFlag = " + queryFlags.ToString("X"));
            string query = String.Empty;
            int count = MAX_RESULTS + 1;    // +1 so that the viewer knows to enable the NEXT button (it seems)
            int queryEnd = queryStart + count - 1;  // 0-based
            int i = 0;
            string sqlTerms = String.Empty;

            if ((queryFlags & ((uint)DirFindFlags.NameSort|(uint)DirFindFlags.AreaSort|(uint)DirFindFlags.PricesSort|(uint)DirFindFlags.PerMeterSort)) == 0)
            {
                // No sort options specified.  Substitute price per meter sort for Land Sales.
                queryFlags |= (uint)DirFindFlags.PerMeterSort;
                queryFlags |= (uint)DirFindFlags.SortAsc;
            }

            bool checkPriceFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.LimitByPrice);
            bool checkAreaFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.LimitByArea);
            bool checkPGFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludePG);
            bool checkMatureFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludeMature);
            bool checkAdultFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludeAdult);

            //sqlTerms = "select parcelUUID, parcelname, area, saleprice from parcelsales";
            sqlTerms = "select land.UUID, land.RegionUUID, land.Name, land.Area, land.SalePrice, regionsettings.maturity from land LEFT JOIN regionsettings ON land.RegionUUID=regionsettings.regionUUID";

            // Limit "Land Sales" returns to parcels for sale.
            sqlTerms += " where (LandFlags & " + ((int)ParcelFlags.ForSale).ToString() + ")";
            // Limit "Land Sales" returns to parcels visible in search.
            sqlTerms += " and (LandFlags & " + ((int)ParcelFlags.ShowDirectory).ToString() + ")";

            if (!(checkPGFlag || checkMatureFlag || checkAdultFlag))
            {
                // nothing to search for
                remoteClient.SendAgentAlertMessage("You must specify a search with at least one maturity level checked.", false);
                remoteClient.SendDirLandReply(queryID, new DirLandReplyData[1]);
                return;
            }

            if (searchType == 2)
            {
                remoteClient.SendAgentAlertMessage("Auctions not available.", false);
                remoteClient.SendDirLandReply(queryID, new DirLandReplyData[1]);
                return;
            } 
            /*else if (searchType == 8)
            {
                sqlTerms += " AND parentestate='1' ";
            }
            else if (searchType == 16)
            {
                sqlTerms += " AND parentestate>'1' ";
            }*/

            int maturities = 0;
            sqlTerms += " and (";
            if (checkPGFlag)
            {
                sqlTerms += "regionsettings.maturity='0'";
                maturities++;
            }
            if (checkMatureFlag)
            {
                if (maturities > 0) sqlTerms += " or ";
                sqlTerms += "regionsettings.maturity='1'";
                maturities++;
            }
            if (checkAdultFlag)
            {
                if (maturities > 0) sqlTerms += " or ";
                sqlTerms += "regionsettings.maturity='2'";
                maturities++;
            }
            sqlTerms += ")";

            if (checkPriceFlag && (price > 0))
            {
                sqlTerms += " and (land.SalePrice<=" + Convert.ToString(price) + " AND land.SalePrice >= 1) ";
            }

            if (checkAreaFlag && (area > 0))
            {
                sqlTerms += " and land.Area>=" + Convert.ToString(area);
            }

            string order = ((queryFlags & (uint)DirFindFlags.SortAsc) != 0) ? "ASC" : "DESC";
            string norder = ((queryFlags & (uint)DirFindFlags.SortAsc) == 0) ? "ASC" : "DESC";
            if ((queryFlags & (uint)DirFindFlags.NameSort) != 0)
            {
                sqlTerms += " order by land.Name " + order;
            }
            else if ((queryFlags & (uint)DirFindFlags.PerMeterSort) != 0)
            {
                sqlTerms += " and land.Area > 0 order by land.SalePrice / land.Area " + order + ", land.SalePrice " + order + ", land.Area " + norder + ", land.Name ASC";
            }
            else if ((queryFlags & (uint)DirFindFlags.PricesSort) != 0)
            {
                sqlTerms += " order by land.SalePrice " + order + ", land.Area " + norder + ", land.Name ASC";
            }
            else if ((queryFlags & (uint)DirFindFlags.AreaSort) != 0)
            {
                sqlTerms += " order by land.Area " + order + ", land.SalePrice ASC, land.Name ASC";
            }

            Dictionary<string, object> parms = new Dictionary<string, object>();
            query = sqlTerms;   // nothing extra to add anymore
//            m_log.Debug("Query is: " + query);
            List<Dictionary<string, string>> results;
            using (ISimpleDB db = _connFactory.GetConnection())
            {
                List<UUID> regionsToInclude = UpdateRegionsList(db);
                results = DoLandQueryAndCombine(remoteClient, db, query, parms, queryFlags, queryStart, queryEnd, regionsToInclude);
            }
            if (results.Count < count)
                count = results.Count;  // no Next button
            if (count < 1)
                count = 1;  // a single empty DirLandReplyData will just cause the viewer to report no results found.
            DirLandReplyData[] data = new DirLandReplyData[count];
            foreach (Dictionary<string, string> row in results)
            {
                bool forSale = true;
                bool auction = false;
                data[i] = new DirLandReplyData();
                data[i].parcelID = new UUID(row["UUID"]);
                data[i].name = row["Name"].ToString();
                data[i].auction = auction;
                data[i].forSale = forSale;
                data[i].salePrice = Convert.ToInt32(row["SalePrice"]);
                data[i].actualArea = Convert.ToInt32(row["Area"]);
                i++;
                if (i >= count)
                    break;
            }

            remoteClient.SendDirLandReply(queryID, data);
        }
Пример #7
0
 /// <summary>
 /// Land for sale request
 /// </summary>
 /// <param name="remoteClient"></param>
 /// <param name="queryID"></param>
 /// <param name="queryFlags"></param>
 /// <param name="searchType"></param>
 /// <param name="price"></param>
 /// <param name="area"></param>
 /// <param name="queryStart"></param>
 public void DirLandQuery(IClientAPI remoteClient, UUID queryID,
                          uint queryFlags, uint searchType, int price, int area,
                          int queryStart)
 {
     DirLandReplyData[] ReturnValues = DSC.FindLandForSale(searchType.ToString(), price.ToString(), area.ToString(), queryStart, queryFlags);
     if (ReturnValues.Length > 10)
     {
         DirLandReplyData[] data = new DirLandReplyData[10];
         
         int i = 0;
         foreach (DirLandReplyData d in ReturnValues)
         {
             data[i] = d;
             i++;
             if (i == 10)
             {
                 remoteClient.SendDirLandReply(queryID, data);
                 i = 0;
                 if (ReturnValues.Length - i < 10)
                 {
                     data = new DirLandReplyData[ReturnValues.Length - i];
                 }
                 else
                 {
                     data = new DirLandReplyData[10];
                 }
             }
         }
         remoteClient.SendDirLandReply(queryID, data);
     }
     else
         remoteClient.SendDirLandReply(queryID, ReturnValues);
 }
Пример #8
0
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, int price, int area,
                                 int queryStart)
        {
            //m_log.DebugFormat("[LAND SEARCH]: In Land Search, queryFlag = " + queryFlags.ToString("X"));
            string query    = "";
            int    count    = MAX_RESULTS + 1;        // +1 so that the viewer knows to enable the NEXT button (it seems)
            int    queryEnd = queryStart + count - 1; // 0-based
            int    i        = 0;
            string sqlTerms = "";

            if ((queryFlags & ((uint)DirFindFlags.NameSort | (uint)DirFindFlags.AreaSort | (uint)DirFindFlags.PricesSort | (uint)DirFindFlags.PerMeterSort)) == 0)
            {
                // No sort options specified.  Substitute price per meter sort for Land Sales.
                queryFlags |= (uint)DirFindFlags.PerMeterSort;
                queryFlags |= (uint)DirFindFlags.SortAsc;
            }

            bool checkPriceFlag  = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.LimitByPrice);
            bool checkAreaFlag   = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.LimitByArea);
            bool checkPGFlag     = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludePG);
            bool checkMatureFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludeMature);
            bool checkAdultFlag  = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludeAdult);

            //sqlTerms = "select parcelUUID, parcelname, area, saleprice from parcelsales";
            sqlTerms = "select land.UUID, land.RegionUUID, land.Name, land.Area, land.SalePrice, regionsettings.maturity from land LEFT JOIN regionsettings ON land.RegionUUID=regionsettings.regionUUID";

            // Limit "Land Sales" returns to parcels for sale.
            sqlTerms += " where (LandFlags & " + ((int)ParcelFlags.ForSale).ToString() + ")";
            // Limit "Land Sales" returns to parcels visible in search.
            sqlTerms += " and (LandFlags & " + ((int)ParcelFlags.ShowDirectory).ToString() + ")";

            if (!(checkPGFlag || checkMatureFlag || checkAdultFlag))
            {
                // nothing to search for
                remoteClient.SendAgentAlertMessage("You must specify a search with at least one maturity level checked.", false);
                remoteClient.SendDirLandReply(queryID, new DirLandReplyData[1]);
                return;
            }

            if (searchType == 2)
            {
                remoteClient.SendAgentAlertMessage("Auctions not available.", false);
                remoteClient.SendDirLandReply(queryID, new DirLandReplyData[1]);
                return;
            }

            /*else if (searchType == 8)
             * {
             *  sqlTerms += " AND parentestate='1' ";
             * }
             * else if (searchType == 16)
             * {
             *  sqlTerms += " AND parentestate>'1' ";
             * }*/

            int maturities = 0;

            sqlTerms += " and (";
            if (checkPGFlag)
            {
                sqlTerms += "regionsettings.maturity='0'";
                maturities++;
            }
            if (checkMatureFlag)
            {
                if (maturities > 0)
                {
                    sqlTerms += " or ";
                }
                sqlTerms += "regionsettings.maturity='1'";
                maturities++;
            }
            if (checkAdultFlag)
            {
                if (maturities > 0)
                {
                    sqlTerms += " or ";
                }
                sqlTerms += "regionsettings.maturity='2'";
                maturities++;
            }
            sqlTerms += ")";

            if (checkPriceFlag && (price > 0))
            {
                sqlTerms += " and (land.SalePrice<=" + Convert.ToString(price) + " AND land.SalePrice >= 1) ";
            }

            if (checkAreaFlag && (area > 0))
            {
                sqlTerms += " and land.Area>=" + Convert.ToString(area);
            }

            string order  = ((queryFlags & (uint)DirFindFlags.SortAsc) != 0) ? "ASC" : "DESC";
            string norder = ((queryFlags & (uint)DirFindFlags.SortAsc) == 0) ? "ASC" : "DESC";

            if ((queryFlags & (uint)DirFindFlags.NameSort) != 0)
            {
                sqlTerms += " order by land.Name " + order;
            }
            else if ((queryFlags & (uint)DirFindFlags.PerMeterSort) != 0)
            {
                sqlTerms += " and land.Area > 0 order by land.SalePrice / land.Area " + order + ", land.SalePrice " + order + ", land.Area " + norder + ", land.Name ASC";
            }
            else if ((queryFlags & (uint)DirFindFlags.PricesSort) != 0)
            {
                sqlTerms += " order by land.SalePrice " + order + ", land.Area " + norder + ", land.Name ASC";
            }
            else if ((queryFlags & (uint)DirFindFlags.AreaSort) != 0)
            {
                sqlTerms += " order by land.Area " + order + ", land.SalePrice ASC, land.Name ASC";
            }

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

            query = sqlTerms;   // nothing extra to add anymore
//            m_log.Debug("Query is: " + query);
            List <Dictionary <string, string> > results;

            using (ISimpleDB db = _connFactory.GetConnection())
            {
                List <UUID> regionsToInclude = UpdateRegionsList(db);
                results = DoLandQueryAndCombine(remoteClient, db, query, parms, queryFlags, queryStart, queryEnd, regionsToInclude);
            }
            if (results.Count < count)
            {
                count = results.Count;  // no Next button
            }
            if (count < 1)
            {
                count = 1;  // a single empty DirLandReplyData will just cause the viewer to report no results found.
            }
            DirLandReplyData[] data = new DirLandReplyData[count];
            foreach (Dictionary <string, string> row in results)
            {
                bool forSale = true;
                bool auction = false;
                data[i]            = new DirLandReplyData();
                data[i].parcelID   = new UUID(row["UUID"]);
                data[i].name       = row["Name"].ToString();
                data[i].auction    = auction;
                data[i].forSale    = forSale;
                data[i].salePrice  = Convert.ToInt32(row["SalePrice"]);
                data[i].actualArea = Convert.ToInt32(row["Area"]);
                i++;
                if (i >= count)
                {
                    break;
                }
            }

            remoteClient.SendDirLandReply(queryID, data);
        }