Пример #1
0
$bugList = '';
foreach ($model->bugs as $bugCrashReport) {
    if ($bugCrashReport->bug->status < Bug::STATUS_OPEN_MAX) {
        $bugList .= CHtml::link('#' . $bugCrashReport->bug_id, array('bug/view', 'id' => $bugCrashReport->bug_id)) . ' ';
    }
    if ($bugList == '') {
        $bugList = 'None';
    }
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'received', 'type' => 'text', 'value' => date("d/m/y H:i", $model->received)), array('name' => 'date_created', 'type' => 'text', 'value' => date("d/m/y H:i", $model->date_created)), array('name' => 'status', 'type' => 'text', 'value' => Lookup::item('CrashReportStatus', $model->status)), array('name' => 'filesize', 'type' => 'raw', 'value' => CHtml::encode(MiscHelpers::fileSizeToStr($model->filesize))), array('name' => 'project_id', 'type' => 'text', 'value' => $model->project->name), array('name' => 'appversion_id', 'type' => 'text', 'value' => $model->appVersion->version), 'crashguid', array('name' => 'crashrptver', 'type' => 'text', 'value' => 'CrashRpt ' . CrashReport::generatorVersionToStr($model->crashrptver)), array('name' => 'srcfilename', 'type' => 'raw', 'value' => CHtml::link($model->srcfilename, array('crashReport/download', 'id' => $model->id))), array('name' => 'groupid', 'type' => 'raw', 'value' => CHtml::link(CHtml::encode($model->collection->title), array('crashGroup/view', 'id' => $model->groupid))), array('label' => 'Open Bug(s)', 'type' => 'raw', 'value' => $bugList))));
?>

<div class="span-27 last detail-group-caption">Sender Info:</div>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'geo_location', 'type' => 'text', 'value' => CrashReport::geoIdToCountryName($model->geo_location)), 'ipaddress', 'emailfrom', 'description')));
?>

<div class="span-27 last detail-group-caption">Exception Info:</div>

<?php 
$text = $model->exception_thread_id != 0 ? '0x' . dechex($model->exception_thread_id) : null;
$exceptionThread = $model->getExceptionThread();
if ($exceptionThread) {
    $link = CHtml::link(CHtml::encode('View Stack Trace'), array('crashReport/view', 'id' => $model->id, 'tab' => 'Threads', 'thread' => $exceptionThread->id));
    $text .= ' ' . $link;
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('exception_type', array('name' => 'exceptionaddress', 'type' => 'text', 'value' => $model->exceptionaddress != 0 ? '0x' . base_convert($model->exceptionaddress, 10, 16) : null), array('name' => 'exception_code', 'type' => 'text', 'value' => $model->exception_code != 0 ? '0x' . base_convert($model->exception_code, 10, 16) : null), 'exe_image', 'exceptionmodule', array('name' => 'exceptionmodulebase', 'type' => 'text', 'value' => $model->exceptionmodulebase != 0 ? '0x' . base_convert($model->exceptionmodulebase, 10, 16) : null), array('name' => 'exception_thread_id', 'type' => 'raw', 'value' => $text))));
?>

<div class="span-27 last detail-group-caption">Machine Info:</div>
Пример #2
0
 public function testGeoIdToCountryName()
 {
     $countryName = CrashReport::geoIdToCountryName('ru-ru');
     $this->assertTrue($countryName == 'Russian Federation (ru-ru)');
 }
Пример #3
0
 /**
  * Generates a crash report geographic location distribution graph for currently 
  * selected project and dumps it to stdout.
  * @param type $w Desired image width.
  * @param type $h Desired image height.
  * @throws CHttpException
  * @return void
  */
 public static function generateGeoLocationDistributionGraph($w, $h, $file = null)
 {
     if (!is_numeric($w) || $w <= 0 || $w > 1024) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     if (!is_numeric($h) || $h <= 0 || $h > 960) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Get current project info
     $curProjectId = Yii::app()->user->getCurProjectId();
     if ($curProjectId == false) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Prepare data
     $criteria = new CDbCriteria();
     $criteria->select = 'geo_location, COUNT(*) as cnt';
     $criteria->group = 'geo_location';
     $criteria->compare('t.project_id', $curProjectId);
     $criteria->order = 'cnt DESC';
     $curVer = '(not set)';
     $versions = Yii::app()->user->getCurProjectVersions($curVer);
     if ($curVer != -1) {
         $criteria->compare('appversion_id', $curVer == 0 ? null : $curVer);
     }
     $data = array();
     $models = CrashReport::model()->findAll($criteria);
     $totalCount = 0;
     foreach ($models as $model) {
         $totalCount += $model->cnt;
         if ($model->geo_location === null) {
             if (isset($data[''])) {
                 $data[''] += $model->cnt;
             } else {
                 $data[''] = $model->cnt;
             }
         } else {
             $data[$model->geo_location] = $model->cnt;
         }
     }
     if ($file == null) {
         $fout = fopen('php://output', 'w');
     } else {
         $fout = fopen($file, 'wt');
     }
     fprintf($fout, '<div class="digest-pane-image" style="width:' . $w . 'px;min-height:' . $h . 'px;max-height:' . $h . 'px;overflow:hidden"><table id="geo-locations">');
     // Check the case when $data is empty.
     if (count($data) == 0) {
         fprintf($fout, '<tr><td><i>No data available</i></td></tr>');
     } else {
         foreach ($data as $name => $val) {
             $percent = 100 * $val / $totalCount;
             $percentStr = sprintf('%0.1f', $percent);
             $nameStr = '(not set)';
             if ($name != '') {
                 $nameStr = MiscHelpers::addEllipsis(CrashReport::geoIdToCountryName($name), 30);
             }
             fprintf($fout, '<tr><td>' . $nameStr . '</td><td>' . $percentStr . '%%</td></tr>');
         }
     }
     fprintf($fout, '</table></div>');
     if ($file != null) {
         fclose($fout);
     }
 }