/// <summary>Executes the supplied command</summary> /// <param name="command">The command to execute.</param> /// <param name="context">The context passed to the command</param> public virtual void Execute(CommandBase<CommandContext> command, CommandContext context) { var args = new CommandProcessEventArgs { Command = command, Context = context }; if (CommandExecuting != null) CommandExecuting.Invoke(this, args); logger.Info(args.Command.Name + " processing " + args.Context); using (var tx = persister.Repository.BeginTransaction()) { try { args.Command.Process(args.Context); tx.Commit(); if (CommandExecuted != null) CommandExecuted.Invoke(this, args); } catch (StopExecutionException) { tx.Rollback(); } catch (Exception ex) { tx.Rollback(); logger.Error(ex); throw; } finally { logger.Info(" -> " + args.Context); } } }
/// <summary>Executes the supplied command</summary> /// <param name="command">The command to execute.</param> /// <param name="context">The context passed to the command</param> public virtual void Execute(CommandBase <CommandContext> command, CommandContext context) { var args = new CommandProcessEventArgs { Command = command, Context = context }; if (CommandExecuting != null) { CommandExecuting.Invoke(this, args); } logger.Info(args.Command.Name + " processing " + args.Context); using (var tx = persister.Repository.BeginTransaction()) { try { args.Command.Process(args.Context); Utility.FindEmpty(args.Context.Content); tx.Commit(); if (CommandExecuted != null) { CommandExecuted.Invoke(this, args); } } catch (StopExecutionException) { tx.Rollback(); } catch (Exception ex) { tx.Rollback(); logger.Error(ex); throw; } finally { logger.Info(" -> " + args.Context); } } }