Пример #1
0
        private List <string> CollectUpdateTitles()
        {
            Console.WriteLine("Would you like to import update titles from file or scan current device?");

            int importOrScanInput;

            do
            {
                Console.WriteLine("\nEnter 1 for Import or 2 for Scan: ");
                importOrScanInput = ConsoleInput.PositiveInteger();
            } while (importOrScanInput != 1 && importOrScanInput != 2);

            List <string> updateTitles = new List <string>();

            if (importOrScanInput == 1)
            {
                Console.WriteLine("\nYou have chosen to Import. Importing...");
                updateTitles = ImportUpdateTitles();
                return(updateTitles);
            }
            else if (importOrScanInput == 2)
            {
                Console.WriteLine("\nYou have chosen to Scan. ");
                Console.WriteLine("\nWould you like to check for available updates or installed updates?");

                int installedOrAvailableinput;
                do
                {
                    Console.WriteLine("\nEnter 1 for Available Updates or 2 for Installed Updates: ");
                    installedOrAvailableinput = ConsoleInput.PositiveInteger();
                } while (installedOrAvailableinput != 1 && installedOrAvailableinput != 2);

                if (installedOrAvailableinput == 1)
                {
                    Console.WriteLine("\nYou have chosen Available Updates. Scanning for available updates...");
                    Console.WriteLine("This may take a few minutes...");
                    updateTitles = WindowsUpdate.GetPendingUpdateTitles(0);
                }
                else if (installedOrAvailableinput == 2)
                {
                    Console.WriteLine("\nYou have chosen Installed Updates. Scanning for installed updates...");
                    Console.WriteLine("This may take a few minutes...");
                    updateTitles = WindowsUpdate.GetPendingUpdateTitles(1);
                }

                return(updateTitles);
            }
            else
            {
                Console.WriteLine("Something went wrong. Input equals: '" + importOrScanInput + "'");
                return(updateTitles);
            }
        }
Пример #2
0
        public int SelectMode()
        {
            Console.WriteLine("Select an option below:");
            Console.WriteLine("1. Collect Update Information");
            Console.WriteLine("2. Collect Update Information & Download Updates");

            int input;

            do
            {
                input = ConsoleInput.PositiveInteger();
                if (input < 1 || input > 2)
                {
                    Console.WriteLine("Incorrect selection. Please try again.");
                }
            } while (input < 1 || input > 2);

            Console.WriteLine("");
            return(input);
        }