/// <summary> /// Searches for parcels around the grid /// </summary> /// <param name="queryText"></param> /// <param name="category"></param> /// <param name="StartQuery"></param> /// <returns></returns> public DirPlacesReplyData[] FindLand(string queryText, string category, int StartQuery, uint Flags) { List <DirPlacesReplyData> Data = new List <DirPlacesReplyData>(); string categoryString = ""; string dwell = ""; if (category != "-1") //Check for category { categoryString = " PCategory = '" + category + "' &&"; } //If they dwell sort flag is there, sort by dwell going down if ((Flags & (uint)DirectoryManager.DirFindFlags.DwellSort) == (uint)DirectoryManager.DirFindFlags.DwellSort) { dwell = " ORDER BY Dwell DESC"; } string whereClause = categoryString + " Description LIKE '%" + queryText + "%' OR Name LIKE '%" + queryText + "%' and ShowInSearch = '1'" + dwell + " LIMIT " + StartQuery.ToString() + ",50 "; List <string> retVal = GD.Query(whereClause, "searchparcel", "InfoUUID,Name,ForSale,Auction,Dwell,Maturity"); if (retVal.Count == 0) { return(Data.ToArray()); } DirPlacesReplyData replyData = new DirPlacesReplyData(); for (int i = 0; i < retVal.Count; i += 6) { replyData.parcelID = new UUID(retVal[i]); replyData.name = retVal[i + 1]; replyData.forSale = int.Parse(retVal[i + 2]) == 1; replyData.auction = retVal[i + 3] == "0"; //Auction is stored as a 0 if there is no auction replyData.dwell = float.Parse(retVal[i + 4]); //Check to make sure we are sending the requested maturity levels if (int.Parse(retVal[i + 5]) <= 0 && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludePG)) == (uint)DirectoryManager.DirFindFlags.IncludePG) { Data.Add(replyData); } else if (int.Parse(retVal[i + 5]) <= 1 && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludeMature)) == (uint)DirectoryManager.DirFindFlags.IncludeMature) { Data.Add(replyData); } else if (int.Parse(retVal[i + 5]) <= 2 && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludeAdult)) == (uint)DirectoryManager.DirFindFlags.IncludeAdult) { Data.Add(replyData); } replyData = new DirPlacesReplyData(); } return(Data.ToArray()); }
protected void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart) { Hashtable ReqHash = new Hashtable(); ReqHash["text"] = queryText; ReqHash["flags"] = queryFlags.ToString(); ReqHash["category"] = category.ToString(); ReqHash["sim_name"] = simName; ReqHash["query_start"] = queryStart.ToString(); Hashtable result = GenericXMLRPCRequest(ReqHash, "dir_places_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; } DirPlacesReplyData[] data = new DirPlacesReplyData[count]; int i = 0; foreach (Object o in dataArray) { Hashtable d = (Hashtable)o; data[i] = new DirPlacesReplyData(); data[i].parcelID = new UUID(d["parcel_id"].ToString()); data[i].name = d["name"].ToString(); data[i].forSale = Convert.ToBoolean(d["for_sale"]); data[i].auction = Convert.ToBoolean(d["auction"]); data[i].dwell = Convert.ToSingle(d["dwell"]); if (++i >= count) { break; } } remoteClient.SendDirPlacesReply(queryID, data); }
public DirPlacesReplyData[] FindLand(string queryText, string category, int StartQuery, uint Flags) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["QUERYTEXT"] = queryText; sendData["CATEGORY"] = category; sendData["STARTQUERY"] = StartQuery; sendData["FLAGS"] = Flags; sendData["METHOD"] = "findland"; string reqString = WebUtils.BuildQueryString(sendData); List <DirPlacesReplyData> Land = new List <DirPlacesReplyData>(); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); foreach (object f in replyData) { KeyValuePair <string, object> value = (KeyValuePair <string, object>)f; if (value.Value is Dictionary <string, object> ) { Dictionary <string, object> valuevalue = value.Value as Dictionary <string, object>; DirPlacesReplyData land = new DirPlacesReplyData(valuevalue); Land.Add(land); } } } } return(Land.ToArray()); } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString()); } return(Land.ToArray()); }
/// <summary> /// Parcel request /// </summary> /// <param name="remoteClient"></param> /// <param name="queryID"></param> /// <param name="queryText">The thing to search for</param> /// <param name="queryFlags"></param> /// <param name="category"></param> /// <param name="simName"></param> /// <param name="queryStart"></param> protected void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart) { DirPlacesReplyData[] ReturnValues = directoryService.FindLand(queryText, category.ToString(), queryStart, (uint)queryFlags); //Only send 10 at a time so that we don't kill the client with too big of a packet if (ReturnValues.Length > 10) { DirPlacesReplyData[] data = new DirPlacesReplyData[10]; int i = 0; foreach (DirPlacesReplyData d in ReturnValues) { data[i] = d; i++; if (i == 10) { //Rebuild the packets every 10 places remoteClient.SendDirPlacesReply(queryID, data); i = 0; if (ReturnValues.Length - i < 10) { data = new DirPlacesReplyData[ReturnValues.Length - i]; } else { data = new DirPlacesReplyData[10]; } } } //Send all the remaining packets if(data.Length != 0) remoteClient.SendDirPlacesReply(queryID, data); } else //Send all then if it is less than 10 remoteClient.SendDirPlacesReply(queryID, ReturnValues); }
/// <summary> /// Searches for parcels around the grid /// </summary> /// <param name="queryText"></param> /// <param name="category"></param> /// <param name="StartQuery"></param> /// <returns></returns> public DirPlacesReplyData[] FindLand(string queryText, string category, int StartQuery, uint Flags) { List<DirPlacesReplyData> Data = new List<DirPlacesReplyData>(); string categoryString = ""; string dwell = ""; if (category != "-1") //Check for category categoryString = " PCategory = '" + category + "' &&"; //If they dwell sort flag is there, sort by dwell going down if ((Flags & (uint)DirectoryManager.DirFindFlags.DwellSort) == (uint)DirectoryManager.DirFindFlags.DwellSort) dwell = " ORDER BY Dwell DESC"; string whereClause = categoryString + " Description LIKE '%" + queryText + "%' OR Name LIKE '%" + queryText + "%' and ShowInSearch = '1'" + dwell + " LIMIT " + StartQuery.ToString() + ",50 "; List<string> retVal = GD.Query(whereClause, "searchparcel", "InfoUUID,Name,ForSale,Auction,Dwell,Flags"); if (retVal.Count == 0) return Data.ToArray(); DirPlacesReplyData replyData = new DirPlacesReplyData(); for (int i = 0; i < retVal.Count; i += 6) { replyData.parcelID = new UUID(retVal[i]); replyData.name = retVal[i + 1]; replyData.forSale = int.Parse(retVal[i + 2]) == 1; replyData.auction = retVal[i + 3] == "0"; //Auction is stored as a 0 if there is no auction replyData.dwell = float.Parse(retVal[i + 4]); //Check to make sure we are sending the requested maturity levels if ((int.Parse (retVal[i + 5]) & (int)ParcelFlags.MaturePublish) == (int)ParcelFlags.MaturePublish && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludeMature)) == 0) { } else Data.Add (replyData); replyData = new DirPlacesReplyData(); } return Data.ToArray(); }
public DirPlacesReplyData[] FindLand(string queryText, string category, int StartQuery, uint Flags) { List<DirPlacesReplyData> Data = new List<DirPlacesReplyData>(); string categoryString = ""; string dwell = ""; if (category != "-1") categoryString = " PCategory = '" + category + "' &&"; if ((Flags & (uint)DirectoryManager.DirFindFlags.DwellSort) == (uint)DirectoryManager.DirFindFlags.DwellSort) dwell = " ORDER BY Dwell DESC"; string whereClause = categoryString + " Description LIKE '%" + queryText + "%' OR Name LIKE '%" + queryText + "%' and ShowInSearch = 'True'" + dwell + " LIMIT " + StartQuery.ToString() + ",50 "; List<string> retVal = GD.Query(whereClause, "searchparcel", "InfoUUID,Name,ForSale,Auction,Dwell,Maturity"); if (retVal.Count == 0) return Data.ToArray(); DirPlacesReplyData replyData = new DirPlacesReplyData(); for (int i = 0; i < retVal.Count; i += 6) { replyData.parcelID = new UUID(retVal[i]); replyData.name = retVal[i + 1]; replyData.forSale = int.Parse(retVal[i + 2]) == 1; replyData.auction = retVal[i + 3] == "0"; replyData.dwell = float.Parse(retVal[i + 4]); if (int.Parse(retVal[i + 5]) == 0 && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludePG)) == (uint)DirectoryManager.DirFindFlags.IncludePG) Data.Add(replyData); else if (int.Parse(retVal[i + 5]) == 1 && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludeMature)) == (uint)DirectoryManager.DirFindFlags.IncludeMature) Data.Add(replyData); else if (int.Parse(retVal[i + 5]) == 2 && ((Flags & (uint)DirectoryManager.DirFindFlags.IncludeAdult)) == (uint)DirectoryManager.DirFindFlags.IncludeAdult) Data.Add(replyData); replyData = new DirPlacesReplyData(); } return Data.ToArray(); }
/// <summary> /// Parcel request /// </summary> /// <param name="remoteClient"></param> /// <param name="queryID"></param> /// <param name="queryText"></param> /// <param name="queryFlags"></param> /// <param name="category"></param> /// <param name="simName"></param> /// <param name="queryStart"></param> protected void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart) { DirPlacesReplyData[] ReturnValues = DSC.FindLand(queryText, category.ToString(), queryStart, (uint)queryFlags); if (ReturnValues.Length > 10) { DirPlacesReplyData[] data = new DirPlacesReplyData[10]; int i = 0; foreach (DirPlacesReplyData d in ReturnValues) { data[i] = d; i++; if (i == 10) { remoteClient.SendDirPlacesReply(queryID, data); i = 0; if (ReturnValues.Length - i < 10) { data = new DirPlacesReplyData[ReturnValues.Length - i]; } else { data = new DirPlacesReplyData[10]; } } } remoteClient.SendDirPlacesReply(queryID, data); } else { remoteClient.SendDirPlacesReply(queryID, ReturnValues); } }
public DirPlacesReplyData[] FindLand(string queryText, string category, int StartQuery, uint Flags) { Dictionary<string, object> sendData = new Dictionary<string, object>(); sendData["QUERYTEXT"] = queryText; sendData["CATEGORY"] = category; sendData["STARTQUERY"] = StartQuery; sendData["FLAGS"] = Flags; sendData["METHOD"] = "findland"; string reqString = WebUtils.BuildQueryString(sendData); List<DirPlacesReplyData> Land = new List<DirPlacesReplyData>(); try { foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auroradata", reqString); if (reply != string.Empty) { Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply); foreach (object f in replyData) { KeyValuePair<string, object> value = (KeyValuePair<string, object>)f; if (value.Value is Dictionary<string, object>) { Dictionary<string, object> valuevalue = value.Value as Dictionary<string, object>; DirPlacesReplyData land = new DirPlacesReplyData(valuevalue); Land.Add(land); } } } } return Land.ToArray(); } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString()); } return Land.ToArray(); }
protected void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart) { // m_log.DebugFormat("[LAND SEARCH]: In Places Search for queryText: {0} with queryFlag: {1} with category {2} for simName {3}", // queryText, queryFlags.ToString("X"), category.ToString(), simName); queryText = queryText.Trim(); // newer viewers sometimes append a space string query = ""; //string newQueryText = "%" + queryText + "%"; Dictionary <string, object> parms = new Dictionary <string, object>(); parms.Add("?searchText", queryText); parms.Add("?searchFlags", queryFlags); if (category > 0) { parms.Add("?searchCategory", category); } //parms.Add("?searchSimName", simName); Single dwell = 0; int count = MAX_RESULTS + 1; // +1 so that the viewer knows to enable the NEXT button (it seems) int i = 0; int queryEnd = queryStart + count - 1; // 0-based query = "select * from land where LandFlags & " + ParcelFlags.ShowDirectory.ToString("d"); if (category > 0) { query += " AND Category=?searchCategory"; } query += " AND (Name REGEXP ?searchText OR Description REGEXP ?searchText) order by Name, Description"; using (ISimpleDB db = _connFactory.GetConnection()) { List <UUID> regionsToInclude = UpdateRegionsList(db); List <Dictionary <string, string> > results = DoLandQueryAndCombine(remoteClient, db, query, parms, 0, queryStart, queryEnd, regionsToInclude); DirPlacesReplyData[] data = new DirPlacesReplyData[results.Count < 1 ? 1 : results.Count]; foreach (Dictionary <string, string> row in results) { bool auction = false; data[i] = new DirPlacesReplyData(); data[i].parcelID = new UUID(row["uuid"]); data[i].name = row["name"]; data[i].forSale = (Convert.ToInt16(row["SalePrice"]) > 0); data[i].auction = auction; data[i].dwell = dwell; data[i].Status = STATUS_SEARCH_PLACES_NONE; // 0, success i++; } if (results.Count == 0) { data[0] = new DirPlacesReplyData(); data[0].parcelID = UUID.Zero; data[0].name = String.Empty; data[0].forSale = false; data[0].auction = false; data[0].dwell = 0; data[0].Status = STATUS_SEARCH_PLACES_FOUNDNONE; // empty results } remoteClient.SendDirPlacesReply(queryID, data); } }