public void Test_JobsImport()
        {
            JobsImporter importer = new JobsImporter();
            ExcelReader reader = new ExcelReader();

            try
            {
                reader.LoadExcelFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "SampleJobTracker.xls"));

                reader.MoveToSheet(1);
                importer.Import(reader.GetCurrentWorksheet());
            }
            catch (Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error(ex);
                Assert.Fail("Jobs and invoices import failed");
            }
            finally
            {
                reader.Dispose();
            }
        }
Example #2
0
        static int Main(string[] args)
        {
            int exitCode;
            Console.WriteLine("Starting Excel Migrator.");
            Console.Write("Looking for MJT Excel file in the current directory.... ");

            // interpret arguments            
            if (args.Length == 0)
            {
                System.Console.WriteLine("Please enter the Excel MJT filename as single command argument");                
                return 1;
            }
           
            string excelFileName = ExtractFullFileNamePath(args[0]);
            ExcelReader reader = new ExcelReader();
            try
            {
                reader.LoadExcelFile(excelFileName);
                Console.WriteLine("OK - File loaded!");
                Console.WriteLine("Starting import:");
                Console.WriteLine("==========================================");

                // perform DB import    
                DatabaseStartup.InitConfiguration();

                // initialize importers
                ClerksImporter clerksImporter = new ClerksImporter();
                ClientsImporter clientsImporter = new ClientsImporter();
                JobsImporter jobsImporter = new JobsImporter();

                Console.WriteLine("--> Importing clerks...");
                reader.MoveToSheet(3);
                clerksImporter.Import(reader.GetCurrentWorksheet());

                Console.WriteLine("--> Importing clients...");
                reader.MoveToSheet(2);
                clientsImporter.Import(reader.GetCurrentWorksheet());

                Console.WriteLine("--> Importing jobs, invoices and appointments...");
                reader.MoveToSheet(1);
                jobsImporter.Import(reader.GetCurrentWorksheet());

                Console.WriteLine("==========================================");
                Console.WriteLine("Done.");
                exitCode = 0;
            }
            catch (Exception ex)
            {
                LogManager.GetCurrentClassLogger().Error(ex);
                Console.WriteLine("Import failed!");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ReadLine();
                exitCode = 1;
            }
            finally
            {
                reader.Dispose();                
            }
            return exitCode;
        }