public void Handle(ExecutePluginCommandCommand message) { _log.Info("Executing plugin command : {0}".Fmt(message.CommandName)); try { var replyMessage = new PluginCommandResponseMessage(); var commandsToExecute = _pluginCommandRepository.Where(x => x.Name == message.CommandName).ToArray(); if (commandsToExecute.Count() > 1) { replyMessage.ResponseData = string.Format("There are more than one command with name '{0}'", message.CommandName); replyMessage.PluginCommandStatus = PluginCommandStatus.Error; } else if (!commandsToExecute.Any()) { replyMessage.ResponseData = string.Format("No command with name '{0}' was found", message.CommandName); replyMessage.PluginCommandStatus = PluginCommandStatus.Error; } else { replyMessage = commandsToExecute[0].Execute(message.Arguments); } _tpBus.Reply(replyMessage); _log.Info("plugin command executed: {0}".Fmt(message.CommandName)); } catch (PluginProfileValidationException validationException) { _log.Info("Profile validation failed during executing command {0} : {1}".Fmt(message.CommandName, validationException.Errors.Serialize())); _tpBus.Reply(new PluginCommandResponseMessage { ResponseData = validationException.Errors.Serialize(), PluginCommandStatus = PluginCommandStatus.Fail }); } catch (Exception e) { _log.Error(string.Format("Plugin {0} command processing failed.", message.CommandName), e); _tpBus.Reply(new PluginCommandResponseMessage { ResponseData = string.Format("Plugin {0} command processing error: {1}", message.CommandName, e.Message), PluginCommandStatus = PluginCommandStatus.Error }); } }
public void Handle(ExecutePluginCommandCommand message) { if (message.CommandName == EmbeddedPluginCommands.DeleteProfile) { _tpBus.DoNotContinueDispatchingCurrentMessageToHandlers(); _tpBus.Reply(new PluginCommandResponseMessage { ResponseData = string.Format("Cannot delete profile for '{0}' plugin", _pluginMetadata.PluginData.Name), PluginCommandStatus = PluginCommandStatus.Error }); } }