Example #1
0
        public void DirEventsQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            Hashtable ReqHash = new Hashtable();

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

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

            DirEventsReplyData[] data = new DirEventsReplyData[count];

            int i = 0;

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

                data[i]            = new DirEventsReplyData();
                data[i].ownerID    = new UUID(d["owner_id"].ToString());
                data[i].name       = d["name"].ToString();
                data[i].eventID    = Convert.ToUInt32(d["event_id"]);
                data[i].date       = d["date"].ToString();
                data[i].unixTime   = Convert.ToUInt32(d["unix_time"]);
                data[i].eventFlags = Convert.ToUInt32(d["event_flags"]);
                i++;
                if (i >= count)
                {
                    break;
                }
            }

            remoteClient.SendDirEventsReply(queryID, data);
        }
        /// <summary>
        ///   Retrives all events in the given region by their maturity level
        /// </summary>
        /// <param name = "regionName"></param>
        /// <param name = "maturity">Uses DirectoryManager.EventFlags to determine the maturity requested</param>
        /// <returns></returns>
        public DirEventsReplyData[] FindAllEventsInRegion(string regionName, int maturity)
        {
            List <DirEventsReplyData> Data = new List <DirEventsReplyData>();

            IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin <IRegionData>();

            if (regiondata != null)
            {
                List <GridRegion> regions = regiondata.Get(regionName, UUID.Zero);
                if (regions.Count >= 1)
                {
                    Dictionary <string, object> whereClause = new Dictionary <string, object>();
                    whereClause["region"]   = regions[0].RegionID.ToString();
                    whereClause["maturity"] = maturity;

                    List <string> retVal = GD.Query(new string[] {
                        "EID",
                        "creator",
                        "date",
                        "maturity",
                        "flags",
                        "name"
                    }, "asevents", new QueryFilter
                    {
                        andFilters = whereClause
                    }, null, null, null);

                    if (retVal.Count > 0)
                    {
                        DirEventsReplyData replyData;
                        for (int i = 0; i < retVal.Count; i += 6)
                        {
                            replyData = new DirEventsReplyData
                            {
                                eventID = Convert.ToUInt32(retVal[i]),
                                ownerID = new UUID(retVal[i + 1]),
                                name    = retVal[i + 5],
                            };
                            DateTime date = DateTime.Parse(retVal[i + 2].ToString());
                            replyData.date       = date.ToString(new DateTimeFormatInfo());
                            replyData.unixTime   = (uint)Util.ToUnixTime(date);
                            replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]);

                            Data.Add(replyData);
                        }
                    }
                }
            }

            return(Data.ToArray());
        }
Example #3
0
        public DirEventsReplyData[] FindEvents(string queryText, string flags, int StartQuery)
        {
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["QUERYTEXT"]  = queryText;
            sendData["FLAGS"]      = flags;
            sendData["STARTQUERY"] = StartQuery;
            sendData["METHOD"]     = "findevents";

            string reqString = WebUtils.BuildQueryString(sendData);
            List <DirEventsReplyData> Events = new List <DirEventsReplyData>();

            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>;
                                DirEventsReplyData          direvent   = new DirEventsReplyData(valuevalue);
                                Events.Add(direvent);
                            }
                        }
                    }
                }
                return(Events.ToArray());
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString());
            }
            return(Events.ToArray());
        }
        /// <summary>
        /// Retrives all events in the given region by their maturity level
        /// </summary>
        /// <param name="regionName"></param>
        /// <param name="maturity">Uses DirectoryManager.EventFlags to determine the maturity requested</param>
        /// <returns></returns>
        public DirEventsReplyData[] FindAllEventsInRegion(string regionName, int maturity)
        {
            List <DirEventsReplyData> Data = new List <DirEventsReplyData>();

            List <string> retVal = GD.Query("ESimName", regionName, "events", "EOwnerID,EName,EID,EDate,EFlags,EMature");

            if (retVal.Count == 0)
            {
                return(Data.ToArray());
            }

            DirEventsReplyData replyData = new DirEventsReplyData();

            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Check maturity level
                if (int.Parse(retVal[i + 5]) != maturity)
                {
                    continue;
                }

                replyData.ownerID = new UUID(retVal[i]);
                replyData.name    = retVal[i + 1];
                replyData.eventID = Convert.ToUInt32(retVal[i + 2]);

                //Parse the date for the viewer
                DateTime date = Util.ToDateTime(ulong.Parse(retVal[i + 3]));
                replyData.date     = date.ToString(new System.Globalization.DateTimeFormatInfo());
                replyData.unixTime = (uint)Util.ToUnixTime(date);

                replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]);
                Data.Add(replyData);
                replyData = new DirEventsReplyData();
            }

            return(Data.ToArray());
        }
        public void DirEventsQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            DirEventsReplyData[] ReturnValues = directoryService.FindEvents(queryText, queryFlags.ToString(), queryStart);

            //Split into sets of 10 packets
            if (ReturnValues.Length > 10)
            {
                DirEventsReplyData[] data = new DirEventsReplyData[10];
                int i = 0;

                foreach (DirEventsReplyData d in ReturnValues)
                {
                    data[i] = d;
                    i++;
                    if (i == 10)
                    {
                        remoteClient.SendDirEventsReply(queryID, data);
                        i = 0;
                        if (data.Length - i < 10)
                            data = new DirEventsReplyData[data.Length - i];
                        else
                            data = new DirEventsReplyData[10];
                    }
                }
                //Send the remaining packets
                if(data.Length != 0)
                    remoteClient.SendDirEventsReply(queryID, data);
            }
            else //Send the remaining as they are under 10
                remoteClient.SendDirEventsReply(queryID, ReturnValues);
        }
        /// <summary>
        ///   Searches for events with the given parameters
        /// </summary>
        /// <param name = "queryText"></param>
        /// <param name = "flags"></param>
        /// <param name = "StartQuery"></param>
        /// <returns></returns>
        public DirEventsReplyData[] FindEvents(string queryText, uint eventFlags, int StartQuery)
        {
            List <DirEventsReplyData> Data = new List <DirEventsReplyData>();

            QueryFilter filter = new QueryFilter();

            //|0| means search between some days
            if (queryText.Contains("|0|"))
            {
                string StringDay = queryText.Split('|')[0];
                if (StringDay == "u") //"u" means search for events that are going on today
                {
                    filter.andGreaterThanEqFilters["UNIX_TIMESTAMP(date)"] = Util.ToUnixTime(DateTime.Today);
                }
                else
                {
                    //Pull the day out then and search for that many days in the future/past
                    int      Day         = int.Parse(StringDay);
                    DateTime SearchedDay = DateTime.Today.AddDays(Day);
                    //We only look at one day at a time
                    DateTime NextDay = SearchedDay.AddDays(1);
                    filter.andGreaterThanEqFilters["UNIX_TIMESTAMP(date)"] = Util.ToUnixTime(SearchedDay);
                    filter.andLessThanEqFilters["UNIX_TIMESTAMP(date)"]    = Util.ToUnixTime(NextDay);
                    filter.andLessThanEqFilters["flags"] = (int)eventFlags;
                }
            }
            else
            {
                filter.andLikeFilters["name"] = "%" + queryText + "%";
            }

            List <string> retVal = GD.Query(new string[] {
                "EID",
                "creator",
                "date",
                "maturity",
                "flags",
                "name"
            }, "asevents", filter, null, (uint)StartQuery, 50);

            if (retVal.Count > 0)
            {
                DirEventsReplyData replyData;
                for (int i = 0; i < retVal.Count; i += 6)
                {
                    replyData = new DirEventsReplyData
                    {
                        eventID = Convert.ToUInt32(retVal[i]),
                        ownerID = new UUID(retVal[i + 1]),
                        name    = retVal[i + 5],
                    };
                    DateTime date = DateTime.Parse(retVal[i + 2].ToString());
                    replyData.date       = date.ToString(new DateTimeFormatInfo());
                    replyData.unixTime   = (uint)Util.ToUnixTime(date);
                    replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]);

                    //Check the maturity levels
                    uint maturity = Convert.ToUInt32(retVal[i + 3]);
                    if (
                        (maturity == 0 && (eventFlags & (uint)DirectoryManager.EventFlags.PG) == (uint)DirectoryManager.EventFlags.PG) ||
                        (maturity == 1 && (eventFlags & (uint)DirectoryManager.EventFlags.Mature) == (uint)DirectoryManager.EventFlags.Mature) ||
                        (maturity == 2 && (eventFlags & (uint)DirectoryManager.EventFlags.Adult) == (uint)DirectoryManager.EventFlags.Adult)
                        )
                    {
                        Data.Add(replyData);
                    }
                }
            }

            return(Data.ToArray());
        }
        /// <summary>
        /// Retrives all events in the given region by their maturity level
        /// </summary>
        /// <param name="regionName"></param>
        /// <param name="maturity">Uses DirectoryManager.EventFlags to determine the maturity requested</param>
        /// <returns></returns>
        public DirEventsReplyData[] FindAllEventsInRegion(string regionName, int maturity)
        {
            List<DirEventsReplyData> Data = new List<DirEventsReplyData>();
            
            List<string> retVal = GD.Query("ESimName", regionName, "events", "EOwnerID,EName,EID,EDate,EFlags,EMature");
            
            if (retVal.Count == 0)
                return Data.ToArray();
            
            DirEventsReplyData replyData = new DirEventsReplyData();
            for (int i = 0; i < retVal.Count; i += 6)
            {
                //Check maturity level
                if(int.Parse(retVal[i+5]) != maturity)
                    continue;

                replyData.ownerID = new UUID(retVal[i]);
                replyData.name = retVal[i + 1];
                replyData.eventID = Convert.ToUInt32(retVal[i + 2]);

                //Parse the date for the viewer
                DateTime date = Util.ToDateTime(ulong.Parse(retVal[i + 3]));
                replyData.date = date.ToString(new System.Globalization.DateTimeFormatInfo());
                replyData.unixTime = (uint)Util.ToUnixTime(date);

                replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]);
                Data.Add(replyData);
                replyData = new DirEventsReplyData();
            }

            return Data.ToArray();
        }
        /// <summary>
        /// Searches for events with the given parameters
        /// </summary>
        /// <param name="queryText"></param>
        /// <param name="flags"></param>
        /// <param name="StartQuery"></param>
        /// <returns></returns>
        public DirEventsReplyData[] FindEvents(string queryText, string flags, int StartQuery)
        {
            List<DirEventsReplyData> Data = new List<DirEventsReplyData>();
            string whereClause = "";
            uint eventFlags = uint.Parse(flags);
            //|0| means search between some days
            if (queryText.Contains("|0|"))
            {
                string StringDay = queryText.Split('|')[0];
                if (StringDay == "u") //"u" means search for events that are going on today
                {
                    whereClause = " EDate >= '" + Util.ToUnixTime(DateTime.Today) + "' LIMIT " + StartQuery.ToString() + ",50 ";
                }
                else
                {
                    //Pull the day out then and search for that many days in the future/past
                    int Day = int.Parse(StringDay);
                    DateTime SearchedDay = DateTime.Today.AddDays(Day);
                    //We only look at one day at a time
                    DateTime NextDay = SearchedDay.AddDays(1);
                    whereClause = " EDate >= '" + Util.ToUnixTime(SearchedDay) + "' and EDate <= '" + Util.ToUnixTime(NextDay) + "' and EFlags <= '" + flags + "' LIMIT " + StartQuery.ToString() + ",50 ";
                }
            }
            else
            {
                //Else, search for the search term
                whereClause = " EName LIKE '%" + queryText + "%' LIMIT " + StartQuery.ToString() + ",50 ";
            }
            List<string> retVal = GD.Query(whereClause, "events", "EOwnerID,EName,EID,EDate,EFlags,EMature");
            if (retVal.Count == 0)
                return Data.ToArray();

            DirEventsReplyData replyData;
            for (int i = 0; i < retVal.Count; i += 6)
            {
                replyData = new DirEventsReplyData();
                replyData.ownerID = new UUID(retVal[i]);
                replyData.name = retVal[i + 1];
                replyData.eventID = Convert.ToUInt32(retVal[i + 2]);
                DateTime date = Util.ToDateTime(ulong.Parse(retVal[i + 3]));
                replyData.date = date.ToString(new System.Globalization.DateTimeFormatInfo());
                replyData.unixTime = (uint)Util.ToUnixTime(date);
                replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]);

                //Check the maturity levels
                if (Convert.ToInt32(retVal[i + 5]) == 2 && (eventFlags & (uint)DirectoryManager.EventFlags.Adult) == (uint)DirectoryManager.EventFlags.Adult)
                    Data.Add(replyData);
                else if (Convert.ToInt32(retVal[i + 5]) == 1 && (eventFlags & (uint)DirectoryManager.EventFlags.Mature) == (uint)DirectoryManager.EventFlags.Mature)
                    Data.Add(replyData);
                else if (Convert.ToInt32(retVal[i + 5]) == 0 && (eventFlags & (uint)DirectoryManager.EventFlags.PG) == (uint)DirectoryManager.EventFlags.PG)
                    Data.Add(replyData);
            }

            return Data.ToArray();
        }
        public DirEventsReplyData[] FindAllEventsInRegion(string regionName)
        {
            List<DirEventsReplyData> Data = new List<DirEventsReplyData>();
            List<string> retVal = GD.Query("ESimName", regionName, "events", "EOwnerID,EName,EID,EDate,EFlags");
            if (retVal.Count == 0)
                return Data.ToArray();
            int DataCount = 0;
            DirEventsReplyData replyData = new DirEventsReplyData();
            for (int i = 0; i < retVal.Count; i++)
            {
                if (DataCount == 0)
                    replyData.ownerID = new UUID(retVal[i]);
                if (DataCount == 1)
                    replyData.name = retVal[i];
                if (DataCount == 2)
                    replyData.eventID = Convert.ToUInt32(retVal[i]);
                if (DataCount == 3)
                {
                    DateTime date = Util.ToDateTime(ulong.Parse(retVal[i]));
                    replyData.date = date.ToString(new System.Globalization.DateTimeFormatInfo());
                    replyData.unixTime = (uint)Util.ToUnixTime(date);
                }
                if (DataCount == 4)
                    replyData.eventFlags = Convert.ToUInt32(retVal[i]);
                DataCount++;
                if (DataCount == 5)
                {
                    DataCount = 0;
                    Data.Add(replyData);
                    replyData = new DirEventsReplyData();
                }
            }

            return Data.ToArray();
        }
Example #10
0
        public void DirEventsQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            DirEventsReplyData[] ReturnValues = DSC.FindEvents(queryText, queryFlags.ToString(), queryStart);

            if (ReturnValues.Length > 10)
            {
                DirEventsReplyData[] data = new DirEventsReplyData[10];
                int i = 0;

                foreach (DirEventsReplyData d in ReturnValues)
                {
                    data[i] = d;
                    i++;
                    if (i == 10)
                    {
                        remoteClient.SendDirEventsReply(queryID, data);
                        i = 0;
                        if (data.Length - i < 10)
                        {
                            data = new DirEventsReplyData[data.Length - i];
                        }
                        else
                        {
                            data = new DirEventsReplyData[10];
                        }
                    }
                }
                remoteClient.SendDirEventsReply(queryID, data);
            }
            else
                remoteClient.SendDirEventsReply(queryID, ReturnValues);
        }
        public DirEventsReplyData[] FindAllEventsInRegion(string regionName, int maturity)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["REGIONNAME"] = regionName;
            sendData["MATURITY"] = maturity;
            sendData["METHOD"] = "findeventsinregion";

            string reqString = WebUtils.BuildQueryString(sendData);
            List<DirEventsReplyData> Events = new List<DirEventsReplyData>();
            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>;
                                DirEventsReplyData direvent = new DirEventsReplyData(valuevalue);
                                Events.Add(direvent);
                            }
                        }
                    }
                }
                return Events.ToArray();
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString());
            }
            return Events.ToArray();
        }
        public DirEventsReplyData[] FindEvents(string queryText, string flags, int StartQuery)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["QUERYTEXT"] = queryText;
            sendData["FLAGS"] = flags;
            sendData["STARTQUERY"] = StartQuery;
            sendData["METHOD"] = "findevents";

            string reqString = WebUtils.BuildQueryString(sendData);
            List<DirEventsReplyData> Events = new List<DirEventsReplyData>();
            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>;
                                DirEventsReplyData direvent = new DirEventsReplyData(valuevalue);
                                Events.Add(direvent);
                            }
                        }
                    }
                }
                return Events.ToArray();
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString());
            }
            return Events.ToArray();
        }
Example #13
0
        public void DirEventsQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            // Flags are going to be 0 or 32 for Mature
            // We also know text comes in 3 segments X|Y|Text where X is the day difference from
            // the current day, Y is the category to search, Text is the user input for search string
            // so let's 'split up the queryText to get our values we need first off
            string eventTime     = "";
            string eventCategory = "";
            string userText      = "";

            queryText = queryText.Trim();   // newer viewers sometimes append a space

            string[] querySplode = queryText.Split(new Char[] { '|' });
            if (querySplode.Length > 0)
            {
                eventTime = querySplode[0];
            }
            if (querySplode.Length > 1)
            {
                eventCategory = querySplode[1];
            }
            if (querySplode.Length > 0)
            {
                userText = querySplode[2];
                userText = userText.Trim();   // newer viewers sometimes append a space
            }

            // Ok we have values, now we need to do something with all this lovely information
            string query       = "";
            string searchStart = Convert.ToString(queryStart);
            int    count       = 100;

            DirEventsReplyData[] data = new DirEventsReplyData[count];
            string searchEnd          = Convert.ToString(queryStart + count);
            int    i = 0;
            int    unixEventUpcomingEndDateToCheck = 0;

            int eventTimeAmt = 0;
            int unixEventDateToCheckMidnight    = 0;
            int unixEventEndDateToCheckMidnight = 0;

            string sqlAddTerms = "";

            DateTime saveNow = DateTime.Now;
            int      startDateCheck;

            // Quick catch to see if the eventTime is set to "u" for In Progress & Upcoming Radio button
            if (eventTime == "u")
            {
                DateTime eventUpcomingEndDateToCheck         = saveNow.AddDays(+7);
                DateTime eventUpcomingEndDateToCheckMidnight = new DateTime(eventUpcomingEndDateToCheck.Year, eventUpcomingEndDateToCheck.Month, eventUpcomingEndDateToCheck.Day);
                unixEventUpcomingEndDateToCheck = Util.ToUnixTime(eventUpcomingEndDateToCheckMidnight);

                // for "in progress" events, show everything that has started within the last three hours (arbitrary)
                startDateCheck = Util.ToUnixTime(saveNow.AddHours(-3.0));
                sqlAddTerms    = " where (dateUTC>=?startDateCheck AND dateUTC<=?unixEventUpcomingEndDateToCheck)";
            }
            else
            {
                // we need the current date, in order to subtract/add the days to view, or see the week upcoming.
                // this will probably be some really ugly code :)
                startDateCheck = Util.ToUnixTime(saveNow);
                eventTimeAmt   = Convert.ToInt16(eventTime);
                DateTime eventDateToCheck    = saveNow.AddDays(Convert.ToInt16(eventTime));
                DateTime eventEndDateToCheck = new DateTime();
                if (eventTime == "0")
                {
                    eventEndDateToCheck = saveNow.AddDays(+2);
                }
                else
                {
                    eventEndDateToCheck = saveNow.AddDays(eventTimeAmt + 1);
                }
                // now truncate the information so we get the midnight value (and yes David, I'm sure there's an
                // easier way to do this, but this will work for now :)  )
                DateTime eventDateToCheckMidnight    = new DateTime(eventDateToCheck.Year, eventDateToCheck.Month, eventDateToCheck.Day);
                DateTime eventEndDateToCheckMidnight = new DateTime(eventEndDateToCheck.Year, eventEndDateToCheck.Month, eventEndDateToCheck.Day);


                // this is the start unix timestamp to look for, we still need the end which is the next day, plus
                // we need the week end unix timestamp for the In Progress & upcoming radio button
                unixEventDateToCheckMidnight    = Util.ToUnixTime(eventDateToCheckMidnight);
                unixEventEndDateToCheckMidnight = Util.ToUnixTime(eventEndDateToCheckMidnight);

                sqlAddTerms = " where (dateUTC>=?unixEventDateToCheck AND dateUTC<=?unixEventEndDateToCheckMidnight)";
            }

            if ((queryFlags & ((uint)DirFindFlags.IncludeAdult | (uint)DirFindFlags.IncludeAdult | (uint)DirFindFlags.IncludeAdult)) == 0)
            {
                // don't just give them an empty list...
                remoteClient.SendAlertMessage("You must included at least one maturity rating.");
                remoteClient.SendDirEventsReply(queryID, data);
                return;
            }

            // Event DB storage does not currently support adult events, so if someone asks for adult, search mature for now.
            if ((queryFlags & (uint)DirFindFlags.IncludeAdult) != 0)
            {
                queryFlags |= (uint)DirFindFlags.IncludeMature;
            }

            if ((queryFlags & (uint)DirFindFlags.IncludeMature) != 0)
            {
                // they included mature and possibly others
                if ((queryFlags & (uint)DirFindFlags.IncludePG) == 0)
                {
                    sqlAddTerms += " AND mature='true'";   // exclude PG
                }
            }
            if ((queryFlags & (uint)DirFindFlags.IncludePG) != 0)
            {
                // they included PG and possibly others
                if ((queryFlags & (uint)DirFindFlags.IncludeMature) == 0)
                {
                    sqlAddTerms += " AND mature='false'";  // exclude mature
                }
            }

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

            if (userText != "")
            {
                sqlAddTerms += " AND (description LIKE ?userText OR name LIKE ?userText)";
            }

            // Events results should come back sorted by date
            sqlAddTerms += " order by dateUTC ASC";

            query = "select owneruuid, name, eventid, dateUTC, eventflags from events" + sqlAddTerms + " limit " + searchStart + ", " + searchEnd + "";

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

            parms.Add("?startDateCheck", Convert.ToString(startDateCheck));
            parms.Add("?unixEventUpcomingEndDateToCheck", Convert.ToString(unixEventUpcomingEndDateToCheck));
            parms.Add("?unixEventDateToCheck", Convert.ToString(unixEventDateToCheckMidnight));
            parms.Add("?unixEventEndDateToCheckMidnight", Convert.ToString(unixEventEndDateToCheckMidnight));
            parms.Add("?category", eventCategory);
            parms.Add("?userText", "%" + Convert.ToString(userText) + "%");

            using (ISimpleDB db = _connFactory.GetConnection())
            {
                List <Dictionary <string, string> > results = db.QueryWithResults(query, parms);
                foreach (Dictionary <string, string> row in results)
                {
                    data[i]         = new DirEventsReplyData();
                    data[i].ownerID = new UUID(row["owneruuid"].ToString());
                    data[i].name    = row["name"].ToString();
                    data[i].eventID = Convert.ToUInt32(row["eventid"]);

                    // need to convert the unix timestamp we get into legible date for viewer
                    DateTime localViewerEventTime = Util.UnixToLocalDateTime(Convert.ToInt32(row["dateUTC"]));
                    string   newSendingDate       = String.Format("{0:MM/dd hh:mm tt}", localViewerEventTime);

                    data[i].date       = newSendingDate;
                    data[i].unixTime   = Convert.ToUInt32(row["dateUTC"]);
                    data[i].eventFlags = Convert.ToUInt32(row["eventflags"]);
                    i++;
                    if (i >= count)
                    {
                        break;
                    }
                }
            }
            remoteClient.SendDirEventsReply(queryID, data);
        }
        /// <summary>
        /// Searches for events with the given parameters
        /// </summary>
        /// <param name="queryText"></param>
        /// <param name="flags"></param>
        /// <param name="StartQuery"></param>
        /// <returns></returns>
        public DirEventsReplyData[] FindEvents(string queryText, string flags, int StartQuery)
        {
            List <DirEventsReplyData> Data = new List <DirEventsReplyData>();
            string whereClause             = "";
            uint   eventFlags = uint.Parse(flags);

            //|0| means search between some days
            if (queryText.Contains("|0|"))
            {
                string StringDay = queryText.Split('|')[0];
                if (StringDay == "u") //"u" means search for events that are going on today
                {
                    whereClause = " EDate >= '" + Util.ToUnixTime(DateTime.Today) + "' LIMIT " + StartQuery.ToString() + ",50 ";
                }
                else
                {
                    //Pull the day out then and search for that many days in the future/past
                    int      Day         = int.Parse(StringDay);
                    DateTime SearchedDay = DateTime.Today.AddDays(Day);
                    //We only look at one day at a time
                    DateTime NextDay = SearchedDay.AddDays(1);
                    whereClause = " EDate >= '" + Util.ToUnixTime(SearchedDay) + "' and EDate <= '" + Util.ToUnixTime(NextDay) + "' and EFlags <= '" + flags + "' LIMIT " + StartQuery.ToString() + ",50 ";
                }
            }
            else
            {
                //Else, search for the search term
                whereClause = " EName LIKE '%" + queryText + "%' LIMIT " + StartQuery.ToString() + ",50 ";
            }
            List <string> retVal = GD.Query(whereClause, "events", "EOwnerID,EName,EID,EDate,EFlags,EMature");

            if (retVal.Count == 0)
            {
                return(Data.ToArray());
            }

            DirEventsReplyData replyData;

            for (int i = 0; i < retVal.Count; i += 6)
            {
                replyData         = new DirEventsReplyData();
                replyData.ownerID = new UUID(retVal[i]);
                replyData.name    = retVal[i + 1];
                replyData.eventID = Convert.ToUInt32(retVal[i + 2]);
                DateTime date = Util.ToDateTime(ulong.Parse(retVal[i + 3]));
                replyData.date       = date.ToString(new System.Globalization.DateTimeFormatInfo());
                replyData.unixTime   = (uint)Util.ToUnixTime(date);
                replyData.eventFlags = Convert.ToUInt32(retVal[i + 4]);

                //Check the maturity levels
                if (Convert.ToInt32(retVal[i + 5]) == 2 && (eventFlags & (uint)DirectoryManager.EventFlags.Adult) == (uint)DirectoryManager.EventFlags.Adult)
                {
                    Data.Add(replyData);
                }
                else if (Convert.ToInt32(retVal[i + 5]) == 1 && (eventFlags & (uint)DirectoryManager.EventFlags.Mature) == (uint)DirectoryManager.EventFlags.Mature)
                {
                    Data.Add(replyData);
                }
                else if (Convert.ToInt32(retVal[i + 5]) == 0 && (eventFlags & (uint)DirectoryManager.EventFlags.PG) == (uint)DirectoryManager.EventFlags.PG)
                {
                    Data.Add(replyData);
                }
            }

            return(Data.ToArray());
        }