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 override CommandExecutionResult Execute() { var ctx = new AdministrationDbContext(); var rmsSystem = ctx.GetSystemInstance(); var sysAdmin = rmsSystem.FindIdentity("sys_admin"); if (Password != null) { if (string.IsNullOrWhiteSpace(Password)) { return(CommandExecutionResult.Fail("Password cannot be blank")); } sysAdmin.SetPassword(Password); } if (Enable) { sysAdmin.MakeActive(); } if (Disable) { sysAdmin.MakeActive(false); } ctx.SaveChanges(); return(CommandExecutionResult.Ok()); }
public override CommandExecutionResult Execute() { using (var ctx = new AdministrationDbContext()) { var rmsSystem = ctx.GetSystemInstance(); var sysInfo = "Description: " + rmsSystem.Description + Environment.NewLine + "Key: [" + rmsSystem.Id.As64BitString() + "]" + Environment.NewLine + "Version: " + rmsSystem.Version + Environment.NewLine; return(CommandExecutionResult.Ok(sysInfo)); } }
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() { PrintModelStatus(new AdministrationDbContext()); PrintModelStatus(new AuditDbContext()); PrintModelStatus(new MediaDbContext()); PrintModelStatus(new MessagingDbContext()); PrintModelStatus(new MetadataDbContext()); PrintModelStatus(new RecentInfoDbContext()); PrintModelStatus(new ReportsDbContext()); PrintModelStatus(new SummariesDbContext()); PrintModelStatus(new StageDbContext()); return(CommandExecutionResult.Ok("Complete")); }
public override async Task <CommandExecutionResult> Execute(OrderDetailsCommand command) { Console.WriteLine($"Incoming request for order details for id = {command.OrderId}"); if (command.OrderId <= 0) { return(CommandExecutionResult.ValidationFailure($"Invalid order ID: {command.OrderId}")); } Console.WriteLine("Getting order details..."); var orderDetails = OrderDetailsRepo.Get(command.OrderId); Console.WriteLine("Ready."); return(CommandExecutionResult.Ok(orderDetails)); }
/// <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 ) ); }
public override async Task <CommandExecutionResult> Execute(PostProcessOrderCommand command) { if (command.OrderId <= 0) { return(CommandExecutionResult.ValidationFailure($"Invalid order ID: {command.OrderId}")); } var orderId = command.OrderId; Console.WriteLine($"Post-process order id = {orderId}"); Console.WriteLine("Getting order details..."); var orderDetailsResult = await _web1.GetOrderDetails(orderId); if (orderDetailsResult.Status != SendStatus.Success || orderDetailsResult.Result == null) { Console.WriteLine("Getting order details failed."); return(CommandExecutionResult.Failure(orderDetailsResult.ErrorMessage, orderDetailsResult.ErrorReason)); } var orderDetails = orderDetailsResult.Result; Console.WriteLine($"Retrieved order details: user is (id {orderDetails.UserId}, name {orderDetails.UserName}), order amount is {orderDetails.Amount}, created on {orderDetails.DateCreated}"); Console.WriteLine($"Pass order details to Azure Functions HTTP microservice..."); var captureResult = await _azureFunctionsHttpServiceClient.CaptureOrder(orderDetails.OrderId, orderDetails.UserName); if (captureResult.Status != SendStatus.Success) { Console.WriteLine($"Calling Azure Functions microservice failed: {captureResult.ErrorMessage}"); } else { Console.WriteLine($"Azure Functions microservice replied: '{captureResult.Result.Message}'"); } return(CommandExecutionResult.Ok()); }
public override CommandExecutionResult Execute() { Log.Info("Processing batch file {0}:", Filename); // load the file var xDoc = XDocument.Load(Filename); // check for a commands node var rootNode = xDoc.Element("Commands"); if (rootNode == null) { throw new Exception("Invalid command file."); } // Process the Command Elements in Document Order var commandInstances = from commandNode in rootNode.Elements("Command") let commandName = commandNode.Attribute("name").Value let commandParameters = GetCommandParameters(commandNode) select CommandInstanceFactory.CreateCommandInstance(commandName, commandParameters); var commandsReady = new List <Command>(); var commandsNotReady = new List <Command>(); foreach (var commandInstance in commandInstances) { if (commandInstance.Ready()) { commandsReady.Add(commandInstance); } else { commandsNotReady.Add(commandInstance); } } // Print Not Ready Commands foreach (var commandNotReady in commandsNotReady) { Log.Info("Command '{0}' not ready. Please check the arguments and try again."); Log.Info(commandNotReady.GetType().GetCustomAttribute <CommandAttribute>().GetCommandInfo()); } // Execute Ready Commands var results = commandsReady .Select(x => x.Execute()); var failures = false; results.ForEach(result => { if (result.Success) { Log.Info(result.Message); } else { Log.Error(result.Message); failures = true; } }); return(failures ? CommandExecutionResult.Ok("Batch Complete with Failures.") : CommandExecutionResult.Ok("Batch Complete.")); }
public override async Task <CommandExecutionResult> Execute(PostDataCommand command) { Console.WriteLine($"Received data: {command.Data}"); return(CommandExecutionResult.Ok()); }