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> /// Searches for classifieds /// </summary> /// <param name = "queryText"></param> /// <param name = "category"></param> /// <param name = "queryFlags"></param> /// <param name = "StartQuery"></param> /// <returns></returns> public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, uint queryFlags, int StartQuery) { QueryFilter filter = new QueryFilter(); if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category { filter.andFilters["Category"] = category; } filter.andLikeFilters["Name"] = "%" + queryText + "%"; List <string> retVal = GD.Query(new string[1] { "*" }, "userclassifieds", filter, null, (uint)StartQuery, 50); if (retVal.Count == 0) { return(new DirClassifiedReplyData[0] { }); } List <DirClassifiedReplyData> Data = new List <DirClassifiedReplyData>(); DirClassifiedReplyData replyData; for (int i = 0; i < retVal.Count; i += 6) { //Pull the classified out of OSD Classified classified = new Classified(); classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5])); replyData = new DirClassifiedReplyData { classifiedFlags = classified.ClassifiedFlags, classifiedID = classified.ClassifiedUUID, creationDate = classified.CreationDate, expirationDate = classified.ExpirationDate, price = classified.PriceForListing, name = classified.Name }; //Check maturity levels if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature) { if ((queryFlags & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature) { Data.Add(replyData); } } else { //Its PG, add all Data.Add(replyData); } } return(Data.ToArray()); }
/// <summary> /// Searches for classifieds /// </summary> /// <param name="queryText"></param> /// <param name="category"></param> /// <param name="queryFlags"></param> /// <param name="StartQuery"></param> /// <returns></returns> public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery) { List <DirClassifiedReplyData> Data = new List <DirClassifiedReplyData>(); string whereClause = ""; string classifiedClause = ""; uint cqf = uint.Parse(queryFlags); if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category { classifiedClause = " and Category = '" + category + "'"; } whereClause = " Name LIKE '%" + queryText + "%'" + classifiedClause + " LIMIT " + StartQuery.ToString() + ",50 "; List <string> retVal = GD.Query(whereClause, "userclassifieds", "*"); if (retVal.Count == 0) { return(Data.ToArray()); } DirClassifiedReplyData replyData = null; for (int i = 0; i < retVal.Count; i += 6) { //Pull the classified out of OSD Classified classified = new Classified(); classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5])); replyData = new DirClassifiedReplyData(); replyData.classifiedFlags = classified.ClassifiedFlags; replyData.classifiedID = classified.ClassifiedUUID; replyData.creationDate = classified.CreationDate; replyData.expirationDate = classified.ExpirationDate; replyData.price = classified.PriceForListing; replyData.name = classified.Name; //Check maturity levels if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature) { if ((cqf & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature) { Data.Add(replyData); } } else //Its PG, add all { Data.Add(replyData); } } return(Data.ToArray()); }
public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["QUERYTEXT"] = queryText; sendData["CATEGORY"] = category; sendData["QUERYFLAGS"] = queryFlags; sendData["STARTQUERY"] = StartQuery; sendData["METHOD"] = "findclassifieds"; string reqString = WebUtils.BuildQueryString(sendData); List <DirClassifiedReplyData> Classifieds = new List <DirClassifiedReplyData>(); 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>; DirClassifiedReplyData classified = new DirClassifiedReplyData(valuevalue); Classifieds.Add(classified); } } } } return(Classifieds.ToArray()); } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString()); } return(Classifieds.ToArray()); }
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); }
/// <summary> /// Searches for classifieds /// </summary> /// <param name="queryText"></param> /// <param name="category"></param> /// <param name="queryFlags"></param> /// <param name="StartQuery"></param> /// <returns></returns> public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery) { List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>(); string whereClause = ""; string classifiedClause = ""; uint cqf = uint.Parse(queryFlags); if (int.Parse(category) != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category classifiedClause = " and Category = '" + category + "'"; whereClause = " Name LIKE '%" + queryText + "%'" + classifiedClause + " LIMIT " + StartQuery.ToString() + ",50 "; List<string> retVal = GD.Query (whereClause, "userclassifieds", "*"); if (retVal.Count == 0) return Data.ToArray(); DirClassifiedReplyData replyData = null; for (int i = 0; i < retVal.Count; i += 6) { //Pull the classified out of OSD Classified classified = new Classified(); classified.FromOSD((OSDMap)OSDParser.DeserializeJson(retVal[i + 5])); replyData = new DirClassifiedReplyData(); replyData.classifiedFlags = classified.ClassifiedFlags; replyData.classifiedID = classified.ClassifiedUUID; replyData.creationDate = classified.CreationDate; replyData.expirationDate = classified.ExpirationDate; replyData.price = classified.PriceForListing; replyData.name = classified.Name; //Check maturity levels if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature) { if ((cqf & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature) Data.Add(replyData); } else //Its PG, add all Data.Add(replyData); } return Data.ToArray(); }
public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery) { //TODO: BROKEN! List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>(); string whereClause = ""; string classifiedClause = ""; uint cqf = uint.Parse(queryFlags); if (category != "0") classifiedClause = " and category = '" + category + "'"; whereClause = " name LIKE '%" + queryText + "%'" + classifiedClause + " LIMIT " + StartQuery.ToString() + ",50 "; List<string> retVal = GD.Query(whereClause, "profileclassifieds", "classifiedflags, classifieduuid, creationdate, expirationdate, priceforlisting, name"); if (retVal.Count == 0) return Data.ToArray(); DirClassifiedReplyData replyData = null; for (int i = 0; i < retVal.Count; i += 6) { replyData = new DirClassifiedReplyData(); replyData.classifiedFlags = Convert.ToByte(retVal[i]); replyData.classifiedID = new UUID(retVal[i + 1]); replyData.creationDate = Convert.ToUInt32(retVal[i + 2]); replyData.expirationDate = Convert.ToUInt32(retVal[i + 3]); replyData.price = Convert.ToInt32(retVal[i + 4]); replyData.name = retVal[i + 5]; if ((replyData.classifiedFlags & (uint)DirectoryManager.ClassifiedFlags.Mature) == (uint)DirectoryManager.ClassifiedFlags.Mature) { if ((cqf & (uint)DirectoryManager.ClassifiedQueryFlags.Mature) == (uint)DirectoryManager.ClassifiedQueryFlags.Mature) Data.Add(replyData); } else Data.Add(replyData); } return Data.ToArray(); }
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); }
public DirClassifiedReplyData[] FindClassifieds(string queryText, string category, string queryFlags, int StartQuery) { Dictionary<string, object> sendData = new Dictionary<string, object>(); sendData["QUERYTEXT"] = queryText; sendData["CATEGORY"] = category; sendData["QUERYFLAGS"] = queryFlags; sendData["STARTQUERY"] = StartQuery; sendData["METHOD"] = "findclassifieds"; string reqString = WebUtils.BuildQueryString(sendData); List<DirClassifiedReplyData> Classifieds = new List<DirClassifiedReplyData>(); 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>; DirClassifiedReplyData classified = new DirClassifiedReplyData(valuevalue); Classifieds.Add(classified); } } } } return Classifieds.ToArray(); } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString()); } return Classifieds.ToArray(); }
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); } }