Пример #1
0
        static void Main(string[] args)
        {
            var options = new Options();
            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                // consume Options instance properties
                if (options.Verbose)
                {
                    Console.WriteLine("Config file: {0}", options.ConfigFile);
                    Console.WriteLine("Source connection string: {0}", options.Source);
                    Console.WriteLine("Target connection string: {0}", options.Target);
                }

                //parse the config file
                ParseConfig(options.ConfigFile);

                //set source/target connection from parameters if specified - this will overwrite connections from the config file
                if (!string.IsNullOrEmpty(options.Source))
                {
                    _sourceString = options.Source;
                }
                if (!string.IsNullOrEmpty(options.Target))
                {
                    _targetString = options.Target;
                }

                //do some basic validations
                if (string.IsNullOrEmpty(_sourceString))
                {
                    Console.WriteLine("no source connection specified - exiting");
                    return;
                }
                if (string.IsNullOrEmpty(_targetString))
                {
                    Console.WriteLine("no target connection specified - exiting");
                    return;
                }
                if (!(_jobSteps.Count > 0))
                {
                    Console.WriteLine("no steps in job - exiting");
                    return;
                }

                Importer importer = new Importer();
                importer.GuidMappings = _guidMappings;
                importer.JobSteps = _jobSteps;
                importer.SourceString = _sourceString;
                importer.TargetString = _targetString;
                importer.MapBaseBu = _mapBaseBu;
                importer.MapBaseCurrency = _mapBaseCurrency;
                importer.Process();

                int errorCount = importer.ErrorCount;

                importer = null;
                
                //show a message to the user
                if (errorCount == 0)
                {
                    Console.WriteLine("Job finished with no errors.");
                }
                else
                {
                    Console.WriteLine("Job finished with errors. See the RecordError.log file for more details.");
                }
            }
        }