Beispiel #1
0
        private static void Run(InputItem item)
        {
            var id    = item.Identifier;
            var count = item.Count;
            var price = item.Price;

            var data = GrabById(id);

            if (data == null)
            {
                return;
            }

            var title   = data.Title.Trim();
            var quality = (ItemQuality)Enum.Parse(typeof(ItemQuality), data.Quality, true);
            var icon    = data.Icon.Replace(@"/items/", string.Empty).Replace(@".png", string.Empty).Trim();
            var race    = (ItemRaceRestriction)data.Race;

            var itemData = new ShopItem(id, title, quality, race, icon, count, price);

            if (string.IsNullOrEmpty(data.CategoryName))
            {
                categories[@"Разное"].Add(itemData);
                return;
            }

            if (categories.ContainsKey(data.CategoryName))
            {
                categories[data.CategoryName].Add(itemData);
                return;
            }

            var newCategory = new ShopItemCollection(data.CategoryName)
            {
                itemData
            };

            categories.Add(newCategory.Name, newCategory);
        }
Beispiel #2
0
        // The main entry point.
        private static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Console.WriteLine("Shugo Trader (http://aiondatabase.net)");
            Console.WriteLine("Copyright (C) 2015 AtreiaWorld.com\n");

            if (args == null || args.Length == 0)
            {
                Console.WriteLine("Shugo usage: Shugo.exe file1 [file2 ... fileN]");
                Console.WriteLine("This tool is not working without special input data.");
                return;
            }

            Parse(args);
            Console.WriteLine("Shugo is ready to grab the data.");
            Console.WriteLine("Press ENTER to continue, or press ESC to exit...");

            ConsoleKeyInfo keyInfo;

            do
            {
                keyInfo = Console.ReadKey(true);
            } while (keyInfo.Key != ConsoleKey.Enter &&
                     keyInfo.Key != ConsoleKey.Escape);

            if (keyInfo.Key == ConsoleKey.Escape)
            {
                return;
            }

            var defaultCategory = new ShopItemCollection(@"Разное");

            categories.Add(defaultCategory.Name, defaultCategory);

            itemCount = 0;

            Console.WriteLine("\nDownloading data:");
            Parallel.ForEach(input, Run);

            var uid = new List <uint>();

            var ic = 0;
            var cc = 0;

            foreach (var category in categories.Values)
            {
                cc += category.Count == 0 ? 0 : 1;
                ic += category.Count;
            }

            Console.WriteLine("DONE!");
            Console.WriteLine("Categories: {0}.", cc);
            Console.WriteLine("Items: {0}.", ic);

            Console.WriteLine("Press any key to save XML file and exit...");
            Console.ReadKey(true);

            if (uid.Count > 0)
            {
                using (var file = new StreamWriter("error.txt"))
                {
                    foreach (var id in uid)
                    {
                        file.WriteLine("{0}", id);
                    }
                }
            }

            SaveResult();
        }