public function beforeUpdate($baseTable, $baseCurrent, $baseUpdate) { if (isset($baseUpdate['abc_id']) && !isset($baseUpdate['abc_time'])) { $baseUpdate['abc_time'] = CalemText::getServerDatetime(); } return $baseUpdate; }
public function execute() { $dayBo = new CalemDashWoOrigDayBo(); $mdBo = new CalemDashWoOrigMdBo(); $woDbo = CalemFactory::getDbo('workorder'); $woDbo->deleteBySql('delete from dash_wo_orig_day'); $woDbo->deleteBySql('delete from dash_wo_orig_md'); //Now recals based on wo info try { $rows = $woDbo->fetchBySql("select * from workorder"); } catch (CalemDboDataNotFoundException $e) { return "No data in workorder. WO count is reset."; } global $_CALEM_conf; $lastDay = strtotime($_CALEM_conf['dash_conf']['dash_wo_orig_day']['limit'] . " day ago"); $lastSvrDay = CalemText::getServerDatetime($lastDay); foreach ($rows as $row) { $mdBo->onDataInserted_CalemWoDbo(array('baseData' => $row)); if ($row['orig_time'] < $lastSvrDay) { continue; } //Too far back not considering $dayBo->onDataInserted_CalemWoDbo(array('baseData' => $row)); } return "WO count updated successfully."; }
public function upgrade() { $startTime = CalemText::getServerDatetime(); $cmds = $this->getCmds(); $succ = true; $results = ''; try { foreach ($cmds as $key => $cmdInfo) { require_once 'command/' . $cmdInfo['cmd'] . '.php'; $cmd = new $cmdInfo['cmd'](); $cmd->init($cmdInfo['param']); $result = $cmd->execute(); $results .= $result; } $results = 'Done upgrade. Commands executed: ' . count($cmds) . "\n" . $results; } catch (Exception $e) { $results = 'Exception in upgrade: ' . $e->getMessage(); $succ = false; } //Now let's log the version upgrade results if any. try { $this->id = $this->verBo->startUpgrade($this->newVer, $this->currVer); if ($succ) { $this->verBo->save($this->newVer); $this->verBo->completeUpgrade($this->id, $results); } else { $this->verBo->failUpgrade($this->id, $results); } } catch (Exception $e) { $results .= '; exception in save log: ' . $e->getMessage(); $succ = false; $this->logger->error("Error in creating upgrade log, error=" . $e->getMessage()); } if (!$succ) { throw new Exception($results); } return $results; }
public function setLogStatus($id, $statusId, $results) { $this->initDbo(); $this->dboLog->setChangeBulk(array('status_id' => $statusId, 'end_time' => CalemText::getServerDatetime(), 'results' => $results)); $this->dboLog->setIdForUpdate($id); $this->dboLog->update(); }