private async Task LoadCache() { this.LoadStaticData(); try { // We are relying on an exception that happens here if the cache is not available await EveCache.GetCacheCollection <SolarSystem>(); await EveCache.GetCacheCollection <Region>(); await EveCache.GetCacheCollection <RefTypeItem>(); this.CacheRebuildRequired = false; } catch { this.CacheRebuildRequired = true; } }
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))); }