Ejemplo n.º 1
0
         public virtual void ExecuteCommand()
         {
             if (command == null)
                 throw new Exception("You forgot to set the command!!");
 
             try
             {
                 log(this.command.GetType().Name + " starting execution ");
                 command.Execute();
                 if (!command.Success)
                 {
                     log(this.command.GetType().Name + " completed execution but failed. Message: " + command.Message + " " + command.StatusCode.ToString());
                 }
                 else
                     log(this.command.GetType().Name + " completed execution. Success!");
 
             }
             catch (Exception ex)
             {
                 command.StatusCode = CommandStatusCode.Error;
                 Loggy.AddError("An unhandled error was caught in " + this.command.GetType().Name + ": " + ex.Message, ex);
                 command.Message = ex.ToString();
                 //throw;
             }
         }
Ejemplo n.º 2
0
         /// <summary>
         /// Executes the command using the default invoker.
         /// </summary>
         /// <param name="aCommand"></param>
         public static void Invoke(this Command aCommand)
         {
             System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
             System.Reflection.MethodBase m = stackTrace.GetFrame(1).GetMethod();
             String strMethodName = m.DeclaringType.Name + "." + m.Name;
 
             try
             {
                 Invoker invoker = new Invoker();
                 invoker.SetCommand(aCommand);
                 invoker.ExecuteCommand();
             }
             catch (Exception ex)
             {
                 Loggy.AddError("An error occured in Extensions.Invoke. + " + strMethodName ,ex);
                 throw ex;
             }
             
         }