Esempio n. 1
0
        internal List <GameContainer> MakeList(string collection, string ignorePath)
        {
            string path  = Path.Combine(Directory.GetCurrentDirectory(), collection);
            var    games =
                Directory.GetFiles(path)
                .Where(f => f.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
                .Select(f => XDocument.Load(f))
                .SelectMany(xdoc => XMLConverter.FromXML(xdoc));

            GeekItemComparer cmp = new GeekItemComparer();
            var ignoredGames     = File.Exists(ignorePath) ? XMLConverter.FromXML(XDocument.Load(ignorePath)) : new List <IGeekItem>();

            var marked = games
                         .GroupBy(g => g, cmp)
                         .Select(grp =>
                                 new GameContainer
            {
                Game    = grp.First().Game,
                Count   = grp.Count(),
                Ignored = ignoredGames.Contains(grp.First(), cmp)
            })
                         .OrderByDescending(g => g.Count);

            var filtered = trueIgnore ? marked.Where(g => !g.Ignored) : marked;
            var result   = filtered.Skip(from).Take(to - from);

            return(result.ToList());
        }
Esempio n. 2
0
        public void Execute(IState state)
        {
            if (state.Collection != null)
            {
                var api = new BGG.API(new APIConfig());
                List <IGeekItem> result = api.GetGeekListAsync(listId).Result;
                XDocument        xml    = XMLConverter.ToXML(result);

                string path = Path.Combine(Directory.GetCurrentDirectory(), state.Collection, listId.ToString());
                path = Path.ChangeExtension(path, ".xml");

                xml.Save(path);
            }
            else
            {
                WriteLine("Stage collection.");
            }
        }
Esempio n. 3
0
        public void Execute(IState state)
        {
            if (state.Collection != null)
            {
                var          api    = new BGG.API(new APIConfig());
                List <IGame> result = api.GetHotAsync().Result;
                XDocument    xml    = XMLConverter.ToXML(result);

                string name = $"{DateTime.Now.ToString("yyyy-M-dd--HH-mm")}_hot.xml";
                string path = Path.Combine(Directory.GetCurrentDirectory(), state.Collection, name);

                xml.Save(path);
            }
            else
            {
                WriteLine("Stage collection.");
            }
        }
Esempio n. 4
0
        public void Execute(IState state)
        {
            if (state.Collection != null)
            {
                var          api    = new BGG.API(new APIConfig());
                List <IGame> result = api.GetTopAsync(depth).Result;
                // Ensure list is truncated to original request depth
                XDocument xml = XMLConverter.ToXML(result.Take(depth));

                string name = $"{DateTime.Now.ToString("yyyy-M-dd--HH-mm")}_top.xml";
                string path = Path.Combine(Directory.GetCurrentDirectory(), state.Collection, name);

                xml.Save(path);
            }
            else
            {
                WriteLine("Stage collection.");
            }
        }
Esempio n. 5
0
        public void Execute(IState state)
        {
            IGeekItem newItem = new GeekItem
            {
                Game = new Game
                {
                    Id   = gameId,
                    Name = string.Empty
                }
            };
            List <IGeekItem> gameList;
            string           path = state.IgnorePath;

            gameList = File.Exists(path) ? XMLConverter.FromXML(XDocument.Load(path)) : new List <IGeekItem>();
            gameList.Add(newItem);
            XDocument xml = XMLConverter.ToXML(gameList);

            xml.Save(path);
        }