Пример #1
0
        protected static void DoSmartMetering()
        {
            try
            {
                int data = 0;
                while (data != 1 && data != 2)
                {
                    Console.WriteLine("Do you want export data in file(1) or SQL(2)");

                    data = Convert.ToInt32(Console.ReadLine());
                }
                switch (data)
                {
                case 2:                                     //Connection to BBDD
                    Console.WriteLine("Connecting to SQL"); //Ask about the credentials to connect to the BBDD
                    ConnectionClient Connection = new ConnectionClient();
                    SqlConnection    connect    = Connection.InitConnection();
                    AddElementSQL(connect);
                    break;

                case 1:         //Save in file
                    ConfigurationFile file = new ConfigurationFile();
                    AddElementFile(file.ConfigureFile());
                    break;

                default:
                    Console.WriteLine("Incorrect value");
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                DoSmartMetering();      //return execute program in case of error
            }
        }