コード例 #1
0
        public static void Main(string[] args)
        {
            Write("Good Day. I hope you are doing well?");
            Write("");

            #region Command Line Arguments

            Write("Reading and verifying command line arguments ...");
            bool hasErrors;
            var commandLineArguments = new CommandLineService().ReadAndVerify(args, out hasErrors);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(1);
            }
            Write("Command line arguments seem okay.");
            Write("");

            #endregion Command Line Arguments

            if (commandLineArguments.LogFile.HasValue())
            {
                _logFile = commandLineArguments.LogFile;
            }

            #region Configuration File

            Write("Reading and verifying configuration file ...");
            bool hasWarnings;
            var configuration = new ConfigurationService(commandLineArguments).ReadAndVerify(out hasErrors,
                out hasWarnings);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(2);
            }
            if (hasWarnings)
            {
                ConfirmWarnings(commandLineArguments);
            }
            else
            {
                Write("Configuration file seems okay.");
            }
            Write("");

            #endregion Configuration File

            if (commandLineArguments.GenerateCsvStub)
            {
                new CsvStubService(configuration).GenerateCsvStub(commandLineArguments.CsvFile);
                Write("Exiting ...");
                Environment.Exit(0);
            }

            #region CSV file

            Write("Reading and verifying CSV file ...");
            var csv = new CsvService(commandLineArguments, configuration).ReadAndVerify(out hasErrors, out hasWarnings);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(3);
            }
            if (hasWarnings)
            {
                ConfirmWarnings(commandLineArguments);
            }
            else
            {
                Write("CSV file seems okay.");
            }
            Write("");

            #endregion CSV file

            #region Import

            new ImportService(configuration, csv).RunImport(out hasErrors);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(4);
            }
            Write("");

            #endregion Import

            Write("Everything done. Have a nice day.");
            Environment.Exit(0);
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            Write("Good Day. I hope you are doing well?");
            Write("");

            #region Command Line Arguments

            Write("Reading and verifying command line arguments ...");
            bool hasErrors;
            var  commandLineArguments = new CommandLineService().ReadAndVerify(args, out hasErrors);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(1);
            }
            Write("Command line arguments seem okay.");
            Write("");

            #endregion Command Line Arguments

            if (commandLineArguments.LogFile.HasValue())
            {
                _logFile = commandLineArguments.LogFile;
            }

            #region Configuration File

            Write("Reading and verifying configuration file ...");
            bool hasWarnings;
            var  configuration = new ConfigurationService(commandLineArguments).ReadAndVerify(out hasErrors,
                                                                                              out hasWarnings);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(2);
            }
            if (hasWarnings)
            {
                ConfirmWarnings(commandLineArguments);
            }
            else
            {
                Write("Configuration file seems okay.");
            }
            Write("");

            #endregion Configuration File

            if (commandLineArguments.GenerateCsvStub)
            {
                new CsvStubService(configuration).GenerateCsvStub(commandLineArguments.CsvFile);
                Write("Exiting ...");
                Environment.Exit(0);
            }

            #region CSV file

            Write("Reading and verifying CSV file ...");
            var csv = new CsvService(commandLineArguments, configuration).ReadAndVerify(out hasErrors, out hasWarnings);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(3);
            }
            if (hasWarnings)
            {
                ConfirmWarnings(commandLineArguments);
            }
            else
            {
                Write("CSV file seems okay.");
            }
            Write("");

            #endregion CSV file

            #region Import

            new ImportService(configuration, csv).RunImport(out hasErrors);
            if (hasErrors)
            {
                Write("Exiting ...");
                Environment.Exit(4);
            }
            Write("");

            #endregion Import

            Write("Everything done. Have a nice day.");
            Environment.Exit(0);
        }