public EventData CreateEvent(UUID creator, UUID regionID, UUID parcelID, DateTime date, uint cover, EventFlags maturity, uint flags, uint duration, Vector3 localPos, string name, string description, string category)
        {
            object remoteValue = DoRemote(creator, regionID, parcelID, date, cover, maturity, flags, duration, localPos, name, description, category);
            if (remoteValue != null || m_doRemoteOnly)
                return (EventData)remoteValue;

            IRegionData regiondata = DataManager.DataManager.RequestPlugin<IRegionData>();
            IParcelServiceConnector parceldata = DataManager.DataManager.RequestPlugin<IParcelServiceConnector>();
            if(regiondata == null || parceldata == null){
                return null;
            }

            GridRegion region = regiondata.Get(regionID, null);
            if(region == null){
                return null;
            }
            if (parcelID != UUID.Zero)
            {
                LandData parcel = parceldata.GetLandData(region.RegionID, parcelID);
                if (parcel == null)
                {
                    return null;
                }
            }


            EventData eventData = new EventData
                                      {
                                          eventID = GetMaxEventID() + 1,
                                          creator = creator.ToString(),
                                          simName = region.RegionName,
                                          date = date.ToString(new DateTimeFormatInfo()),
                                          dateUTC = (uint) Util.ToUnixTime(date),
                                          amount = cover,
                                          cover = cover,
                                          maturity = (int) maturity,
                                          eventFlags = flags | (uint) maturity,
                                          duration = duration,
                                          globalPos = new Vector3(
                                              region.RegionLocX + localPos.X,
                                              region.RegionLocY + localPos.Y,
                                              region.RegionLocZ + localPos.Z
                                              ),
                                          name = name,
                                          description = description,
                                          category = category
                                      };

            Dictionary<string, object> row = new Dictionary<string, object>(15);
            row["EID"] = eventData.eventID;
            row["creator"] = creator.ToString();
            row["region"] = regionID.ToString();
            row["parcel"] = parcelID.ToString();
            row["date"] = date.ToString("s");
            row["cover"] = eventData.cover;
            row["maturity"] = (uint)maturity;
            row["flags"] = flags;
            row["duration"] = duration;
            row["localPosX"] = localPos.X;
            row["localPosY"] = localPos.Y;
            row["localPosZ"] = localPos.Z;
            row["name"] = name;
            row["description"] = description;
            row["category"] = category;

            GD.Insert("asevents", row);

            return eventData;
        }
        public void EventInfoRequest(IClientAPI remoteClient, uint queryEventID)
        {
            Hashtable ReqHash = new Hashtable();
            ReqHash["eventID"] = queryEventID.ToString();

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

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

            ArrayList dataArray = (ArrayList)result["data"];
            if (dataArray.Count == 0)
            {
                // something bad happened here, if we could return an
                // event after the search,
                // we should be able to find it here
                // TODO do some (more) sensible error-handling here
                remoteClient.SendAgentAlertMessage("Couldn't find this event.",
                        false);
                return;
            }

            Hashtable d = (Hashtable)dataArray[0];
            EventData data = new EventData();
            data.eventID = Convert.ToUInt32(d["event_id"]);
            data.creator = d["creator"].ToString();
            data.name = d["name"].ToString();
            data.category = d["category"].ToString();
            data.description = d["description"].ToString();
            data.date = d["date"].ToString();
            data.dateUTC = Convert.ToUInt32(d["dateUTC"]);
            data.duration = Convert.ToUInt32(d["duration"]);
            data.cover = Convert.ToUInt32(d["covercharge"]);
            data.amount = Convert.ToUInt32(d["coveramount"]);
            data.simName = d["simname"].ToString();
            Vector3.TryParse(d["globalposition"].ToString(), out data.globalPos);
            data.eventFlags = Convert.ToUInt32(d["eventflags"]);

            remoteClient.SendEventInfoReply(data);
        }
        private static List<EventData> Query2EventData(List<string> RetVal){
            List<EventData> Events = new List<EventData>();
            IRegionData regiondata = DataManager.DataManager.RequestPlugin<IRegionData>();
            if (RetVal.Count % 16 != 0 || regiondata == null)
            {
                return Events;
            }

            for (int i = 0; i < RetVal.Count; i += 16)
            {
                EventData data = new EventData();

                GridRegion region = regiondata.Get(UUID.Parse(RetVal[2]), null);
                if (region == null)
                {
                    continue;
                }
                data.simName = region.RegionName;

                data.eventID = Convert.ToUInt32(RetVal[i]);
                data.creator = RetVal[i + 1];

                //Parse the time out for the viewer
                DateTime date = DateTime.Parse(RetVal[i + 4]);
                data.date = date.ToString(new DateTimeFormatInfo());
                data.dateUTC = (uint)Util.ToUnixTime(date);

                data.cover = data.amount = Convert.ToUInt32(RetVal[i + 5]);
                data.maturity = Convert.ToInt32(RetVal[i + 6]);
                data.eventFlags = Convert.ToUInt32(RetVal[i + 7]);
                data.duration = Convert.ToUInt32(RetVal[i + 8]);

                data.globalPos = new Vector3(
                        region.RegionLocX + float.Parse(RetVal[i + 9]),
                        region.RegionLocY + float.Parse(RetVal[i + 10]),
                        region.RegionLocZ + float.Parse(RetVal[i + 11])
                );

                data.name = RetVal[i + 12];
                data.description = RetVal[i + 13];
                data.category = RetVal[i + 14];

                Events.Add(data);
            }

            return Events;
        }
        public EventData CreateEvent(UUID creator, UUID regionID, UUID parcelID, DateTime date, uint cover, EventFlags maturity, uint flags, uint duration, Vector3 localPos, string name, string description, string category)
        {
            IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin<IRegionData>();
            IParcelServiceConnector parceldata = Aurora.DataManager.DataManager.RequestPlugin<IParcelServiceConnector>();
            if(regiondata == null || parceldata == null){
                return null;
            }

            GridRegion region = regiondata.Get(regionID, UUID.Zero);
            if(region == null){
                return null;
            }
            if (parcelID != UUID.Zero)
            {
                LandData parcel = parceldata.GetLandData(region.RegionID, parcelID);
                if (parcel == null)
                {
                    return null;
                }
            }


            EventData eventData = new EventData();
            eventData.eventID = GetMaxEventID() + 1;
            eventData.creator = creator.ToString();
            eventData.simName = region.RegionName;
            eventData.date = date.ToString(new DateTimeFormatInfo());
            eventData.dateUTC = (uint)Util.ToUnixTime(date);
            eventData.cover = eventData.amount = cover;
            eventData.maturity = (int)maturity;
            eventData.eventFlags = flags | (uint)maturity;
            eventData.duration = duration;
            eventData.globalPos = new Vector3(
                region.RegionLocX + localPos.X,
                region.RegionLocY + localPos.Y,
                region.RegionLocZ + localPos.Z
            );
            eventData.name = name;
            eventData.description = description;
            eventData.category = category;

            GD.Insert("asevents", new string[]{
                "EID",
                "creator",
                "region",
                "parcel", 
                "date", 
                "cover", 
                "maturity", 
                "flags", 
                "duration", 
                "localPosX", 
                "localPosY", 
                "localPosZ", 
                "name",
                "description",
                "category"
            }, new object[]{
                eventData.eventID,
                creator.ToString(),
                regionID.ToString(),
                parcelID.ToString(),
                date.ToString("s"),
                eventData.cover,
                (uint)maturity,
                flags,
                duration,
                localPos.X,
                localPos.Y,
                localPos.Z,
                name,
                description,
                category
            });

            return eventData;
        }