public ActionResult <ItemsResponse <SteamGame> > GetTopSell() { try { string outputFilePath = "C:/SF.Code/gamedeals/middletier/GamesDeals.Services/Scraper/Output/SteamScraper.Jsonl"; List <SteamGame> items = new List <SteamGame>(); SteamScraper scraper = new SteamScraper(); System.IO.File.WriteAllText(@outputFilePath, string.Empty); scraper.Start(); ItemsResponse <SteamGame> response = new ItemsResponse <SteamGame>(); using (StreamReader reader = new StreamReader(outputFilePath)) { string json = reader.ReadToEnd(); response.Items = JsonConvert.DeserializeObject <List <SteamGame> >(json); } return(Ok200(response)); } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public SteamUserDetails GetByUserID(long id, bool reloadWishlistPrices = false) { DataCacheRepository repo = _uow.GetRepo <DataCacheRepository>(); DataCache cache = repo.Get(id, CacheType.SteamUserDetails); if (cache != null && cache.StoredOn > DateTime.Now.AddHours(-1)) { SteamUserDetails user = cache.Deserialize <SteamUserDetails>(); if (reloadWishlistPrices) { LoadWishlistPrices(user); user.Wishlist = user.Wishlist.OrderByDescending(x => x.Pricing.IsOnSale).ToList(); } return(user); } SteamUserDetails userDetails = new SteamUserDetails { User = _steamApi.GetPlayerSummary(id), OwnedApps = _steamApi.GetOwnedApps(id) }; SteamScraper scraper = new SteamScraper(); long? lastPlayedID = scraper.GetLastPlayedGame(userDetails.User.ProfileUrl); if (lastPlayedID.HasValue) { userDetails.LastPlayedGame = _steamApi.GetAppStoreDetails(lastPlayedID.Value); } List <long> wishlistIDs = scraper.GetWishlist(userDetails.User.ProfileUrl); foreach (long wishlistID in wishlistIDs) { userDetails.Wishlist.Add(_steamApi.GetAppStoreDetails(wishlistID)); } userDetails.Wishlist = userDetails.Wishlist.OrderByDescending(x => x.Pricing != null && x.Pricing.IsOnSale).ToList(); userDetails.SteamLevel = _steamApi.GetSteamLevel(userDetails.User.ID); userDetails.Friends = _steamApi.GetFriendList(userDetails.User.ID); bool isNew = cache == null; cache = new DataCache { EntityID = userDetails.User.ID.ToString(), CacheTypeID = CacheType.SteamUserDetails, StoredOn = DateTime.Now, JsonData = JsonConvert.SerializeObject(userDetails) }; if (isNew) { repo.Add(cache); } else { repo.Update(cache); } return(userDetails); }