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


PHP StreamOutput::doWrite方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->loadConfig($input);
     $ignore_locked = false;
     $from_date = $this->getHarvestFromDate("Ymd", "3 days ago");
     $to_date = $this->getHarvestToDate("Ymd", "today");
     $chartType = $this->getChartType(null);
     $chartPeriod = $this->getChartPeriod(null);
     if (!($outputFilename = $input->getOption("output-file"))) {
         $outputFilename = 'FetchUserActivity-' . $from_date . '-' . $to_date . '.json';
     }
     $output->writeln('FetchUserActivity executed: ' . date('Ymd H:i:s'));
     $output->writeln('Verifying projects in Harvest');
     $output->writeln('Output filename: ' . $outputFilename);
     if ($this->getHarvestExcludeContractors()) {
         $output->writeln('NOTE: Contractors are excluded from the dataset!');
     }
     $ticketEntries = $this->getEntriesByUsers($from_date, $to_date);
     $output->writeln(sprintf('Collected %d ticket entries', sizeof($ticketEntries)));
     if (sizeof($ticketEntries) == 0) {
         //We have no entries containing ticket ids so bail
         return;
     }
     // GET THE LATEST ENTRY FOR EACH USER IN PERIOD REGARDLESS OF PROJECT
     $sortedEntries = null;
     foreach ($ticketEntries as $userArray) {
         foreach ($userArray as $entry) {
             $notes = strlen($entry->get('notes')) > 0 ? $entry->get('notes') : "...";
             $output->writeln(sprintf('%s | %s - %s: "%s" (%s timer @ %s)', self::getUserNameById($entry->get('user-id')), self::getProjectNameById($entry->get('project-id')), self::getTaskNameById($entry->get("task-id")), $notes, $entry->get('hours'), $entry->get('spent-at')));
             $sortedEntries[strtotime($entry->get("updated-at"))] = $entry;
         }
     }
     krsort($sortedEntries);
     $userSortedEntries = null;
     foreach ($sortedEntries as $updated => $entry) {
         if (!isset($userSortedEntries[$entry->get('user-id')])) {
             $userSortedEntries[$entry->get('user-id')]['project'] = self::getProjectNameById($entry->get('project-id'));
             $userSortedEntries[$entry->get('user-id')]['task'] = self::getTaskNameById($entry->get('task-id'));
             $userSortedEntries[$entry->get('user-id')]['username'] = self::getUserNameById($entry->get('user-id'));
             $userSortedEntries[$entry->get('user-id')]['notes'] = $entry->get("notes");
             $userSortedEntries[$entry->get('user-id')]['updated-at'] = $entry->get("updated-at");
             $userSortedEntries[$entry->get('user-id')]['timer-started-at'] = $entry->get("timer-started-at");
             $userSortedEntries[$entry->get('user-id')]['project-id'] = $entry->get('project-id');
             $userSortedEntries[$entry->get('user-id')]['spent-at'] = $entry->get('spent-at');
         } else {
             continue;
         }
     }
     $json = json_encode($userSortedEntries);
     // let's write the response to a file
     $outputFile = new StreamOutput(fopen('data/' . $outputFilename, 'w', false));
     $outputFile->doWrite($json, false);
     $output->writeln("FetchUserActivity completed -> " . $outputFilename . " updated");
 }
开发者ID:reload,项目名称:harvestdata,代码行数:54,代码来源:FetchUserActivity.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->loadConfig($input);
     $from_date = $this->getHarvestFromDate("Ymd", "yesterday");
     $to_date = $this->getHarvestToDate("Ymd", "yesterday");
     $chartType = $this->getChartType();
     $chartPeriod = $this->getChartPeriod();
     if (!($outputFilename = $input->getOption("output-file"))) {
         $outputFilename = 'FetchData-' . $from_date . '-' . $to_date . '.xml';
     }
     $output->writeln('FetchData executed: ' . date('Ymd H:i:s'));
     $output->writeln('Output filename: ' . $outputFilename);
     if ($this->getHarvestExcludeContractors()) {
         $output->writeln('NOTE: Contractors are excluded from the dataset!');
     }
     $output->writeln(sprintf('Chart type is "%s" and period is "%s"', $chartType, $chartPeriod));
     $output->writeln(sprintf("Collecting Harvest entries between %s to %s", $from_date, $to_date));
     switch ($chartType) {
         case 'singlecolumn':
             $sortedTicketEntries = $this->fetchBillableHoursInPeriod($from_date, $to_date);
             $data = \GeckoChart::makeSingleColumn($sortedTicketEntries, $chartPeriod);
             break;
             // used for displaying budget vs. actual billable hours
         // used for displaying budget vs. actual billable hours
         case 'columnspline':
             $sortedTicketEntries = $this->fetchBillableHoursInPeriod($from_date, $to_date);
             $data = \GeckoChart::makeSingleColumnWithSpline($sortedTicketEntries, $chartPeriod);
             break;
         case 'stackedcolumn':
             $assembledEntries = $this->fetchAllHoursInPeriod($from_date, $to_date);
             $data = \GeckoChart::makeStackedColumn($assembledEntries, $chartPeriod);
             break;
         case 'piechart':
             $assembledEntries = $this->fetchAllHoursInPeriod($from_date, $to_date);
             $chartPeriodTitle = date("M. jS", strtotime($from_date)) . " - " . date("M. jS", strtotime($to_date));
             $data = \GeckoChart::makePieChart($assembledEntries, $chartPeriodTitle);
             break;
         default:
             $output->writeln("FetchData ChartType not recognized -> " . $chartType . "");
             return;
             break;
     }
     // lets write the data to a file
     if ($data) {
         $outputFile = new StreamOutput(fopen('data/' . $outputFilename, 'w', false));
         $outputFile->doWrite($data, false);
         $output->writeln("\nFetchData completed -> " . $outputFilename . " updated");
     }
 }
开发者ID:reload,项目名称:harvestdata,代码行数:49,代码来源:FetchData.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->loadConfig($input);
     $ignore_locked = false;
     $from_date = $this->getHarvestFromDate("Ymd", "today");
     $to_date = $this->getHarvestToDate("Ymd", "today");
     $chartType = $this->getChartType(null);
     $chartPeriod = $this->getChartPeriod(null);
     if (!($outputFilename = $input->getOption("output-file"))) {
         $outputFilename = 'FetchEntries-' . $from_date . '-' . $to_date . '.xml';
     }
     $output->writeln('FetchEntries executed: ' . date('Ymd H:i:s'));
     $output->writeln('Verifying projects in Harvest');
     $output->writeln('Output filename: ' . $outputFilename);
     if ($this->getHarvestExcludeContractors()) {
         $output->writeln('NOTE: Contractors are excluded from the dataset!');
     }
     $ticketEntries = $this->getEntriesByUsers($from_date, $to_date);
     $output->writeln(sprintf('Collected %d ticket entries', sizeof($ticketEntries)));
     if (sizeof($ticketEntries) == 0) {
         //We have no entries containing ticket ids so bail
         return;
     }
     $sortedEntries = null;
     foreach ($ticketEntries as $userArray) {
         foreach ($userArray as $entry) {
             $notes = strlen($entry->get('notes')) > 0 ? $entry->get('notes') : "...";
             $output->writeln(sprintf('%s | %s - %s: "%s" (%s timer @ %s)', self::getUserNameById($entry->get('user-id')), self::getProjectNameById($entry->get('project-id')), self::getTaskNameById($entry->get("task-id")), $notes, $entry->get('hours'), $entry->get('spent-at')));
             $sortedEntries[strtotime($entry->get("updated-at"))] = $entry;
         }
     }
     krsort($sortedEntries);
     // get top 30
     $sortedEntries = array_slice($sortedEntries, 0, 30, true);
     // TODO: Refactor and move to GeckoChart.php
     // prepare the response!
     $geckoresponse = new \GeckoResponse();
     // format as text
     foreach ($sortedEntries as $entry) {
         $notes = strlen($entry->get('notes')) > 0 ? $entry->get('notes') : "[no notes]";
         $data['item'][] = array('text' => '<span class="t-size-x18">' . self::getProjectNameById($entry->get('project-id')) . ':</span><br/><span class="t-size-x24">"' . $notes . '"</span><br/><span class="t-size-x18">' . self::getUserNameById($entry->get('user-id')) . ' - ' . self::getTaskNameById($entry->get("task-id")) . ', ' . $entry->get('hours') . ' timer</span>', 'type' => 0);
     }
     $response = $geckoresponse->getResponse($data, true);
     // let's write the response to a file
     $outputFile = new StreamOutput(fopen('data/' . $outputFilename, 'w', false));
     $outputFile->doWrite($response, false);
     $output->writeln("FetchEntries completed -> " . $outputFilename . " updated");
 }
开发者ID:reload,项目名称:harvestdata,代码行数:48,代码来源:FetchEntries.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->loadConfig($input);
     $ignore_locked = false;
     $from_date = $this->getHarvestFromDate("Ymd", "yesterday");
     $to_date = $this->getHarvestToDate("Ymd", "yesterday");
     $chartType = $this->getChartType("geekometer");
     $chartPeriod = $this->getChartPeriod("day");
     /*	  
         $updated_since  = null;  // NULL meeans all projects (and is thereby slow), but it doesnt seem to work correctly if I set the date otherwise
                                  // Ahh: http://forum.getharvest.com/forums/api-and-developer-chat/topics/announcement-greater-availability-of-updated_since-filtering-in-api
     //    $updated_since  = urlencode($this->getHarvestFromDate($input, "Y-m-d 00:00"));
     */
     if (!($outputFilename = $input->getOption("output-file"))) {
         $outputFilename = 'FetchBillable-' . $from_date . '-' . $to_date . '.xml';
     }
     //Setup Harvest API access
     $harvest = $this->getHarvestApi();
     $output->writeln('FetchBillable executed: ' . date('Ymd H:i:s'));
     $output->writeln('Verifying projects in Harvest');
     $output->writeln('Output filename: ' . $outputFilename);
     if ($this->getHarvestExcludeContractors()) {
         $output->writeln('NOTE: Contractors are excluded from the dataset!');
     }
     $output->writeln(sprintf('Chart type is "%s" and period is "%s"', $chartType, $chartPeriod));
     $output->writeln(sprintf("Collecting Harvest entries between %s to %s", $from_date, $to_date));
     $sortedTicketEntries = $this->fetchBillableHoursInPeriod($from_date, $to_date);
     $output->writeln(sprintf('Collected %d ticket entries', sizeof($sortedTicketEntries) - 1));
     if (!sizeof($sortedTicketEntries) > 0) {
         //We have no entries containing ticket ids so bail
         return;
     }
     $output->writeln(sprintf('OutputFormat for Geckoboard: %s', $chartType));
     switch ($chartType) {
         default:
         case "geekometer":
             $output->writeln(sprintf('"%s" will show data for the entire period regardless of what is specified', $chartType));
             // prepare the response!
             $geckoresponse = new \GeckoResponse();
             $billableHours = $sortedTicketEntries["statistics"]["totalhours"];
             $output->writeln(sprintf('Billable hours from %s to %s: %s', $from_date, $to_date, $billableHours));
             $data['item'] = round($billableHours);
             $data['type'] = "standard";
             $data['min'][] = array('value' => 0, 'text' => '');
             $data['max'][] = array('value' => 75, 'text' => '');
             // fetch data
             $response = $geckoresponse->getResponse($data, true);
             break;
         case "line":
             $output->writeln(sprintf('Billable hours from %s to %s: %s', $from_date, $to_date, $sortedTicketEntries["statistics"]["totalhours"]));
             // lets strip the statistics data
             array_pop($sortedTicketEntries);
             $sortedTicketEntries = \GeckoChart::formatValuesToKeys($sortedTicketEntries, $chartPeriod);
             $response = \GeckoChart::formatXmlGeckoboardLine($sortedTicketEntries);
             break;
     }
     // let's write the response to a file
     $outputFile = new StreamOutput(fopen('data/' . $outputFilename, 'w', false));
     $outputFile->doWrite($response, false);
     $output->writeln("FetchBillable completed -> " . $outputFilename . " updated");
 }
开发者ID:reload,项目名称:harvestdata,代码行数:61,代码来源:FetchBillable.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->loadConfig($input);
     $from_date = $this->getHarvestFromDate("Ymd", "yesterday");
     $to_date = $this->getHarvestToDate("Ymd", "yesterday");
     $chartType = $this->getChartType("numberstat");
     $chartPeriod = $this->getChartPeriod(null);
     if (!($outputFilename = $input->getOption("output-file"))) {
         $outputFilename = 'ComparePeriods-' . $from_date . '-' . $to_date . '.xml';
     }
     if ($this->getHarvestExcludeContractors()) {
         $output->writeln('NOTE: Contractors are excluded from the dataset!');
     }
     $output->writeln('ComparePeriods executed: ' . date('Ymd H:i:s'));
     $output->writeln('Output filename: ' . $outputFilename);
     // 		$output->writeln(sprintf('Chart type is "%s" and period is "%s"',$chartType,$chartPeriod));
     $datetime1 = new \DateTime($to_date);
     $datetime2 = new \DateTime($from_date);
     $interval = $datetime1->diff($datetime2);
     /*
         echo "Datetime1: (to) " .  $datetime1->format('Ymd') . "\n";
         echo "Datetime2: (from) " .  $datetime2->format('Ymd') . "\n";    
         echo "Diff: ". $interval->format('%R%a days') . "\n";
     */
     // subtract one day as all days are inclusive
     $prev_to_date = $datetime2->sub(new \DateInterval('P1D'))->format('Ymd');
     $prev_from_date = $datetime2->sub(new \DateInterval($interval->format('P%aD')))->format('Ymd');
     /*
         echo "new to date: " . $prev_to_date  . "\n";
         echo "new from date: " . $prev_from_date  . "\n";
     */
     switch ($chartType) {
         case 'numberstat':
             $output->writeln(sprintf("Collecting Harvest entries between %s to %s", $from_date, $to_date));
             $currentPeriodEntries = $this->fetchBillableHoursInPeriod($from_date, $to_date);
             $output->writeln("\n");
             $output->writeln(sprintf("Collecting Harvest entries between %s to %s", $prev_from_date, $prev_to_date));
             $prevPeriodEntries = $this->fetchBillableHoursInPeriod($prev_from_date, $prev_to_date);
             // prepare the response!
             $geckoresponse = new \GeckoResponse();
             $data['type'] = "standard";
             $data['item'][] = array('value' => round($currentPeriodEntries["statistics"]["totalhours"], 0), 'text' => 'hours');
             $data['item'][] = array('value' => round($prevPeriodEntries["statistics"]["totalhours"], 0), 'text' => '');
             $data = $geckoresponse->getResponse($data, true);
             break;
         case 'numberstatbudget':
             $output->writeln(sprintf("Collecting Harvest entries between %s to %s", $from_date, $to_date));
             $currentPeriodEntries = $this->fetchBillableHoursInPeriod($from_date, $to_date);
             // prepare the response!
             $geckoresponse = new \GeckoResponse();
             $data['type'] = "standard";
             $data['item'][] = array('value' => round($currentPeriodEntries["statistics"]["totalhours"], 0), 'text' => 'hours');
             $data['item'][] = array('value' => round($currentPeriodEntries["statistics"]["totalbudget"], 2), 'text' => '');
             $data = $geckoresponse->getResponse($data, true);
             break;
         default:
             $output->writeln("ComparePeriods ChartType not recognized -> " . $chartType . "");
             return;
             break;
     }
     // lets write the data to a file
     if ($data) {
         $outputFile = new StreamOutput(fopen('data/' . $outputFilename, 'w', false));
         $outputFile->doWrite($data, false);
         $output->writeln("\nComparePeriods completed -> " . $outputFilename . " updated");
     }
 }
开发者ID:reload,项目名称:harvestdata,代码行数:67,代码来源:ComparePeriods.php


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