static void Main(string[] args)
        {
            args = new string[] { "--action", "makewarehousesales", "--", "starttime=01/01/2016", "endtime=12/31/2016" };
            //args = new string[] { "--action", "deletedatabase" };

            try
            {
                log.Info("Application Started");
                string argstring = string.Empty;

                foreach (var arg in args)
                {
                    argstring += arg + ' ';
                }

                argstring = argstring.TrimEnd();
                log.Info("Parameters: {0}", argstring);

                applicationConfig = new ApplicationConfiguration();
                fclp = new FluentCommandLineParser();

                fclp.Setup<string>("action")
                    .CaptureAdditionalArguments(applicationConfig.Options.AddRange)
                    .WithDescription("What action to perform with the application")
                    .Required()
                    .Callback(x => applicationConfig.Action = x);

                var results = fclp.Parse(args);
                
                if (results.HasErrors == false || results.HelpCalled)
                {                    
                    DoWork();
                }
                else
                {
                    ShowHelp();
                }
            }
            catch (Exception e)
            {
                log.Error(e.Message.Trim());
                if (e.InnerException != null)
                {
                    log.Error(e.InnerException.Message.Trim());
                }
                log.Error(e.StackTrace);
            }
            finally
            {
                log.Info("Application Finished");
                Console.ReadKey();
            }
        }
        static void ApplyConfiguration(ApplicationConfiguration config)
        {
            string[] validOptions = { "username", "password", "host", "port", "database", "warehouseusername", "warehousepassword", "warehousehost", "warehouseport" };
            foreach(var option in config.Options)
            {
                var o = option.Split('=');
                if (!validOptions.Contains(o[0].ToLower()))
                {
                    log.Info(string.Format("{0} is not a valid configuration option", o[0].ToLower()));
                    throw new Exception(string.Format("{0} is not a valid configuration option", o[0].ToLower()));
                }

                var c = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                c.AppSettings.Settings[o[0].ToLower()].Value = Functions.Crypto.EncryptStringAES(o[1], "Biotrack1!");                
                c.Save(ConfigurationSaveMode.Full);
                log.Info(string.Format("Changing {0} to {1}", o[0], o[1]));
            }
        }