예제 #1
0
        private async Task RebuildRefTypeItem()
        {
            var server = Factory.Create <IEveApi>().Server;
            var result = await WebServiceConsumer.Consume <DefaultRestClient, XmlDeserializer, RefTypeItemCollection>($"{server.XMLApi}eve/RefTypes.xml.aspx");

            await EveCache.SetCache(result.Items);
        }
예제 #2
0
        private async Task RebuildRegionsAndSolarSystems()
        {
            var eve          = Factory.Create <IEveApi>();
            var regions      = (await this.ConsumeUntil <RegionCollection>((await eve.GetMotdAsync()).Regions.HRef, x => x.Next == null ? null : x.Next.HRef)).SelectMany(x => x.Items);
            var solarSystems = (await this.ConsumeUntil <SolarSystemCollection>((await eve.GetMotdAsync()).SolarSystems.HRef, x => x.Next == null ? null : x.Next.HRef)).SelectMany(x => x.Items);

            await EveCache.SetCache(regions);

            await EveCache.SetCache(solarSystems);
        }
예제 #3
0
        public async Task <IEnumerable <CharacterName> > GetCharacterNamesAsync(long[] characterIds)
        {
            if (characterIds.Length == 0)
            {
                return(new CharacterName[0]);
            }

            // If not loaded... Load it
            try
            {
                if (_characterNames.Count == 0)
                {
                    _characterNames.AddRange(await EveCache.GetCacheCollection <CharacterName>());
                }
            }
            catch
            {
                // Happens... And expected if cache is not available... But too lazy to correctly handle this
            }

            var notFound = characterIds.Where(x => _characterNames.All(y => y.CharacterId != x));

            if (!notFound.Any() && _characterNames.Count > 0)
            {
                return(_characterNames.Where(x => characterIds.Contains(x.CharacterId)));
            }

            var result = await WebServiceConsumer.Consume <DefaultRestClient, XmlDeserializer, CharacterNameCollection>(
                $"{this.Server.XMLApi}eve/CharacterName.xml.aspx?ids={(_characterNames.Count == 0 ? characterIds : notFound).Join(",")}");

            _characterNames.AddRange(result.Items);

            if (result.Items.Any())
            {
                await EveCache.SetCache(_characterNames);
            }

            return(_characterNames.Where(x => characterIds.Contains(x.CharacterId)));
        }