示例#1
0
 public static function handleLiveReportExportFinished(BatchJob $dbBatchJob, kLiveReportExportJobData $data)
 {
     // Move file from shared temp to it's final location
     $fileName = basename($data->outputPath);
     $directory = myContentStorage::getFSContentRootPath() . "/content/reports/live/" . $dbBatchJob->getPartnerId();
     $filePath = $directory . DIRECTORY_SEPARATOR . $fileName;
     $moveFile = kFile::moveFile($data->outputPath, $filePath);
     if (!$moveFile) {
         KalturaLog::err("Failed to move report file from: " . $data->outputPath . " to: " . $filePath);
         return kFlowHelper::handleLiveReportExportFailed($dbBatchJob, $data);
     }
     $data->outputPath = $filePath;
     $dbBatchJob->setData($data);
     $dbBatchJob->save();
     $expiry = kConf::get("live_report_export_expiry", 'local', self::LIVE_REPORT_EXPIRY_TIME);
     // Create download URL
     $url = self::createLiveReportExportDownloadUrl($dbBatchJob->getPartnerId(), $fileName, $expiry, $data->applicationUrlTemplate);
     if (!$url) {
         KalturaLog::err("Failed to create download URL");
         return kFlowHelper::handleLiveReportExportFailed($dbBatchJob, $data);
     }
     // Create email params
     $time = date("m-d-y H:i", $data->timeReference + $data->timeZoneOffset);
     $email_id = MailType::MAIL_TYPE_LIVE_REPORT_EXPORT_SUCCESS;
     $validUntil = date("m-d-y H:i", $data->timeReference + $expiry + $data->timeZoneOffset);
     $expiryInDays = $expiry / 60 / 60 / 24;
     $params = array($dbBatchJob->getPartner()->getName(), $time, $dbBatchJob->getId(), $url, $expiryInDays, $validUntil);
     $titleParams = array($time);
     // Email it all
     kJobsManager::addMailJob(null, 0, $dbBatchJob->getPartnerId(), $email_id, kMailJobData::MAIL_PRIORITY_NORMAL, kConf::get("live_report_sender_email"), kConf::get("live_report_sender_name"), $data->recipientEmail, $params, $titleParams);
     return $dbBatchJob;
 }
示例#2
0
 protected function updatedLiveReportExport(BatchJob $dbBatchJob, kLiveReportExportJobData $data)
 {
     switch ($dbBatchJob->getStatus()) {
         case BatchJob::BATCHJOB_STATUS_FINISHED:
             return kFlowHelper::handleLiveReportExportFinished($dbBatchJob, $data);
         case BatchJob::BATCHJOB_STATUS_FAILED:
         case BatchJob::BATCHJOB_STATUS_FATAL:
             return kFlowHelper::handleLiveReportExportFailed($dbBatchJob, $data);
         case BatchJob::BATCHJOB_STATUS_ABORTED:
             return kFlowHelper::handleLiveReportExportAborted($dbBatchJob, $data);
         default:
             return $dbBatchJob;
     }
 }