/**
  * Exception handler.
  */
 public function handleException(\Exception $ex)
 {
     $request = new Request();
     $request->addFeedback($ex);
     if ($ex instanceof \Classes\Controller\Exception\NotFoundException) {
         $request->setProperty('cmd', '404');
     } else {
         $request->setProperty('cmd', '500');
     }
     $cmd_r = new \Classes\Controller\Command\CommandResolver();
     $cmd = $cmd_r->getCommand($request);
     $cmd->execute($request);
 }
 private function doCommand($cmdObject)
 {
     // Create command resolver
     $commandResolver = new \Classes\Controller\Command\CommandResolver();
     // Create command request
     $commandRequest = new \Classes\Controller\Controller\Request();
     $command = trim($cmdObject->getProperty('command')->get());
     $object = trim($cmdObject->getProperty('object')->get());
     // Try to find command
     if ($command == "COMBINE" && $object == "DOUBLE NODES") {
         $commandRequest->setProperty('cmd', 'CombineDoubleNodes');
     }
     if ($command == "DIVIDE" && $object == "ALL MEMBERS") {
         $commandRequest->setProperty('cmd', 'DivideAllMemberByExistingNodes');
     }
     if ($command == "IMPORT" || $command == "EXPORT") {
         $format = trim($cmdObject->getProperty('format')->get());
         $file = trim($cmdObject->getProperty('file')->get());
     }
     if ($command == "IMPORT" && $format == "EXCEL") {
         // Check filename
         $filename = $this->getTempFileName($file);
         if ($filename === FALSE) {
             return;
         } else {
             $commandRequest->setProperty('filename', $filename);
         }
         if ($object == "STEEL MEMBER") {
             $commandRequest->setProperty('cmd', 'ImportSteelMembersFromExcel');
         }
         if ($object == "PARAMETER MEMBER") {
             $commandRequest->setProperty('cmd', 'ImportParameterMembersFromExcel');
         }
         if ($object == "CONSTRAINT") {
             $commandRequest->setProperty('cmd', 'ImportConstraintsFromExcel');
         }
         if ($object == "LOAD CASE") {
             $commandRequest->setProperty('cmd', 'ImportLoadCasesFromExcel');
         }
         if ($object == "COMMON MEMBER LOAD") {
             $commandRequest->setProperty('cmd', 'ImportCommonMemberLoadsFromExcel');
         }
     }
     if ($command == "EXPORT") {
         $commandRequest->setProperty('filename', $file);
         if ($object == "MODEL" && $format == "SCAD21") {
             $commandRequest->setProperty('cmd', 'ExportModelToScad21');
         }
     }
     if (is_null($commandRequest->getProperty('cmd'))) {
         throw new \Classes\Controller\Exception\CommandNotFoundException("Command *" . $cmdObject->servicePrint() . "* is NOT found.");
     }
     $cmd = $commandResolver->getCommand($commandRequest);
     $cmd->execute($commandRequest);
 }