Пример #1
0
        private void StartDownloadManager(List <UpdateInfo> updates, DataTable table)
        {
            List <string> relevantProducts = new List <string>();

            foreach (UpdateInfo update in updates)
            {
                string[] products = update.Product.Split(',');
                foreach (string product in products)
                {
                    if (!relevantProducts.Contains(product.Trim()))
                    {
                        relevantProducts.Add(product.Trim());
                    }
                }
            }
            List <string> productList = GetFilteredProductList(table, relevantProducts);
            bool          isFinished  = false;

            while (isFinished == false)
            {
                Console.WriteLine("\nProducts: ");
                foreach (string product in productList)
                {
                    Console.WriteLine("{0}. {1}", (productList.IndexOf(product) + 1), product);
                }
                Console.WriteLine("Select a product to enable or disable it from the download list. \n(Leave blank and press enter to begin downloading): ");
                int input = ConsoleInput.PositiveIntegerAllowEmpty();
                if (input >= 1 && input <= productList.Count)
                {
                    if (productList[input - 1].EndsWith(" - DISABLED"))
                    {
                        productList[input - 1] = productList[input - 1].Replace(" - DISABLED", "");
                    }
                    else
                    {
                        productList[input - 1] = productList[input - 1] + " - DISABLED";
                    }
                }
                else if (input == -1)
                {
                    isFinished = true;
                }
                else
                {
                    Console.WriteLine("\nInvalid input. Try again... ");
                }
            }
            List <string> filteredProductList  = new List <string>();
            List <string> filteredLanguageList = new List <string>
            {
                "",
                "english",
                "all"
            };

            foreach (string product in productList)
            {
                if (!product.Contains(" - DISABLED"))
                {
                    filteredProductList.Add(product);
                }
            }

            DownloadManager d = new DownloadManager(filteredProductList, filteredLanguageList);

            Console.WriteLine("Populating download queue...");
            d.PopulateDownloadQueue(updates);
            Console.WriteLine("Queue loading complete...");
            Console.WriteLine("Initializing download sequence...");
            d.DownloadFilesFromQueue();
            Console.WriteLine("Downloads complete.");
        }