private static void CreateCommandForSetupAction(CommandLineApplication app) { Log.Verbose("Start creating command [setup]."); app.Command("setup", (command) => { command.Description = "Performs the SETUP step which initializes the embedded database"; command.HelpOption("-?|-h|--help"); var overwriteOption = command.Option("-o|--overwrite <true/false>", "Overwrite an existing database.", CommandOptionType.SingleValue); command.OnExecute(() => { var overwrite = overwriteOption.HasValue() && Convert.ToBoolean(overwriteOption.Value()); ActionBuilder.Execute <ActionSetupDb>(new ActionSetupDbOptions() { Overwrite = overwrite }); return(0); }); }); Log.Verbose("Finished creating command [setup]."); }
public static IActionResult AsActionResult(this OperationResult operation, bool?internalFlag = null) { var actionBuilder = new ActionBuilder(operation); if (internalFlag.HasValue) { actionBuilder.WithInternalFlag(internalFlag.Value); } return(actionBuilder.Execute()); }
public void TestActionEnSerie() { ActionNull actionNull = new ActionNull("Action null"); ActionEnSerie serialSuccess = new ActionBuilder("Action Série Test") .Add(actionNull) .Add(actionNull.Clone()) .Add(actionNull.Clone()) .BuildActionEnSerie(); serialSuccess.Execute(); Assert.AreEqual(serialSuccess.Status, ActionStatus.SUCCESS); }
private static void CreateCommandForRunAsServiceAction(CommandLineApplication app) { Log.Verbose("Start creating command [run-as-service]."); app.Command("service", (command) => { command.Description = "Performs the SERVICE step which starts the application as a web service application"; command.HelpOption("-?|-h|--help"); command.OnExecute(() => { ActionBuilder.Execute <ActionRunAsService>(null); return(0); }); }); Log.Verbose("Finished creating command [run-as-service]."); }
private static void CreateCommandForPopulateAction(CommandLineApplication app) { Log.Verbose("Start creating command [populate]."); app.Command("populate", (command) => { command.Description = "Performs the POPULATE step which populates the database with data from the specified textfile"; command.HelpOption("-?|-h|--help"); var locationArgument = command.Argument("[sourcefile]", "The sourcefile to use for populating the service's database."); var recordCountOption = command.Option("-rc|--rc <integer-value>", "Number of records to import. If no value is specified, all data will be imported.", CommandOptionType.SingleValue); var minimalOccurenceCountOption = command.Option("-m|--min <integer-value>", "Minimum prevalence counter required to be considered 'unsafe'", CommandOptionType.SingleValue); var startFromOption = command.Option("-s|--start-from <integer-value>", "Row-number to start importing from", CommandOptionType.SingleValue); var ignoreDuplicateExceptionOption = command.Option("-id|--ignore-duplicates", "Choose whether to ignore duplication exceptions from the database", CommandOptionType.SingleValue); command.OnExecute(() => { if (locationArgument.Values == null || locationArgument.Values.Count == 0) { throw new MissingArgumentException("Source-file not specified or invalid..."); } var sourceFile = locationArgument.Values[0]; var numberOfRecordsToImport = recordCountOption.HasValue() ? Convert.ToInt32(recordCountOption.Value()) : int.MaxValue; var minimalOccurenceCount = minimalOccurenceCountOption.HasValue() ? Convert.ToInt32(minimalOccurenceCountOption.Value()) : Constants.DEFAULT_MIN_PREVALENCE; var startFrom = startFromOption.HasValue() ? Convert.ToInt32(startFromOption.Value()) : 0; var ignoreDuplicates = ignoreDuplicateExceptionOption.HasValue() && Convert.ToBoolean(ignoreDuplicateExceptionOption.Value()); try { ActionBuilder.Execute <ActionPopulateDb>(new ActionPopulateDbOptions() { Source = sourceFile, IgnoreDuplicates = ignoreDuplicates, Limit = numberOfRecordsToImport, MinPrevalance = minimalOccurenceCount, StartFromRow = startFrom }); return(0); } catch (Exception e) { Log.Error(e.ToString()); Console.WriteLine(e.Message); return(-1); } }); }); Log.Verbose("Finished creating command [populate]."); }