public List <GridRegion> Get(RegionFlags flags)
        {
            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters ["Flags"] = (uint)flags;
            return(ParseQuery(null, GD.Query(new string [] { "*" }, m_realm, filter, null, null, null)));
        }
        public uint Count(uint estateID, RegionFlags flags)
        {
            IEstateConnector estates = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (estates == null)
            {
                return(0);
            }

            EstateSettings es = estates.GetEstateSettings((int)estateID);

            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters["Flags"] = (uint)flags;

            List <GridRegion> query = ParseQuery(null, GD.Query(new string[] { "*" }, m_realm, filter, null, null, null));

            uint count = 0;

            query.ForEach(delegate(GridRegion region)
            {
                if (region.EstateOwner == es.EstateOwner &&
                    estates.GetEstateID(region.RegionID) == es.EstateID)
                {
                    ++count;
                }
            });

            return(count);
        }
示例#3
0
        OSDMap GetRegions(OSDMap map)
        {
            OSDMap      resp  = new OSDMap();
            RegionFlags type  = map.Keys.Contains("RegionFlags") ? (RegionFlags)map ["RegionFlags"].AsInteger() : RegionFlags.RegionOnline;
            int         start = map.Keys.Contains("Start") ? map ["Start"].AsInteger() : 0;

            if (start < 0)
            {
                start = 0;
            }
            int count = map.Keys.Contains("Count") ? map ["Count"].AsInteger() : 10;

            if (count < 0)
            {
                count = 1;
            }

            var regiondata = DataPlugins.RequestPlugin <IRegionData> ();

            Dictionary <string, bool> sort = new Dictionary <string, bool> ();

            string [] supportedSort =
            {
                "SortRegionName",
                "SortLocX",
                "SortLocY"
            };

            foreach (string sortable in supportedSort)
            {
                if (map.ContainsKey(sortable))
                {
                    sort [sortable.Substring(4)] = map [sortable].AsBoolean();
                }
            }

            List <GridRegion> regions = regiondata.Get(type, sort);
            OSDArray          Regions = new OSDArray();

            if (start < regions.Count)
            {
                int i = 0;
                int j = regions.Count <= (start + count) ? regions.Count : (start + count);
                for (i = start; i < j; ++i)
                {
                    Regions.Add(regions [i].ToOSD());
                }
            }
            resp ["Start"]   = OSD.FromInteger(start);
            resp ["Count"]   = OSD.FromInteger(count);
            resp ["Total"]   = OSD.FromInteger(regions.Count);
            resp ["Regions"] = Regions;
            return(resp);
        }
        public uint Count(RegionFlags includeFlags, RegionFlags excludeFlags)
        {
            QueryFilter filter = new QueryFilter();

            if (includeFlags > 0)
            {
                filter.andBitfieldAndFilters ["Flags"] = (uint)includeFlags;
            }
            if (excludeFlags > 0)
            {
                filter.andBitfieldNandFilters ["Flags"] = (uint)excludeFlags;
            }

            return(uint.Parse(GD.Query(new string [] { "COUNT(*)" }, m_realm, filter, null, null, null) [0]));
        }
        public List <GridRegion> Get(RegionFlags includeFlags, RegionFlags excludeFlags, uint?start, uint?count,
                                     Dictionary <string, bool> sort)
        {
            QueryFilter filter = new QueryFilter();

            if (includeFlags > 0)
            {
                filter.andBitfieldAndFilters ["Flags"] = (uint)includeFlags;
            }
            if (excludeFlags > 0)
            {
                filter.andBitfieldNandFilters ["Flags"] = (uint)excludeFlags;
            }

            return(ParseQuery(null, GD.Query(new string [] { "*" }, m_realm, filter, sort, start, count)));
        }
        public List <GridRegion> Get(uint start, uint count, uint estateID, RegionFlags flags,
                                     Dictionary <string, bool> sort)
        {
            List <GridRegion> resp    = new List <GridRegion>();
            IEstateConnector  estates = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (count == 0 || estates == null)
            {
                return(resp);
            }

            EstateSettings es = estates.GetEstateSettings((int)estateID);

            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters["Flags"] = (uint)flags;

            while (resp.Count < count)
            {
                uint limit = count - (uint)resp.Count;
                List <GridRegion> query = ParseQuery(null,
                                                     GD.Query(new string[] { "*" }, m_realm, filter, sort, start, count));

                if (query.Count == 0)
                {
                    break;
                }

                query.ForEach(delegate(GridRegion region)
                {
                    if (region.EstateOwner == es.EstateOwner &&
                        estates.GetEstateID(region.RegionID) == es.EstateID)
                    {
                        resp.Add(region);
                    }
                });

                start += limit;
            }

            return(resp);
        }
 public List <GridRegion> Get(RegionFlags flags, Dictionary <string, bool> sort)
 {
     return(Get(flags, 0, null, null, sort));
 }