Exemple #1
0
        public async Task RefreshItems(bool forceRefresh = false)
        {
            const string itemCacheFilePath = "./item-cache.json";

            if (!forceRefresh && File.Exists(itemCacheFilePath))
            {
                string json;
                using (var reader = new StreamReader(itemCacheFilePath))
                {
                    json = reader.ReadToEnd();
                }
                var dataset = JsonConvert.DeserializeObject <IEnumerable <ItemWithStatistics> >(json);
                _itemCacheService.InitializeCache(dataset);
                Log.Information("Item Cache Loaded");
            }
            else
            {
                var items = await _itemCacheService.GetItems(forceRefresh : true);

                var json = JsonConvert.SerializeObject(items);
                using (var writer = new StreamWriter(itemCacheFilePath))
                {
                    writer.Write(json);
                }
                Log.Information("Items Loaded");
            }
        }
Exemple #2
0
 public async Task <IEnumerable <string> > GetItemManifest()
 {
     return((await _itemCacheService.GetItems()).Select(item => item.UrlName));
 }