public override CommandExecutionResult Execute() { try { using (var adminContext = new AdministrationDbContext()) { var system = adminContext.GetSystemInstance(); Log.Info(system.Description); var agencies = adminContext.GetSystemInstance() .Agencies .Select(a => new { a.Name, a.Jurisdiction.Ori }) .ToList(); foreach (var agency in agencies) { Log.Info("[{0}]\t{1}", agency.Ori, agency.Name); } } } catch (Exception ex) { return(CommandExecutionResult.Exception(ex)); } return(CommandExecutionResult.Ok()); }
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; }
public override CommandExecutionResult Execute() { try { // Create the Agency AgencyFactory.Create(Implementation, Name, Ori, ClassicRmsConnectionString); } catch (Exception ex) { return(CommandExecutionResult.Exception(ex)); } return(CommandExecutionResult.Ok("Complete.")); }
/// <summary> /// Execute the Command and return an ExecutionResult. /// </summary> /// <returns></returns> public override CommandExecutionResult Execute() { var started = DateTime.Now; Log.Info(started + " Generating views..."); try { ContextPreloader.GenerateViews( Path, Log ); } catch (Exception ex) { return CommandExecutionResult.Exception( ex ); } var finished = DateTime.Now; return CommandExecutionResult.Ok( finished + " View generation completed in " + finished.Subtract( started ) ); }