当前位置: 首页>>代码示例>>PHP>>正文


PHP myPartnerUtils::collectPartnerUsageFromDWH方法代码示例

本文整理汇总了PHP中myPartnerUtils::collectPartnerUsageFromDWH方法的典型用法代码示例。如果您正苦于以下问题:PHP myPartnerUtils::collectPartnerUsageFromDWH方法的具体用法?PHP myPartnerUtils::collectPartnerUsageFromDWH怎么用?PHP myPartnerUtils::collectPartnerUsageFromDWH使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在myPartnerUtils的用法示例。


在下文中一共展示了myPartnerUtils::collectPartnerUsageFromDWH方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getStatisticsAction

 /**
  * Get usage statistics for a partner
  * Calculation is done according to partner's package
  *
  * @action getStatistics
  * @return KalturaPartnerStatistics
  * 
  * @throws APIErrors::UNKNOWN_PARTNER_ID
  */
 public function getStatisticsAction()
 {
     $dbPartner = PartnerPeer::retrieveByPK($this->getPartnerId());
     if (!$dbPartner) {
         throw new KalturaAPIException(APIErrors::UNKNOWN_PARTNER_ID, $this->getPartnerId());
     }
     $packages = new PartnerPackages();
     $partnerUsage = new KalturaPartnerStatistics();
     $partnerPackage = $packages->getPackageDetails($dbPartner->getPartnerPackage());
     $report_date = date("Y-m-d", time());
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerUsageFromDWH($dbPartner, $partnerPackage, $report_date);
     $partnerUsage->hosting = round($totalStorage / 1024, 2);
     // from MB to GB
     $totalUsageGB = round($totalUsage / 1024 / 1024, 2);
     // from KB to GB
     if ($partnerPackage) {
         $partnerUsage->usagePercent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
         $partnerUsage->packageBandwidthAndStorage = $partnerPackage['cycle_bw'];
     }
     if ($totalTraffic) {
         $partnerUsage->bandwidth = round($totalTraffic / 1024 / 1024, 2);
         // from KB to GB
     }
     $partnerUsage->usage = $totalUsageGB;
     $partnerUsage->reachedLimitDate = $dbPartner->getUsageLimitWarning();
     return $partnerUsage;
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:36,代码来源:PartnerService.php

示例2: getUsageAction

 /**
  * Get usage statistics for a partner
  * Calculation is done according to partner's package
  *
  * Additional data returned is a graph points of streaming usage in a timeframe
  * The resolution can be "days" or "months"
  *
  * @link http://docs.kaltura.org/api/partner/usage
  * @action getUsage
  * @param int $year
  * @param int $month
  * @param string $resolution accepted values are "days" or "months"
  * @return KalturaPartnerUsage
  * 
  * @throws APIErrors::UNKNOWN_PARTNER_ID
  */
 function getUsageAction($year = '', $month = 1, $resolution = "days")
 {
     $dbPartner = PartnerPeer::retrieveByPK($this->getPartnerId());
     if (!$dbPartner) {
         throw new KalturaAPIException(APIErrors::UNKNOWN_PARTNER_ID, $this->getPartnerId());
     }
     $packages = new PartnerPackages();
     $partnerUsage = new KalturaPartnerUsage();
     $partnerPackage = $packages->getPackageDetails($dbPartner->getPartnerPackage());
     $report_date = dateUtils::todayOffset(-3);
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerUsageFromDWH($dbPartner, $partnerPackage, $report_date);
     $partnerUsage->hostingGB = round($totalStorage / 1024, 2);
     // from MB to GB
     $totalUsageGB = round($totalUsage / 1024 / 1024, 2);
     // from KB to GB
     if ($partnerPackage) {
         $partnerUsage->Percent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
         $partnerUsage->packageBW = $partnerPackage['cycle_bw'];
     }
     $partnerUsage->usageGB = $totalUsageGB;
     $partnerUsage->reachedLimitDate = $dbPartner->getUsageLimitWarning();
     if ($year != '' && is_int($year)) {
         $graph_lines = myPartnerUtils::getPartnerUsageGraph($year, $month, $dbPartner, $resolution);
         // currently we provide only one line, output as a string.
         // in the future this could be extended to something like KalturaGraphLines object
         $partnerUsage->usageGraph = $graph_lines['line'];
     }
     return $partnerUsage;
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:45,代码来源:PartnerService.php

示例3: executeImpl

 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // make sure the secret fits the one in the partner's table
     $partner = PartnerPeer::retrieveByPK($partner_id);
     if (!$partner) {
         // CANNOT be because we are already in the service. it would have fallen before...
         $this->addException(APIErrors::UNKNOWN_PARTNER_ID);
     }
     $packages = new PartnerPackages();
     $partnerPackage = $packages->getPackageDetails($partner->getPartnerPackage());
     $report_date = dateUtils::todayOffset(-3);
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerUsageFromDWH($partner, $partnerPackage, $report_date);
     $return['hostingGB'] = round($totalStorage / 1024, 2);
     // from MB to GB
     $totalUsageGB = round($totalUsage / 1024 / 1024, 2);
     // from KB to GB
     $return['Percent'] = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
     $return['package_bw'] = $partnerPackage['cycle_bw'];
     $return['GB'] = $totalUsageGB;
     $return['reached_limit_date'] = $partner->getUsageLimitWarning();
     /* total usage status */
     /*  --- ended total usage status --- */
     /* usage graph */
     $year = $this->getPM("year");
     $month = $this->getP("month");
     $resolution = $this->getP("resolution");
     $graph_points = myPartnerUtils::getPartnerUsageGraph($year, $month, $partner, $resolution);
     /* --- ended usage graph --- */
     $this->addMsg("usage", $return);
     if (isset($debug_data)) {
         $this->addDebug('debug_data', $debug_data);
     }
     $this->addMsg("graph", $graph_points);
     /*
     * ADD ATTRIBUTES TO GRAPH
     
     <graph caption=""
     bgcolor="0xffffff" 
     border="false" 
     bordercolor="0xffffa7" 
     customxaxis="true" 
     minimumx="0"  
     maximumx="10" 
     intervalx="1" 
     xaxisname="Time"
     xtype="Category" 
     dataunits="hours"
     customyaxis="false" 
     minimumy="0" 
     maximumy="100" 
     intervaly="10" 
     yaxisname=""
     showdatatips="true" 
     mousesensitivity="50" 
     datatipmode="multiple"
     gridlinesdirection="both"
     customgridlines="true" 
     lineshadow="false"
     horizontalstrokecolor="0xeeeeee" 
     horizontalstrokesize=".3" 
     horizontalfillcolor="0xffffff" 
     horizontalfillsize=".3" 
     horizontalstrokealpha="0.1"
     horizontalalternatefillcolor="0xffffff" 
     horizontalalternatefillsize=".3"
     verticalstrokecolor="0xcccccc" 
     verticalstrokesize=".5"  
     verticalstrokealpha="0.5"
     verticalfillcolor="0xffffff" 
     verticalfillsize=".3" 
     verticalalternatefillcolor="0xffffff"
     verticalalternatefillsize=".3">
     
     * 
     */
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:76,代码来源:getpartnerusageAction.class.php

示例4: doPartnerUsage

 public static function doPartnerUsage($partner)
 {
     $should_block_delete_partner = true;
     $blocking_days_grace = 7;
     $block_notification_grace = time() - dateUtils::DAY * $blocking_days_grace;
     $delete_grace = time() - dateUtils::DAY * 30;
     $packages = new PartnerPackages();
     $partnerPackage = $packages->getPackageDetails($partner->getPartnerPackage());
     $report_date = date('Y-m') . '-01';
     // We are now working with the DWH and a stored-procedure, and not with record type 6 on partner_activity.
     $report_date = dateUtils::todayOffset(-3);
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerUsageFromDWH($partner, $partnerPackage, $report_date);
     $totalUsageGB = $totalUsage / 1024 / 1024;
     // from KB to GB
     $percent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
     TRACE("percent (" . $partner->getId() . ") is: {$percent}");
     $email_link_hash = 'pid=' . $partner->getId() . '&h=' . self::getEmailLinkHash($partner->getId(), $partner->getSecret());
     $email_link_hash_adOpt = $email_link_hash . '&type=adOptIn';
     /* mindtouch partners - extra mail parameter */
     $mindtouch_notice = ' ';
     if ($partner->getType() == 103) {
         $mindtouch_notice = '<BR><BR>Note: You must be a MindTouch paying customer to upgrade your video service. If you are not a paying MindTouch customer, contact MindTouch: http://www.mindtouch.com/about_mindtouch/contact_mindtouch to get a quote.<BR><BR>';
     }
     if ($percent >= 80 && $percent < 100 && !$partner->getEightyPercentWarning()) {
         TRACE("partner " . $partner->getId() . " reached 80% - setting first warning");
         /* prepare mail job, and set EightyPercentWarning() to true/date */
         $partner->setEightyPercentWarning(time());
         $partner->setUsageLimitWarning(0);
         $body_params = array($partner->getAdminName(), $partnerPackage['cycle_bw'], $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash, $email_link_hash_adOpt);
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_EIGHTY_PERCENT_WARNING, $partner, $body_params);
     } elseif ($percent >= 80 && $percent < 100 && $partner->getEightyPercentWarning() && !$partner->getUsageLimitWarning()) {
         TRACE("passed the 80%, assume notification sent, nothing to do.");
     } elseif ($percent < 80 && $partner->getEightyPercentWarning()) {
         TRACE("partner " . $partner->getId() . " was 80%, now not. clearing warnings");
         /* clear getEightyPercentWarning */
         $partner->setEightyPercentWarning(0);
         $partner->setUsageLimitWarning(0);
     } elseif ($percent >= 100 && !$partner->getUsageLimitWarning()) {
         TRACE("partner " . $partner->getId() . " reached 100% - setting second warning");
         /* prepare mail job, and set getUsageLimitWarning() date */
         $partner->setUsageLimitWarning(time());
         $body_params = array($partner->getAdminName(), $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash, $email_link_hash_adOpt);
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_LIMIT_WARNING_1, $partner, $body_params);
     } elseif ($percent >= 100 && $partnerPackage['cycle_fee'] == 0 && $partner->getUsageLimitWarning() > 0 && $partner->getUsageLimitWarning() <= $block_notification_grace && $partner->getUsageLimitWarning() > $delete_grace && $partner->getStatus() != Partner::PARTNER_STATUS_CONTENT_BLOCK) {
         TRACE("partner " . $partner->getId() . " reached 100% {$blocking_days_grace} days ago - sending block email and blocking partner");
         /* send block email and block partner */
         $body_params = array($partner->getAdminName(), $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash, $email_link_hash_adOpt);
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_LIMIT_WARNING_2, $partner, $body_params);
         if ($should_block_delete_partner) {
             $partner->setStatus(2);
         }
     } elseif ($percent >= 120 && $partnerPackage['cycle_fee'] != 0 && $partner->getUsageLimitWarning() <= $block_notification_grace) {
         $body_params = array($partner->getAdminName(), round($totalUsageGB, 2));
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PAID_PACKAGE_SUGGEST_UPGRADE, $partner, $body_params);
     } elseif ($percent >= 100 && $partnerPackage['cycle_fee'] == 0 && $partner->getUsageLimitWarning() > 0 && $partner->getUsageLimitWarning() <= $delete_grace && $partner->getStatus() == Partner::PARTNER_STATUS_CONTENT_BLOCK) {
         TRACE("partner " . $partner->getId() . " reached 100% a month ago - deleting partner");
         /* delete partner */
         $body_params = array($partner->getAdminName());
         myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_DELETE_ACCOUNT, $partner, $body_params);
         if ($should_block_delete_partner) {
             $partner->setStatus(0);
         }
     } elseif ($percent < 80 && ($partner->getUsageLimitWarning() || $partner->getEightyPercentWarning())) {
         TRACE("partner " . $partner->getId() . " OK");
         // PARTNER OK
         // resetting status and warnings should only be done manually
         //$partner->setStatus(1);
         $partner->setEightyPercentWarning(0);
         $partner->setUsageLimitWarning(0);
     }
     $partner->save();
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:72,代码来源:myPartnerUtils.class.php

示例5: getUsageAction

 /**
  * Get usage statistics for a partner
  * Calculation is done according to partner's package
  *
  * Additional data returned is a graph points of streaming usage in a timeframe
  * The resolution can be "days" or "months"
  *
  * @link http://docs.kaltura.org/api/partner/usage
  * @action getUsage
  * @param int $year
  * @param int $month
  * @param KalturaReportInterval $resolution
  * @return KalturaPartnerUsage
  * 
  * @throws APIErrors::UNKNOWN_PARTNER_ID
  * @deprecated use getStatistics instead
  */
 public function getUsageAction($year = '', $month = 1, $resolution = "days")
 {
     $dbPartner = PartnerPeer::retrieveByPK($this->getPartnerId());
     if (!$dbPartner) {
         throw new KalturaAPIException(APIErrors::UNKNOWN_PARTNER_ID, $this->getPartnerId());
     }
     $packages = new PartnerPackages();
     $partnerUsage = new KalturaPartnerUsage();
     $partnerPackage = $packages->getPackageDetails($dbPartner->getPartnerPackage());
     $report_date = date("Y-m-d", time());
     list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerUsageFromDWH($dbPartner, $partnerPackage, $report_date);
     $partnerUsage->hostingGB = round($totalStorage / 1024, 2);
     // from MB to GB
     $totalUsageGB = round($totalUsage / 1024 / 1024, 2);
     // from KB to GB
     if ($partnerPackage) {
         $partnerUsage->Percent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
         $partnerUsage->packageBW = $partnerPackage['cycle_bw'];
     }
     $partnerUsage->usageGB = $totalUsageGB;
     $partnerUsage->reachedLimitDate = $dbPartner->getUsageLimitWarning();
     if ($year != '') {
         $startDate = gmmktime(0, 0, 0, $month, 1, $year);
         $endDate = gmmktime(0, 0, 0, $month, date('t', $startDate), $year);
         if ($resolution == reportInterval::MONTHS) {
             $startDate = gmmktime(0, 0, 0, 1, 1, $year);
             $endDate = gmmktime(0, 0, 0, 12, 31, $year);
             if (intval(date('Y')) == $year) {
                 $endDate = time();
             }
         }
         $usageGraph = myPartnerUtils::getPartnerUsageGraph($startDate, $endDate, $dbPartner, $resolution);
         // currently we provide only one line, output as a string.
         // in the future this could be extended to something like KalturaGraphLines object
         $partnerUsage->usageGraph = $usageGraph;
     }
     return $partnerUsage;
 }
开发者ID:DBezemer,项目名称:server,代码行数:55,代码来源:PartnerService.php


注:本文中的myPartnerUtils::collectPartnerUsageFromDWH方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。