Exemplo n.º 1
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->step = sfConfig::get('app_max_features_on_featurelist');
     $this->getUser()->syncParameters($this, 'energyaction', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'name';
         $this->sort_direction = 'up';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = new Criteria();
     SortCriteria::addSortCriteria($c, $this->sort_column, EnergyactionPeer::getSortAliases(), $this->sort_direction);
     $c->setOffset($this->offset);
     if ($this->limit >= 0) {
         $c->setLimit($this->limit);
     }
     $this->energyaction_list = EnergyactionPeer::doSelect($c);
     $this->count = EnergyactionPeer::doCount(new Criteria());
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404();
     }
 }
Exemplo n.º 2
0
 public function getEnergyactions()
 {
     $c = new Criteria();
     $c->addJoin(EnergyactionPeer::ID, RoomHasEnergyactionPeer::ENERGYACTION_ID);
     $c->add(RoomHasEnergyactionPeer::ROOM_ID, $this->getId(), Criteria::EQUAL);
     $c->addAscendingOrderByColumn(EnergyactionPeer::NAME);
     return EnergyactionPeer::doSelect($c);
 }
 protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $this->context = sfContext::createInstance($this->configuration);
     $databaseManager = new sfDatabaseManager($this->configuration);
     ConfigurationHelper::load();
     $now = time();
     $this->logSection('tempos', sprintf('Checking energy actions at: %s.', strftime('%c', $now)), 1024);
     // Creates physical access controller
     /* 
     $hac = BaseHomeAutomationController::create();
     
     		$hac->setVerbose($options['verbose']);
     		$hac->setUpdateStatus($options['update-status']);
     
     		$this->logSection('tempos', sprintf('Creating a home automation controller: %s', $hac->getName()), 1024);
     */
     // Refresh statuses
     $actions = EnergyactionPeer::doSelect(new Criteria());
     if (empty($actions)) {
         $this->logSection('tempos', sprintf('Refreshing statuses for all actions: no actions.'), 1024);
     } else {
         $this->logSection('tempos', sprintf('Refreshing statuses for all actions: %d action(s) to refresh.', count($actions)), 1024);
         foreach ($actions as $action) {
             $hac = self::findHac($action);
             if (is_null($hac)) {
                 $this->logSection('tempos', sprintf('Can\'t create a home automation controller for this action: id(%s) HAC is null', $action->getId()), 1024);
                 continue;
             }
             $hac->setVerbose($options['verbose']);
             $hac->setUpdateStatus($options['update-status']);
             $this->logSection('tempos', sprintf('Creating a home automation controller: %s for action: %s', $hac->getName(), $action->getId(), 1024));
             $this->refreshAction($hac, $action);
         }
     }
     // Check out of period actions
     $actions = EnergyactionPeer::doSelectOutOfPeriod(true, $now);
     if (empty($actions)) {
         $this->logSection('tempos', sprintf('Checking out-of-period active actions: no action is out-of-period.'), 1024);
     } else {
         $this->logSection('tempos', sprintf('Checking out-of-period active actions: %d action(s) to shut down.', count($actions)), 1024);
         foreach ($actions as $action) {
             $hac = self::findHac($action);
             if (is_null($hac)) {
                 $this->logSection('tempos', sprintf('Can\'t check out-of-period with this action: id(%s) HAC is null', $action->getId()), 1024);
                 continue;
             }
             $this->updateAction($hac, $action, false, $options['force']);
         }
     }
     // Check the ready actions
     $actions = EnergyactionPeer::doSelectReady($now);
     if (empty($actions)) {
         $this->logSection('tempos', sprintf('Checking reservation ready actions: no action must be triggered.'), 1024);
     } else {
         $this->logSection('tempos', sprintf('Checking reservation ready actions: %d action(s) to power on.', count($actions)), 1024);
         foreach ($actions as $action) {
             $hac = self::findHac($action);
             if (is_null($hac)) {
                 $this->logSection('tempos', sprintf('Can\'t update this action: id(%s) HAC is null', $action->getId()), 1024);
                 continue;
             }
             $this->updateAction($hac, $action, true, $options['force']);
         }
     }
     // Check the over actions
     $actions = EnergyactionPeer::doSelectOver($now, $actions);
     if (empty($actions)) {
         $this->logSection('tempos', sprintf('Checking reservation over actions: no action must be triggered.'), 1024);
     } else {
         $this->logSection('tempos', sprintf('Checking reservation over actions: %d action(s) to shut down.', count($actions)), 1024);
         foreach ($actions as $action) {
             $hac = self::findHac($action);
             if (is_null($hac)) {
                 $this->logSection('tempos', sprintf('Can\'t update this action: id(%s) HAC is null', $action->getId()), 1024);
                 continue;
             }
             $this->updateAction($hac, $action, false, $options['force']);
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(EnergyactionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EnergyactionPeer::DATABASE_NAME);
         $criteria->add(EnergyactionPeer::ID, $pks, Criteria::IN);
         $objs = EnergyactionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }