示例#1
0
        public async Task CacheBlock(List <string> IDs)
        {
            _Logger.LogInformation($"Caching {IDs.Count} characters");

            int blockSize = 20;

            for (int i = 0; i < IDs.Count; i += blockSize)
            {
                int           count = Math.Min(blockSize, IDs.Count - i);
                List <string> block = IDs.GetRange(i, count);

                CensusQuery query = _Census.Create("character");
                foreach (string ID in block)
                {
                    query.Where("character_id").Equals(ID);
                }
                query.AddResolve("outfit");
                query.AddResolve("outfit", "online_status");
                query.ShowFields("character_id", "name", "faction_id", "outfit", "online_status");

                List <JToken> tokens = (await query.GetListAsync()).ToList();
                foreach (JToken token in tokens)
                {
                    Character?c = _ParseCharacter(token);
                    if (c != null)
                    {
                        _Cache.TryAdd(c.ID, c);
                    }
                }

                //_Logger.LogInformation($"Cached {i}/{IDs.Count} characters");
            }
            _Logger.LogInformation($"Cached all characters");
        }
        public async Task<IEnumerable<CensusMapRegionModel>> GetAllMapRegions()
        {
            var query = _queryFactory.Create("map_region");

            query.ShowFields("map_region_id", "zone_id", "facility_id", "facility_name", "facility_type_id", "facility_type");

            return await query.GetBatchAsync<CensusMapRegionModel>();
        }
示例#3
0
        public async Task <CensusOutfitModel> GetOutfitAsync(string outfitId)
        {
            var query = _queryFactory.Create("outfit");

            query.ShowFields("outfit_id", "name", "alias", "alias_lower", "time_created", "leader_character_id", "member_count");

            query.Where("outfit_id").Equals(outfitId);

            return(await query.GetAsync <CensusOutfitModel>());
        }
        public async Task <IEnumerable <CensusVehicleModel> > GetAllVehicles()
        {
            var query = _queryFactory.Create("vehicle");

            query.SetLanguage("en");

            query.ShowFields("vehicle_id", "name", "description", "type_id", "type_name", "cost", "cost_resource_id", "image_id");

            return(await query.GetBatchAsync <CensusVehicleModel>());
        }
        public async Task <CensusCharacterModel> GetCharacter(string characterId)
        {
            var query = _queryFactory.Create("character");

            query.AddResolve("world");
            query.ShowFields("character_id", "name.first", "faction_id", "world_id", "battle_rank.value", "battle_rank.percent_to_next", "certs.earned_points", "title_id", "prestige_level");
            query.Where("character_id").Equals(characterId);

            return(await query.GetAsync <CensusCharacterModel>());
        }
        public async Task <IEnumerable <CensusItemModel> > GetAllItems()
        {
            var query = _queryFactory.Create("item");

            query.SetLanguage("en");

            query.ShowFields("item_id", "item_type_id", "item_category_id", "is_vehicle_weapon", "name", "description", "faction_id", "max_stack_size", "image_id");

            return(await query.GetBatchAsync <CensusItemModel>());
        }
示例#7
0
        public async Task <IActionResult> GetCharacter(string characterName)
        {
            var query = _censusFactory.Create("character");

            query.Where("name.first_lower").StartsWith(characterName.ToLower());
            query.SetLimit(10);

            // In this example GetListAsync is passing a model to bind the response items to
            var characterList = await query.GetListAsync <CensusCharacterModel>();

            ViewData["CharacterList"] = JToken.FromObject(characterList).ToString();

            return(View("Index"));
        }
        public async Task <IEnumerable <CensusLoadoutModel> > GetAllLoadoutsAsync()
        {
            var query = _queryFactory.Create("loadout");

            query.ShowFields("loadout_id", "profile_id", "faction_id", "code_name");

            return(await query.GetBatchAsync <CensusLoadoutModel>());
        }
示例#9
0
        public async Task <IEnumerable <CensusWorldModel> > GetAllWorlds()
        {
            var query = _queryFactory.Create("world");

            query.SetLanguage("en");

            return(await query.GetBatchAsync <CensusWorldModel>());
        }
示例#10
0
        public async Task <IEnumerable <CensusZoneModel> > GetAllZones()
        {
            var query = _queryFactory.Create("zone");

            query.SetLanguage("en");

            query.ShowFields("zone_id", "code", "name", "description", "hex_size");

            return(await query.GetBatchAsync <CensusZoneModel>());
        }
示例#11
0
        public async Task <IEnumerable <CensusProfileModel> > GetAllProfilesAsync()
        {
            var query = _queryFactory.Create("profile");

            query.SetLanguage("en");

            query.ShowFields("profile_id", "profile_type_id", "faction_id", "name", "image_id");

            return(await query.GetBatchAsync <CensusProfileModel>());
        }
示例#12
0
        public async Task <IEnumerable <CensusTitleModel> > GetAllTitles()
        {
            var query = _queryFactory.Create("title");

            query.SetLanguage("en");

            query.ShowFields("title_id", "name");

            return(await query.GetBatchAsync <CensusTitleModel>());
        }
        public async Task <IEnumerable <CensusFactionModel> > GetAllFactions()
        {
            var query = _queryFactory.Create("faction");

            query.SetLanguage("en");

            query.ShowFields("faction_id", "name", "image_id", "code_tag", "user_selectable");

            return(await query.GetBatchAsync <CensusFactionModel>());
        }
示例#14
0
        public async Task <IEnumerable <CensusItemCategoryModel> > GetAllItemCategories()
        {
            var query = _queryFactory.Create("item_category");

            query.SetLanguage("en");

            query.ShowFields("item_category_id", "name");

            return(await query.GetBatchAsync <CensusItemCategoryModel>());
        }