private void Process(ActionQueueItem item, CancellationTokenSource cancelSource) { try { var simulated = _actionSimulation ? " (simulated)" : string.Empty; var threaded = cancelSource != null ? " thread" : string.Empty; Console.WriteLine($"Start{threaded}{simulated} action {item.Action.GetType().Name}, config: {item.Action.ConfigName} ({item.Host})"); if (!_actionSimulation) { CancellationToken token = cancelSource == null ? CancellationToken.None : cancelSource.Token; IActionHandler handler = _actionHandlers[item.Action.GetType().FullName]; item.ActionHandler = handler; // get config; allow it an action to have an empty config dynamic config = null; string configName = item.ConfigName.Trim(); if (!string.IsNullOrWhiteSpace(configName)) { config = _configManager[configName]; } handler.Action(item.Action, token, config); } Console.WriteLine($"End{threaded}{simulated} action {item.Action.GetType().Name}, config: {item.Action.ConfigName} ({item.Host})"); } catch (Exception ex) { Error($"Error while processing action: {ex.ToString()}"); } }
public TOut Run(Tin input) { var result = _actionHandler.Action(input); Errors = _actionHandler.Errors; if (!HasErrors) { Errors = _provider.SaveChangesWithValidations(); } return(result); }
private void Process(ActionQueueItem item, CancellationTokenSource cancelSource) { try { var simulated = _actionSimulation ? " (simulated)" : string.Empty; var threaded = cancelSource != null ? " thread" : string.Empty; Console.WriteLine($"Start{threaded}{simulated} action {item.Action.GetType().Name}, instance: {item.Action.InstanceName} ({item.Host})"); if (!_actionSimulation) { CancellationToken token = cancelSource == null ? CancellationToken.None : cancelSource.Token; IActionHandler handler = _actionHandlers[item.InstanceName]; handler.Action(item.Action, token, _configManager[item.InstanceName]); } Console.WriteLine($"End{threaded}{simulated} action {item.Action.GetType().Name}, instance: {item.Action.InstanceName} ({item.Host})"); } catch (Exception ex) { Error($"Error while processing action: {ex.ToString()}"); } }