Ejemplo n.º 1
0
 public function import()
 {
     $projects = $this->projectEntity->fetchPairs("name", null);
     $statusNewRow = $this->lstErrorStatus->findOneBy(array("status" => "New"));
     foreach ($projects as $projectName => $index) {
         $fileList = $this->dataSource->getFileList("{$projectName}/exception");
         foreach ($fileList as $file) {
             if (pathinfo($file->name, PATHINFO_EXTENSION) != "html") {
                 continue;
             }
             $errorRow = $this->errorEntity->findOneBy(array("source_file" => $file->name));
             if (!$errorRow) {
                 try {
                     $errorFileContent = $this->dataSource->getFileContent($file->name);
                     $archiveFilePath = $this->dataSource->moveToArchive($file->name);
                     $this->exceptionParser->parse($errorFileContent);
                     $errorMessage = $this->exceptionParser->getMessage();
                     $title = $this->exceptionParser->getTitle();
                     $errorRow = $this->errorEntity->insert(array("project_id" => $projects[$projectName]->id, "error_status_id" => $statusNewRow->id, "title" => $title, "message" => $this->exceptionParser->getMessage(), "source_file" => $this->exceptionParser->getSourceFile(), "remote_file" => $archiveFilePath, "error_dt" => $file->lastModified, "ins_process_id" => __METHOD__));
                     $link = "http://" . $_SERVER["HTTP_HOST"] . "/error-list/display/" . $errorRow->id;
                     $this->hipChat->sendMessage("<b>{$projectName}</b> - {$title} - {$errorMessage} <a href=\"{$link}\">Show!</a>");
                 } catch (InvalidArgumentException $e) {
                     // file does not exists in source, how it can happen? That's the question, he?
                 }
             }
         }
     }
     $this->cache->save("lastUpdate", new \DateTime());
 }
Ejemplo n.º 2
0
 protected function configure($presenter)
 {
     $this->selection->select("error.id, title, message, error_dt, project_id.name AS project_name, error_status_id.status AS status");
     $source = new \NiftyGrid\DataSource\NDataSource($this->selection);
     $self = $this;
     $this->setDataSource($source);
     $this->setDefaultOrder("error_dt DESC");
     $this->addColumn("project_name", "Project")->setTableName("project_id")->setSortable()->setSelectFilter($this->projectEntity->findAll()->fetchPairs("id", "name"));
     $this->addColumn("title", "Title")->setTextFilter()->setSortable();
     $this->addColumn("message", "Message")->setSortable()->setTextFilter()->setRenderer(function ($row) use($presenter) {
         return \Nette\Utils\Html::el("a")->setText(trim($row["message"]) ? Strings::truncate($row["message"], 60) : $row["id"])->addAttributes(array("target" => "_blank"))->href($presenter->link("ErrorList:display", $row["id"]));
     });
     $this->addColumn("status", "Status")->setTableName("error_status_id")->setSelectFilter($this->lstErrorStatus->findAll()->fetchPairs("id", "status"))->setRenderer(function ($row) use($presenter) {
         $label = "";
         if ($row["status"] == "New") {
             $label = "label-important";
         }
         return \Nette\Utils\Html::el("span")->setText($row["status"])->addAttributes(array("class" => "label {$label}"));
     });
     if (!isset($this->filter['status'])) {
         $this->filter['status'] = '1';
     }
     $this->addColumn("error_dt", "Date", "150px")->setDateFilter()->setSortable()->setRenderer(function ($row) {
         return $row["error_dt"]->format("j.n.Y H:i:s");
     });
     $this->addButton("archive", "Archive")->setText("Archive")->setAjax()->setLink(function ($row) use($presenter) {
         return $presenter->link("archive!", $row['id']);
     })->setClass("btn-success btn-solve");
     /*
     		$this->addButton("createTask", "Create Task")
     			->setText('Create task')
     			->setAjax()
     			->setLink(function($row) use ($presenter){return $presenter->link("createTask!", $row['id']);})
     			->setClass("btn-info");
     */
     $this->addAction("archive", "Archive")->setAjax(true)->setCallback(function ($selectedItems) use($self) {
         $self->handleArchive($selectedItems);
     });
     $this->addAction("unarchive", "Unarchive")->setAjax(true)->setCallback(function ($selectedItems) use($self) {
         $self->handleUnArchive($selectedItems);
     });
 }