Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            appData = Path.Combine(appDataPath, @"TimDeSmet-HoGent\GPS-Project\Tool-2");

            Boolean isConnected = false;

            while (!isConnected)
            {
                printHeader();
                Console.Write("Database password?: ");
                mysql_pass = Console.ReadLine();
                db         = new DatabaseUtil(mysql_host, mysql_user, mysql_pass, mysql_data);

                int status = db.checkConnection();
                switch (status)
                {
                case 1:
                    isConnected = true;
                    break;

                case 1042:
                    Console.WriteLine("Unabale to create connection!");
                    Console.WriteLine(" ");
                    Console.Write("Press ENTER to continue...");
                    Console.ReadLine();
                    break;

                case 0:
                    Console.WriteLine("Invalid password!");
                    Console.WriteLine(" ");
                    Console.Write("Press ENTER to continue...");
                    Console.ReadLine();
                    break;

                default:
                    break;
                }
            }

            while (data == null)
            {
                printHeader();
                Console.Write("Data file path?: ");
                String dataFile = Console.ReadLine();

                printHeader();
                Console.WriteLine("Loading data...");
                Console.WriteLine(" ");

                data = DataManager.importData(dataFile);

                if (data == null)
                {
                    printHeader();
                    Console.WriteLine("File was not a valid Data file");
                    Console.WriteLine(" ");
                    Console.Write("Press ENTER to continue...");
                    Console.ReadLine();
                }
            }

            Thread.Sleep(25);
            Boolean runApp = true;

            while (runApp)
            {
                printHeader();
                Console.WriteLine("All data has been loaded");
                Console.WriteLine(" ");

                Console.WriteLine("----- [MENU] -----");
                Console.WriteLine("[1] UPLOAD TO DATABASE");
                Console.WriteLine("[2] DATABASE STATUS");
                Console.WriteLine("[3] CLOSE APPLICATION");
                Console.Write("Selection: ");
                String selection = Console.ReadLine();

                switch (selection)
                {
                case "1":
                    MenuManager.case1();
                    break;

                case "2":
                    MenuManager.case2();
                    break;

                case "3":
                    runApp = false;
                    break;

                default:
                    Console.Write("Wrong selection input, press ENTER to continue...");
                    Console.ReadLine();
                    break;
                }
            }
        }