예제 #1
0
 public Data Execute(string url)
 {
     StringReader reader = null;
     Data DetailGame = null;
     try
     {
         WebClient wc = new WebClient();
         string xmlString = wc.DownloadString(url);
         DetailGame = new Data();
         XmlSerializer serializer = new XmlSerializer(typeof(Data));
         reader = new StringReader(xmlString);
         DetailGame = (Data)serializer.Deserialize(reader);
         return DetailGame;
     }
     catch(Exception ex)
     {
         Utitlity.LogError.AddError(ex);
     }
     finally
     {
         if(reader != null)
             reader.Close();
     }
     return DetailGame;
 }
 public static Game Convert(Data d, List<Genre> genres, List<Platform> platforms)
 {
     Game g = new Game();
     g.ImportId = d.Game.id;
     g.Description = d.Game.Overview;
     g.Title = d.Game.GameTitle;
     if(!string.IsNullOrEmpty(d.Game.GameTitle))
         g.shortName = d.Game.GameTitle.RemoveMultipleSpace().Replace(" ", "-").Substring(0, Math.Min(d.Game.GameTitle.Length,20));
     g.Platform = GetPlatform(d.Game.PlatformId, platforms);
     g.Image = d.DowloadedFrontImage;
     g.Genre = GetGenre(d.Game.Genres.genre, genres);
     return g;
 }
예제 #3
0
        public Data DownloadImage(Data DetailGame)
        {
            try
            {

                string frontImage = DetailGame.Game.Images.boxart
                                                    .Where(x => x.side.Equals(frontAttribute))
                                                    .Select(y => y.Value)
                                                    .FirstOrDefault();
                if (!string.IsNullOrEmpty(frontImage))
                {
                    string url = string.Format("{0}{1}", DetailGame.baseImgUrl, frontImage);
                    DetailGame.DowloadedFrontImage = client.DownloadData(new Uri(url));
                }
            }
            catch(Exception ex)
            {
                Utitlity.LogError.AddError(string.Format("Per il gioco {0} - {1} non è disponibile nessuna immagine", DetailGame.Game.GameTitle, DetailGame.Game.Platform));
            }
            return DetailGame;
        }