public static void Main(string[] args) { // Process the incoming arguments var commandParser = new CommandArgumentsParserService(); Tuple <string, Dictionary <string, string> > commandArguments; try { commandArguments = commandParser.ParseCommandWithArguments(args); } catch (FormatException ex) { Log.Error(ex.Message); Environment.ExitCode = ExitCodeInvalidCommandFormat; return; } if (commandArguments == null) { Log.Info(@"No command specified. " + Environment.NewLine); PrintAvailableCommands(); Environment.ExitCode = ExitCodeOk; return; } // Locate the specified Command var command = CommandInstanceFactory.CreateCommandInstance(commandArguments.Item1, commandArguments.Item2); if (command == null) { Log.Info(@"Command not found."); Environment.ExitCode = ExitCodeCommandNotFound; return; } // Execute the command only if it is ready if (command.Ready()) { CommandExecutionResult result; try { result = command.Execute(); } catch (Exception ex) { result = CommandExecutionResult.Exception(ex); } Log.Info(result.Message); Environment.ExitCode = result.Success ? ExitCodeOk : ExitCodeCommandExecutionFailed; return; } Log.Info(@"Command was not ready to execute. Check your parameters and try again."); Log.Info(command.GetType().GetCustomAttribute <CommandAttribute>().GetCommandInfo()); Environment.ExitCode = ExitCodeCommandNotReady; }
/// <summary> /// The Main Logic for the Preprocessor /// </summary> /// <param name="args"></param> private static void Main(string[] args) { // Say Hello Log.Info(LineBreak); Log.Info(" TriTech Software Systems: Inform RMS Web"); Log.Info(" Preprocessor v1.0"); Log.Info(" " + DateTime.Now.ToString(CultureInfo.InvariantCulture)); Log.Info(LineBreak); Log.Info(""); // Parse Arguments var argumentParserService = new CommandArgumentsParserService(); var arguments = argumentParserService.ParseArguments(args); // Process Arguments ProcessArguments(arguments); PreprocessData(); Exit("Process Complete " + DateTime.Now); }