/**
  * Create IngestManifestAsset from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\IngestManifestAsset
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['ParentIngestManifestId'], 'options[ParentIngestManifestId]');
     $asset = new self($options['ParentIngestManifestId']);
     $asset->fromArray($options);
     return $asset;
 }
Example #2
0
 public static function import($new_songs, $force = false)
 {
     $db_stats = array('skipped' => 0, 'updated' => 0, 'inserted' => 0, 'deleted' => 0);
     if (empty($new_songs)) {
         return false;
     }
     Debug::startTimer('Import data into database');
     $em = self::getEntityManager();
     $existing_hashes = self::getHashes();
     $existing_ids = self::getIds();
     $unused_hashes = $existing_hashes;
     $song_ids = Song::getIds();
     $i = 0;
     foreach ($new_songs as $song_hash => $processed) {
         if (!in_array($song_hash, $song_ids)) {
             Song::getOrCreate($processed);
         }
         if (isset($existing_hashes[$song_hash])) {
             if ($force && $existing_hashes[$song_hash] == $processed['id']) {
                 $db_stats['updated']++;
                 $record = self::find($processed['id']);
             } else {
                 $db_stats['skipped']++;
                 $record = null;
             }
         } else {
             if (isset($existing_ids[$processed['id']])) {
                 $db_stats['updated']++;
                 $record = self::find($processed['id']);
             } else {
                 $db_stats['inserted']++;
                 $record = new self();
             }
         }
         if ($record instanceof self) {
             $existing_ids[$processed['id']] = $processed['hash'];
             $existing_hashes[$processed['hash']] = $processed['id'];
             $record->fromArray($processed);
             $em->persist($record);
         }
         unset($unused_hashes[$song_hash]);
         $i++;
         if ($i % 200 == 0) {
             $em->flush();
             $em->clear();
         }
     }
     $em->flush();
     $em->clear();
     // Clear out any songs not found.
     $hashes_remaining = array_keys($unused_hashes);
     $db_stats['deleted'] = count($hashes_remaining);
     $em->createQuery('DELETE FROM ' . __CLASS__ . ' e WHERE e.hash IN (:hashes)')->setParameter('hashes', $hashes_remaining)->execute();
     Debug::endTimer('Import data into database');
     Debug::print_r($db_stats);
     return $db_stats;
 }
Example #3
0
 /**
  *
  * 使用数组初始化对象
  * @param array $array
  * @param 是否检测签名 $noCheckSign
  * @param string $mchKey 商户Api密钥
  */
 public static function initfromArray($array, $noCheckSign = false, $mchKey = '')
 {
     $obj = new self();
     if ($mchKey) {
         $obj->setMchKey($mchKey);
     }
     $obj->fromArray($array);
     if ($noCheckSign == false) {
         $obj->checkSign();
     }
     return $obj;
 }
Example #4
0
 public static function fromFile($filePath, $env)
 {
     if (is_file($filePath)) {
         $configuration = parse_ini_file($filePath, true);
         if (isset($configuration[$env])) {
             $config = new self();
             $config->fromArray($configuration[$env]);
             return $config;
         }
         throw new Exception("File Env:[{$env}] Not Found");
     }
     throw new Exception("File Not Found");
 }
Example #5
0
 /**
  * Static Functions
  */
 public static function post($nowplaying)
 {
     $em = self::getEntityManager();
     $active_shortcodes = Station::getShortNameLookup();
     $total_overall = 0;
     foreach ($nowplaying as $short_code => $info) {
         $listeners = (int) $info['listeners']['current'];
         $station_id = $info['station']['id'];
         if (isset($active_shortcodes[$short_code])) {
             $total_overall += $listeners;
         }
         $record = new self();
         $record->fromArray(array('station_id' => $station_id, 'type' => 'second', 'timestamp' => time(), 'number_min' => $listeners, 'number_max' => $listeners, 'number_avg' => $listeners));
         $em->persist($record);
     }
     // Create "overall" statistic.
     $record = new self();
     $record->fromArray(array('type' => 'second', 'timestamp' => time(), 'number_min' => $total_overall, 'number_max' => $total_overall, 'number_avg' => $total_overall));
     $em->persist($record);
     $em->flush();
 }
Example #6
0
 /**
  * Create asset from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Job
  */
 public static function createFromOptions($options)
 {
     $job = new self();
     $job->fromArray($options);
     return $job;
 }
 /**
  * Create Program from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return Program
  */
 public static function createFromOptions($options)
 {
     $program = new self();
     $program->fromArray($options);
     return $program;
 }
Example #8
0
 public static function fetchAll($lentry_id = 0, $active = 1)
 {
     global $db;
     $entry_objectives = false;
     $query = "SELECT * FROM `logbook_entry_objectives` WHERE `lentry_id` = ? AND `objective_active` = ?";
     $results = $db->GetAll($query, array($lentry_id, $active));
     if ($results) {
         foreach ($results as $result) {
             if ($result["objective_id"]) {
                 $result["objective"] = Models_Objective::fetchRow($result["objective_id"]);
             }
             $entry_objective = new self();
             $entry_objectives[$result["objective_id"]] = $entry_objective->fromArray($result);
         }
     }
     return $entry_objectives;
 }
Example #9
0
 public static function fetchRow($objective_id = 0, $active = 1)
 {
     global $db;
     $return = false;
     if ($objective_id != 0) {
         $query = "SELECT * FROM `global_lu_objectives` WHERE `objective_id` = ? AND `objective_active` = ?";
         $result = $db->GetRow($query, array($objective_id, $active));
         if ($result) {
             $objective = new self();
             $return = $objective->fromArray($result);
         }
     }
     return $return;
 }
 /**
  * Create EncodingReservedUnitType from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return EncodingReservedUnit
  */
 public static function createFromOptions($options)
 {
     $encodingReservedUnitType = new self();
     $encodingReservedUnitType->fromArray($options);
     return $encodingReservedUnitType;
 }
 /**
  * Create media processor from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\MediaProcessor
  */
 public static function createFromOptions($options)
 {
     $mediaProcessor = new self();
     $mediaProcessor->fromArray($options);
     return $mediaProcessor;
 }
 /**
  * Create task template from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\TaskTemplate
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['NumberofInputAssets'], 'options[NumberofInputAssets]');
     Validate::notNull($options['NumberofOutputAssets'], 'options[NumberofOutputAssets]');
     $taskTemplate = new self($options['NumberofInputAssets'], $options['NumberofOutputAssets']);
     $taskTemplate->fromArray($options);
     return $taskTemplate;
 }
 /**
  * Create asset file from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\AssetFile
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['Name'], 'options[Name]');
     Validate::notNull($options['ParentAssetId'], 'options[ParentAssetId]');
     $assetFile = new self($options['Name'], $options['ParentAssetId']);
     $assetFile->fromArray($options);
     return $assetFile;
 }
Example #14
0
 /**
  * @param $packageName
  * @return Package
  */
 public static function create($packageName)
 {
     $package = new self();
     $package->fromArray(array('name' => $packageName, 'visited' => false, 'blacklisted' => false));
     return $package;
 }
Example #15
0
 /**
  *
  * 使用数组初始化对象
  * @param array $array
  * @param 是否检测签名 $noCheckSign
  */
 public static function initFromArray($array, $noCheckSign = false)
 {
     $obj = new self();
     $obj->fromArray($array);
     if ($noCheckSign == false) {
         $obj->checkSign();
     }
     return $obj;
 }
 /**
  * Create error detail from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\ErrorDetail
  */
 public static function createFromOptions($options)
 {
     $errorDetail = new self();
     $errorDetail->fromArray($options);
     return $errorDetail;
 }
Example #17
0
 /**
  * Create task from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Task
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['TaskBody'], 'options[TaskBody]');
     Validate::notNull($options['Options'], 'options[Options]');
     Validate::notNull($options['MediaProcessorId'], 'options[MediaProcessorId]');
     $task = new self($options['TaskBody'], $options['MediaProcessorId'], $options['Options']);
     $task->fromArray($options);
     return $task;
 }
 /**
  * Create manifest from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\IngestManifest
  */
 public static function createFromOptions($options)
 {
     $manifest = new self();
     $manifest->fromArray($options);
     return $manifest;
 }
 /**
  * Create task historical event from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\TaskHistoricalEvent
  */
 public static function createFromOptions($options)
 {
     $taskHistoricalEvent = new self();
     $taskHistoricalEvent->fromArray($options);
     return $taskHistoricalEvent;
 }
Example #20
0
 public static function fetchRowByCourseID($course_id, $active = NULL)
 {
     global $db;
     $syllabus = new self();
     $query = "\tSELECT a.*, b.`course_name`, b.`course_code`\n\t\t\t\t\tFROM `course_syllabi` AS a\n\t\t\t\t\tJOIN `courses` AS b\n\t\t\t\t\tON a.`course_id` = b.`course_id`\n\t\t\t\t\tJOIN `curriculum_periods` AS c\n\t\t\t\t\tON b.`curriculum_type_id` = c.`curriculum_type_id`\n\t\t\t\t\tAND c.`active` = 1\n\t\t\t\t\tWHERE a.`course_id` = ?" . (!is_null($active) ? "AND a.`active` = ?" : "") . "\n                    GROUP BY a.`syllabus_id`";
     $course_details = $db->GetRow($query, array($course_id, $active));
     if ($course_details) {
         $syllabus->fromArray($course_details);
     }
     return $syllabus;
 }
 /**
  * Create ManifestStatistics from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\IngestManifestStatistics
  */
 public static function createFromOptions($options)
 {
     $statistics = new self();
     $statistics->fromArray($options);
     return $statistics;
 }
 /**
  * Create locator from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Locator
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['AssetId'], 'options[AssetId]');
     Validate::notNull($options['AccessPolicyId'], 'options[AccessPolicyId]');
     Validate::notNull($options['Type'], 'options[Type]');
     $locator = new self($options['AssetId'], $options['AccessPolicyId'], $options['Type']);
     $locator->fromArray($options);
     return $locator;
 }
Example #23
0
 public static function getLoginInfo($application, $includeInactive = false)
 {
     global $current_user;
     $eapmBean = new self();
     if (isset($_SESSION['EAPM'][$application]) && !$includeInactive) {
         if (is_array($_SESSION['EAPM'][$application])) {
             $eapmBean->fromArray($_SESSION['EAPM'][$application]);
         } else {
             return;
         }
     } else {
         $queryArray = array('assigned_user_id' => $current_user->id, 'application' => $application, 'deleted' => 0);
         if (!$includeInactive) {
             $queryArray['validated'] = 1;
         }
         $eapmBean = $eapmBean->retrieve_by_string_fields($queryArray, false);
         // Don't cache the include inactive results
         if (!$includeInactive) {
             if ($eapmBean != null) {
                 $_SESSION['EAPM'][$application] = $eapmBean->toArray();
             } else {
                 $_SESSION['EAPM'][$application] = '';
                 return;
             }
         }
     }
     if (isset($eapmBean->password)) {
         require_once 'include/utils/encryption_utils.php';
         $eapmBean->password = blowfishDecode(blowfishGetKey('encrypt_field'), $eapmBean->password);
     }
     return $eapmBean;
 }
Example #24
0
 /**
  * Create asset from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\Asset
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['Options'], 'options[Options]');
     $asset = new self($options['Options']);
     $asset->fromArray($options);
     return $asset;
 }
Example #25
0
 public static function fetchRow($lentry_id = 0, $active = 1)
 {
     global $db;
     $logbook_entry = false;
     if ($lentry_id != 0) {
         $query = "SELECT * FROM `logbook_entries` WHERE `lentry_id` = ? AND `entry_active` = ?";
         $result = $db->GetRow($query, array($lentry_id, $active));
         if ($result) {
             $entry_objectives = Models_Logbook_Entry_Objective::fetchAll($result["lentry_id"]);
             if ($entry_objectives) {
                 foreach ($entry_objectives as $entry_objective) {
                     $result["objectives"][] = $entry_objective;
                 }
             }
             $le = new self();
             $logbook_entry = $le->fromArray($result);
         }
     }
     return $logbook_entry;
 }
 /**
  * Create access policy from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\AccessPolicy
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['Name'], 'options[Name]');
     $accessPolicy = new self($options['Name']);
     $accessPolicy->fromArray($options);
     return $accessPolicy;
 }
 /**
  * Create ContentKeyAuthorizationPolicy from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return ContentKeyAuthorizationPolicy
  */
 public static function createFromOptions($options)
 {
     $contentKeyAuthorizationPolicy = new self();
     $contentKeyAuthorizationPolicy->fromArray($options);
     return $contentKeyAuthorizationPolicy;
 }
 /**
  * Create asset from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return WindowsAzure\MediaServices\Models\JobTemplate
  */
 public static function createFromOptions($options)
 {
     Validate::notNull($options['JobTemplateBody'], 'options[JobTemplateBody]');
     $jobTemplate = new self($options['JobTemplateBody'], $options['TemplateType']);
     $jobTemplate->fromArray($options);
     return $jobTemplate;
 }
 /**
  * Create Encoding from array.
  *
  * @param array $options Array containing values for object properties
  *
  * @return Encoding
  */
 public static function createFromOptions($options)
 {
     $operation = new self();
     $operation->fromArray($options);
     return $operation;
 }
Example #30
0
 /**
  * 通过数组创建消息
  * @param array $arr
  * @return RPCMessage
  */
 static function createWithArray(array $arr)
 {
     $message = new self();
     $message->fromArray($arr);
     return $message;
 }