Exemplo n.º 1
0
 public function set(Device $device)
 {
     $sp = "sp_device_set";
     $params = new SDMDBParameters();
     $params->add($device->getId());
     $params->add($device->getWifiMacAddress());
     $params->add($device->getUserId());
     // 		var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 		var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'][0]['result'])) {
                 $ret = $result['response']['resultSet'][0]['result'];
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Exemplo n.º 2
0
 public static function addDateParam(SDMDBParameters $param, $date)
 {
     if ($date == null || $date == "") {
         $param->add($date);
     } else {
         $param->add($date->format(DATE_FORMAT));
     }
 }
Exemplo n.º 3
0
 public function getAll($userId)
 {
     $sp = "sp_notification_getAllByUserId";
     $params = new SDMDBParameters();
     $params->add($userId);
     // 		var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 				var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'])) {
                 $dataRows = $result['response']['resultSet'];
                 $notifications = array();
                 foreach ($dataRows as $dataRow) {
                     $notification = new Notification();
                     $notification->setId($dataRow['notification_id']);
                     $notification->setStatus($dataRow['status']);
                     $notification->setProirity($dataRow['proirity']);
                     $notification->setUserId($dataRow['user_id']);
                     $notification->setType($dataRow['type']);
                     $notification->setMsg($dataRow['message']);
                     $notification->setEventDt($dataRow['event_dt']);
                     $notification->setLastUpate($dataRow['last_update']);
                     $notification->setObserveeId($dataRow['observee_id']);
                     array_push($notifications, $notification);
                 }
                 $ret = $notifications;
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * 
  * @param int $observeeId
  * @param string $date
  * @throws SSSException
  * @return Task[] | boolean
  */
 public function getAllTaskByObservee($observeeId)
 {
     $sp = "sp_task_getAllByObservee";
     $params = new SDMDBParameters();
     $params->add($observeeId);
     // 				var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 								var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'][0])) {
                 $tasks = array();
                 $dataRows = $result['response']['resultSet'];
                 foreach ($dataRows as $data) {
                     $task = new Task();
                     $task->setId($data['id']);
                     $task->setLat($data['lat']);
                     $task->setLng($data['lng']);
                     $task->setAddress($data['address']);
                     $task->setMsg($data['msg']);
                     $task->setLastUpdate($data['lastUpdate']);
                     $task->setCreateDt($data['createDt']);
                     $taskType = new TaskType();
                     $taskType->setId($data['typeId']);
                     $taskType->setName($data['taskType']);
                     $task->setTaskType($taskType);
                     $taskStatus = new TaskStatus();
                     $taskStatus->setId($data['statusId']);
                     $taskStatus->setName($data['status']);
                     $task->setTaskStatus($taskStatus);
                     $reporter = new User();
                     $reporter->setId($data['reporterId']);
                     $reporter->setName($data['reporter']);
                     $task->setReport($reporter);
                     if (isset($data['handlerId'])) {
                         $handler = new User();
                         $handler->setId($data['handlerId']);
                         $handler->setName($data['handler']);
                         $task->setHandler($handler);
                     }
                     array_push($tasks, $task);
                 }
                 $ret = $tasks;
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Exemplo n.º 5
0
 /**
  * Get location by date
  * @param unknown $userId
  * @param unknown $date
  * @throws SSSException
  * @return array
  */
 public function getLocationsByDate($userId, $date)
 {
     $sp = "sp_student_location_getByDate";
     $params = new SDMDBParameters();
     $params->add($userId);
     $params->add($date);
     // 		var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     $ret = false;
     // 				var_dump($result);
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             $deviceReports = array();
             foreach ($result['response']['resultSet'] as $dataRow) {
                 // 					$student = new Student();
                 // 					$student->setClassId($dataRow['class_id']);
                 // 					$student->setId($dataRow['user_id']);
                 // 					$student->setName($dataRow['login_name']);
                 // 					$student->setStudentId($dataRow['student_id']);
                 // 					$device = new Device();
                 // 					$device->setWifiMacAddress($dataRow['wifi_address']);
                 $position = new Position();
                 $position->setAccuracy($dataRow['gps_accuracy']);
                 $position->setAtt($dataRow['altitude']);
                 $position->setDateTime($dataRow['gps_Dt']);
                 // 					$position->setEnable($dataRow['gps_accuracy']);
                 $position->setLat($dataRow['latitude']);
                 $position->setLng($dataRow['longitude']);
                 // 					$position->setPlace($dataRow['gps_accuracy']);
                 $deviceReport = new DeviceReport();
                 $deviceReport->setBatt($dataRow['battery_status']);
                 $deviceReport->setDateTime($dataRow['report_dt']);
                 $deviceReport->setSignal($dataRow['network_coverage_status']);
                 $deviceReport->setMovement($dataRow['movement_status']);
                 $deviceReport->setUserId($dataRow['user_id']);
                 $deviceReport->setId($dataRow['report_id']);
                 $deviceReport->setGPS($dataRow['gps_status']);
                 $deviceReport->setPlaceStatus($dataRow['place_status']);
                 $deviceReport->setPosition($position);
                 // 					$student->setDevice($device);
                 // 					$student->setReport($deviceReport);
                 array_push($deviceReports, $deviceReport);
             }
             // 				var_dump($students);
             return $deviceReports;
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Exemplo n.º 6
0
 public function getByType($type)
 {
     $sp = "sp_user_getByType";
     $params = new SDMDBParameters();
     $params->add($type);
     // 				var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 				var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             $items = $result['response']['resultSet'];
             $array = array();
             foreach ($items as $item) {
                 $user = new User();
                 $user->setName($item['login_name']);
                 $user->setId($item['user_id']);
                 $user->setType($item['user_type']);
                 $user->setStatus($item['status']);
                 $user->setLastUpdate($item['last_update']);
                 array_push($array, $user);
             }
             return $array;
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Exemplo n.º 7
0
 public function getAll($observeeId)
 {
     $sp = "sp_place_get";
     $params = new SDMDBParameters();
     $params->add($observeeId);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 		var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'])) {
                 $items = $result['response']['resultSet'];
                 $places = array();
                 foreach ($items as $item) {
                     // 						var_dump($item);
                     $place = new Place();
                     $place->setAddress($item['place_name']);
                     $place->setId($item['place_id']);
                     $place->setLat($item['latitude']);
                     $place->setLng($item['longitude']);
                     $place->setRadius($item['radius']);
                     $place->setStudentId($item['user_id']);
                     array_push($places, $place);
                 }
                 if (sizeof($places) > 0) {
                     $ret = $places;
                 }
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Exemplo n.º 8
0
 public function add(DeviceReport $report)
 {
     $sp = "sp_deviceReport_add";
     $pos = $report->getPosition();
     // 		var_dump($pos);
     // 		var_dump($report);
     $params = new SDMDBParameters();
     $params->add($report->getUserId());
     $params->add($report->getDateTime());
     $params->add($report->getBatt());
     $params->add($report->getGPS());
     $params->add($report->getMovement());
     $params->add($report->getSignal());
     $params->add($pos->getLat());
     $params->add($pos->getLng());
     $params->add($pos->getAccuracy());
     $params->add($pos->getAtt());
     $params->add($pos->getDateTime());
     $params->add($report->getPlaceStatus());
     // 		var_dump($params);
     // 		echo "<BR>";
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 		var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'][0]['result'])) {
                 $ret = $result['response']['resultSet'][0]['result'];
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }