function indexingCatalogAction() { $guid = $this->_getParam('guid') ? $this->_getParam('guid') : ''; $catalogGuid = $this->_getParam('catalogGuid') ? $this->_getParam('catalogGuid') : ''; $solrAdapter = Pandamp_Search::manager(); try { $solrAdapter->indexCatalog($catalogGuid); $tblTmpIndex = new Pandamp_Modules_Extension_Index_Model_TmpIndex(); $tblTmpIndex->delete("guid='{$guid}'"); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $username = '******' . $auth->getIdentity()->username; } else { $username = '******'; } // log to assetSetting $tblAssetSetting = new Pandamp_Modules_Dms_Catalog_Model_AssetSetting(); $rowAsset = $tblAssetSetting->fetchRow("application='INDEX CATALOG'"); if ($rowAsset) { $rowAsset->valueText = "Update indexing-catalog at " . date("d-m-Y H:i:s") . $username; $rowAsset->valueInt = $rowAsset->valueInt + 1; } else { $gman = new Pandamp_Core_Guid(); $catalogGuid = $gman->generateGuid(); $rowAsset = $tblAssetSetting->fetchNew(); $rowAsset->guid = $catalogGuid; $rowAsset->application = "INDEX CATALOG"; $rowAsset->part = "KUTU"; $rowAsset->valueType = "INDEX"; $rowAsset->valueInt = 0; $rowAsset->valueText = "Indexing catalog at " . date("d-m-Y H:i:s") . $username; } $rowAsset->save(); $this->view->success = true; } catch (Exception $e) { $this->view->success = false; } }
public function reIndexCatalog() { gc_enable(); $this->emptyIndex(); $time_start = microtime(true); $solr =& $this->_solr; $formater = new Pandamp_Lib_Formater(); $title = new Pandamp_Controller_Action_Helper_GetCatalogTitle(); // $tbl = new Pandamp_Core_Orm_Table_Catalog(); // $rowset = $tbl->fetchAll(); //("profileGuid='Pandamp_peraturan'"); $query = "SELECT * FROM KutuCatalog"; $results = $this->_conn->query($query); $rowset = $results->fetchAll(PDO::FETCH_OBJ); $documents = array(); $rowCount = count($rowset); for ($iCount = 0; $iCount < $rowCount; $iCount++) { $row = $rowset[$iCount]; // if($iCount == 100) // break; // echo 'urutan: '.$iCount .'<br>'; $nextRow = $rowset[$iCount + 1]; // echo 'current guid: '.$row->guid.' '.'next guid: '.$nextRow->guid.'<br>'; if ($row->modifiedBy !== $row->createdBy) { $modified = '<font color=red>[modifiedBy:<i>' . $row->modifiedBy . '</i>]</font> '; } else { $modified = ''; } echo '<li><span style="font:11px verdana,arial,helvetica,sans-serif;">[urutan:' . $iCount . '] indexing:<font color=green>' . $title->getCatalogTitle($row->guid) . '</font>[current guid: ' . $row->guid . ' ' . 'next guid: ' . $nextRow->guid . '][author:<i>' . $row->createdBy . '</i>] ' . $modified . '[createdDate:<i>' . $formater->get_date($row->createdDate) . '</i>]</span></li>'; $documents[] = $this->_createSolrDocument($row); if ($iCount % 500 == 0) { try { $solr->addDocuments($documents); $solr->commit(); // $solr->optimize(); $documents = array(); } catch (Exception $e) { // echo "Error occured when processing record starting from number: ". ($iCount - 1000) . ' to '.$iCount.' '.$row->guid; $log->err($e->getMessage()); throw new Zend_Exception($e->getMessage()); // echo $e->getMessage().'<br>'; } } flush(); } echo '</ul></div></td></tr></table>'; try { $solr->addDocuments($documents); $solr->commit(); // $solr->optimize(); } catch (Exception $e) { $log->err($e->getMessage()); throw new Zend_Exception($e->getMessage()); // echo $e->getMessage().'<br>'; } $time_end = microtime(true); $time = $time_end - $time_start; // echo'<br>WAKTU EKSEKUSI: '. $time; // $log->info("WAKTU EKSEKUSI: ". $time." indexing catalog ".$iCount." dari ".$rowCount ." ".$username); echo '<br><br><span style="font:11px verdana,arial,helvetica,sans-serif;color:#00FF00">WAKTU EKSEKUSI: ' . $time . '<br>indexing catalog ' . $iCount . ' dari ' . $rowCount . '</span>'; // log to assetSetting $tblAssetSetting = new Pandamp_Modules_Dms_Catalog_Model_AssetSetting(); $rowAsset = $tblAssetSetting->fetchRow("application='INDEX CATALOG'"); if ($rowAsset) { $rowAsset->valueText = "Update {$rowCount} indexing-catalog at " . date("Y-m-d H:i:s") . $username; $rowAsset->valueInt = $rowAsset->valueInt + 1; } else { $gman = new Pandamp_Core_Guid(); $catalogGuid = $gman->generateGuid(); $rowAsset = $tblAssetSetting->fetchNew(); $rowAsset->guid = $catalogGuid; $rowAsset->application = "INDEX CATALOG"; $rowAsset->part = "KUTU"; $rowAsset->valueType = "INDEX"; $rowAsset->valueInt = 0; $rowAsset->valueText = $rowCount . " Indexing catalog at " . date("Y-m-d H:i:s") . $username; } $rowAsset->save(); }
function downloadFile_OldAction() { $this->_helper->layout()->disableLayout(); $catalogGuid = $this->_getParam('guid'); $parentGuid = $this->_getParam('parent'); $tblCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog(); $rowsetCatalog = $tblCatalog->find($catalogGuid); if (count($rowsetCatalog)) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $guidUser = $auth->getIdentity()->kopel; } $tblAsetSetting = new Pandamp_Modules_Dms_Catalog_Model_AssetSetting(); $rowAset = $tblAsetSetting->find($catalogGuid)->current(); if ($rowAset) { $rowAset->valueInt = $rowAset->valueInt + 1; } else { $rowAset = $tblAsetSetting->fetchNew(); $rowAset->guid = $catalogGuid; $rowAset->application = "kutu_doc"; $rowAset->part = isset($guidUser) ? $guidUser : ''; $rowAset->valueType = gethostbyaddr($_SERVER['REMOTE_ADDR']); $rowAset->valueInt = 1; } $rowAset->save(); $rowCatalog = $rowsetCatalog->current(); $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute(); $contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value; $filename = $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value; $oriName = $oname = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value; $tblRelatedItem = new Pandamp_Modules_Dms_Catalog_Model_RelatedItem(); $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'"); $flagFileFound = false; foreach ($rowsetRelatedItem as $rowRelatedItem) { if (!$flagFileFound) { $parentGuid = $rowRelatedItem->relatedGuid; $sDir1 = ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $systemname; $sDir2 = ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname; $sDir3 = ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $oname; $sDir4 = ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $oname; if (file_exists($sDir1)) { $flagFileFound = true; header("Content-type: {$contentType}"); header("Content-Disposition: attachment; filename={$oriName}"); @readfile($sDir1); die; } else { if (file_exists($sDir2)) { $flagFileFound = true; header("Content-type: {$contentType}"); header("Content-Disposition: attachment; filename={$oriName}"); @readfile($sDir2); die; } } if (file_exists($sDir3)) { $flagFileFound = true; header("Content-type: {$contentType}"); header("Content-Disposition: attachment; filename={$oriName}"); @readfile($sDir3); die; } if (file_exists($sDir4)) { $flagFileFound = true; header("Content-type: {$contentType}"); header("Content-Disposition: attachment; filename={$oriName}"); @readfile($sDir4); die; } else { $flagFileFound = false; $this->_forward('forbidden', 'browser', 'hold'); } } } } else { $flagFileFound = false; $this->_forward('forbidden', 'browser', 'hold'); } }