示例#1
0
        static void Main(string[] args)
        {
            ProgramHelper.ShowHeader();

            bool bCmdHandled = false;

            if (args != null)
            {
                if (args.Length > 1)
                {
                    bCmdHandled = true;

                    _compilationMode = args[0].ToUpperInvariant();
                    if (_compilationMode != "DEBUG" && _compilationMode != "RELEASE")
                    {
                        ProgramHelper.WriteError("Parameter 1 -> invalid argument!");
                        Environment.Exit(ProgramExitCodes.InvalidArguments);
                    }

                    _configFilePath = args[1];
                    if (!File.Exists(_configFilePath))
                    {
                        ProgramHelper.WriteError("Cannot find the config file ({0})", _configFilePath);
                        Environment.Exit(ProgramExitCodes.ConfigFileNotFound);
                    }

                    if (args.Length > 2)
                    {
                        if (!bool.TryParse(args[2], out _withSqlProcedureIntegration))
                        {
                            ProgramHelper.WriteError("Parameter 3 -> invalid argument!");
                            Environment.Exit(ProgramExitCodes.InvalidArguments);
                        }
                    }

                    if (args.Length > 3)
                    {
                        _selectedTableNames = new List <string>(args.Skip(3));
                    }

                    Program.Process();

                    Console.WriteLine();
                }
            }

            if (!bCmdHandled)
            {
                ProgramHelper.ShowHelp();
            }

            if (_withErrors)
            {
                Environment.Exit(ProgramExitCodes.ProcessException);
            }

            Environment.Exit(ProgramExitCodes.Ok);
        }
示例#2
0
        private static void Process()
        {
            ProgramHelper.WriteAction("Processing {0}...", Program.ShortConfigFilePath);
            Console.WriteLine();

            Processor processor = new Processor();

            processor.OnProcessMessage += OnProcessorProcessMessage;

            try
            {
                if (processor.Initialize(_configFilePath))
                {
                    if (_selectedTableNames == null)
                    {
                        _selectedTableNames = processor.TableNames;
                    }

                    processor.Execute(new FullProcessorBehavior(), new ProcessorParameters
                    {
                        WithSqlProcedureIntegration = _withSqlProcedureIntegration,
                        CompilationMode             = _compilationMode,
                        TableNames = _selectedTableNames.ToArray()
                    });
                }
            }
            catch (Exception x)
            {
                _withErrors = true;

                Console.WriteLine();

                ProgramHelper.WriteError("Error while processing: {0}", x.GetFullMessage(withExceptionType: true));
                ProgramHelper.WriteError(x.StackTrace);
            }
        }