Пример #1
0
        static void RunFileImportExamples()
        {
            Console.WriteLine("RunFileImportExamples()");

            ConsoleKeyInfo response = new ConsoleKeyInfo();

            do
            {
                Console.WriteLine();
                Console.WriteLine("[1] = CsvImport1");
                Console.WriteLine("[2] = ExcelImport1");
                Console.WriteLine("[e] = Exit");

                Console.Write("\r\nEnter choice: ");
                response = Console.ReadKey();
                Console.WriteLine("\r\n");

                Stopwatch sw = null;

                switch (response.Key)
                {
                case ConsoleKey.D1:
                    sw = Stopwatch.StartNew();
                    CsvDataImport.CsvImport1(Common.CsvDataPath);
                    break;

                case ConsoleKey.D2:
                    sw = Stopwatch.StartNew();
                    ExcelDataImport.ExcelImport1(Common.ExcelDataPath);
                    break;

                case ConsoleKey.E:
                case ConsoleKey.Escape:
                    break;

                default:
                    Console.WriteLine("Invalid choice.");
                    break;
                }

                if (sw != null && sw.IsRunning)
                {
                    sw.Stop();
                    Common.WriteTime("Import total seconds: ", sw.Elapsed);
                }
            } while (!(response.Key == ConsoleKey.E || response.Key == ConsoleKey.Escape));
        }
Пример #2
0
        static void RunLoopedExcelFileImportExamples()
        {
            Console.WriteLine("RunLoopedExcelFileImportExamples()");

            Console.WriteLine("Import started");

            for (int i = 0; i < 5; i++)
            {
                Stopwatch sw = Stopwatch.StartNew();

                ExcelDataImport.ExcelImport1(Common.ExcelDataPath);

                sw.Stop();
                Common.WriteTime(String.Format("Import {0} total seconds: ", i), sw.Elapsed);
            }
            Console.WriteLine("\r\nPress any key to continue.");
            Console.ReadKey(true);
        }