Load() public method

Takes a collection of command line arguments, and parses them / loads them onto our properties. Will also accept a single filename, and treat that as if it were provided at the command line
public Load ( string args ) : bool
args string
return bool
Exemplo n.º 1
0
        /// <summary>
        /// Our main entry point for the command line app
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static int Main(string[] args)
        {
            Init();
            LoadConfigFile();
            ShowWelcomeScreen();
            ShowCopyrightAndLicense();


            ImportJob job = new ImportJob();

            if ((args != null) && (args.Length > 0))
            {
                _log.Debug("Loading arguments...");
                if (!job.Load(args))
                {
                    _log.Debug("Error while loading arguments. Exiting.");
                    return(-1);
                }

                if (!job.ExecuteJob())
                {
                    _log.Fatal("An error was encountered while performing the operation.  Please examine the log output and try again if necessary.");
                }
            }
            else
            {
                DisplayOptions();
            }

            //#if DEBUG
            //            _log.Debug("Done! Press ANY KEY to Quit");
            //            Console.ReadKey();
            //#endif
            return(0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Our main entry point for the command line app
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static int Main(string[] args)
        {
            Init();
            LoadConfigFile();
            ShowWelcomeScreen();
            ShowCopyrightAndLicense();

            ImportJob job = new ImportJob();
            if ((args != null) && (args.Length > 0))
            {
                _log.Debug("Loading arguments...");
                if (!job.Load(args))
                {
                    _log.Debug("Error while loading arguments. Exiting.");
                    return -1;
                }

                if (!job.ExecuteJob())
                {
                    _log.Fatal("An error was encountered while performing the operation.  Please examine the log output and try again if necessary.");
                }
            }
            else
            {
                DisplayOptions();
            }

            //#if DEBUG
            //            _log.Debug("Done! Press ANY KEY to Quit");
            //            Console.ReadKey();
            //#endif
            return 0;
        }
Exemplo n.º 3
0
        public void TestFullLine()
        {
            string[] args = "-s Wyoming -y 2010 -outputFolder \"c:\\sandbox\\ACSDataErmine\\\" -workingFolder \"c:\\sandbox\\ACSDataErmine\\Wo-rking\\\" -v test_vars.txt -exportToShape".Split(' ');
            ImportJob job = new ImportJob();
            if (!job.Load(args))
            {
                Assert.Fail("Couldn't parse standard line for full line");
            }

            Assert.AreEqual(AcsState.Wyoming, job.State, "State is wrong for args");
            Assert.AreEqual("test_vars.txt", job.IncludedVariableFile, "variables file is wrong for args");
            Assert.AreEqual("c:\\sandbox\\ACSDataErmine\\", job.OutputFolder, "Output folder is wrong!");
            Assert.AreEqual("c:\\sandbox\\ACSDataErmine\\Wo-rking\\", job.WorkingFolder, "Working folder is wrong!");

            Assert.AreEqual(true.ToString(), job.ExportToShapefile, true.ToString(), "flag param is wrong for args");
        }
Exemplo n.º 4
0
        public void TestStandardLine()
        {
            var argsList = new string[][]{
                ("-s Wyoming -e 150 -v my-VariablesFile.txt -jobName Test-01 " + (char)8211 + "exportToShape").Split(' '),
                ("-s Wyoming -e 150 " + (char)8211 + "v my-VariablesFile.txt -jobName Test-01 -exportToShape").Split(' '),
                ((char)8211 + "s Wyoming -e 150 -v my-VariablesFile.txt -jobName Test-01 -exportToShape").Split(' ')
            };

            for (int i = 0; i < argsList.Length; i++)
            {
                var args = argsList[i];
                ImportJob job = new ImportJob();
                if (!job.Load(args))
                {
                    Assert.Fail("Couldn't parse standard line for argsList[{0}]", i);
                }

                Assert.AreEqual(AcsState.Wyoming, job.State, "State is wrong for argsList[{0}]", i);
                Assert.AreEqual("my-VariablesFile.txt", job.IncludedVariableFile, "variables file is wrong for argsList[{0}]", i);
                Assert.AreEqual("Test-01", job.JobName, "Job name is wrong for argsList[{0}]", i);
                Assert.AreEqual(true.ToString(), job.ExportToShapefile, true.ToString(), "flag param is wrong for argsList[{0}]", i);
            }
        }