function postProcess(&$params, &$db, &$form)
 {
     $file = $params['uploadFile']['name'];
     $result = self::_CsvToTable($db, $file, CRM_Utils_Array::value('skipColumnHeader', $params, FALSE), CRM_Utils_Array::value('import_table_name', $params), CRM_Utils_Array::value('fieldSeparator', $params, ','));
     $form->set('originalColHeader', CRM_Utils_Array::value('original_col_header', $result));
     $table = $result['import_table_name'];
     $importJob = new CRM_Import_ImportJob($table);
     $form->set('importTableName', $importJob->getTableName());
 }
Example #2
0
 function postProcess(&$params, &$db)
 {
     $file = $params['uploadFile']['name'];
     $result = self::_CsvToTable($db, $file, $params['skipColumnHeader'], CRM_Utils_Array::value('import_table_name', $params));
     $this->set('originalColHeader', CRM_Utils_Array::value('original_col_header', $result));
     $table = $result['import_table_name'];
     require_once 'CRM/Import/ImportJob.php';
     $importJob = new CRM_Import_ImportJob($table);
     $this->set('importTableName', $importJob->getTableName());
 }
 public function runIncompleteImportJobs($timeout = 55)
 {
     $startTime = time();
     $incompleteImportTables = CRM_Import_ImportJob::getIncompleteImportTables();
     foreach ($incompleteImportTables as $importTable) {
         $importJob = new CRM_Import_ImportJob($importTable);
         $importJob->runImport(NULL, $timeout);
         $currentTime = time();
         if ($currentTime - $startTime >= $timeout) {
             break;
         }
     }
 }
Example #4
0
 public function postProcess(&$params, &$db)
 {
     require_once 'CRM/Import/ImportJob.php';
     $importJob = new CRM_Import_ImportJob(CRM_Utils_Array::value('import_table_name', $params), $params['sqlQuery'], true);
     $this->set('importTableName', $importJob->getTableName());
 }
Example #5
0
 /**
  * Process the mapped fields and map it into the uploaded file
  * preview the file and extract some summary statistics
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $importJobParams = array('doGeocodeAddress' => $this->controller->exportValue('DataSource', 'doGeocodeAddress'), 'invalidRowCount' => $this->get('invalidRowCount'), 'conflictRowCount' => $this->get('conflictRowCount'), 'onDuplicate' => $this->get('onDuplicate'), 'newGroupName' => $this->controller->exportValue($this->_name, 'newGroupName'), 'newGroupDesc' => $this->controller->exportValue($this->_name, 'newGroupDesc'), 'groups' => $this->controller->exportValue($this->_name, 'groups'), 'allGroups' => $this->get('groups'), 'newTagName' => $this->controller->exportValue($this->_name, 'newTagName'), 'newTagDesc' => $this->controller->exportValue($this->_name, 'newTagDesc'), 'tag' => $this->controller->exportValue($this->_name, 'tag'), 'allTags' => $this->get('tag'), 'mapper' => $this->controller->exportValue('MapField', 'mapper'), 'mapFields' => $this->get('fields'), 'contactType' => $this->get('contactType'), 'contactSubType' => $this->get('contactSubType'), 'primaryKeyName' => $this->get('primaryKeyName'), 'statusFieldName' => $this->get('statusFieldName'), 'statusID' => $this->get('statusID'), 'totalRowCount' => $this->get('totalRowCount'));
     $tableName = $this->get('importTableName');
     require_once 'CRM/Import/ImportJob.php';
     $importJob = new CRM_Import_ImportJob($tableName);
     $importJob->setJobParams($importJobParams);
     // update cache before starting with runImport
     $session =& CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     require_once 'CRM/ACL/BAO/Cache.php';
     CRM_ACL_BAO_Cache::updateEntry($userID);
     // run the import
     $importJob->runImport($this);
     // update cache after we done with runImport
     require_once 'CRM/ACL/BAO/Cache.php';
     CRM_ACL_BAO_Cache::updateEntry($userID);
     // add all the necessary variables to the form
     $importJob->setFormVariables($this);
     // check if there is any error occured
     $errorStack =& CRM_Core_Error::singleton();
     $errors = $errorStack->getErrors();
     $errorMessage = array();
     if (is_array($errors)) {
         foreach ($errors as $key => $value) {
             $errorMessage[] = $value['message'];
         }
         // there is no fileName since this is a sql import
         // so fudge it
         $config =& CRM_Core_Config::singleton();
         $errorFile = $config->uploadDir . "sqlImport.error.log";
         if ($fd = fopen($errorFile, 'w')) {
             fwrite($fd, implode('\\n', $errorMessage));
         }
         fclose($fd);
         $this->set('errorFile', $errorFile);
         $this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=1'));
         $this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=2'));
         $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=4'));
     }
     //hack to clean db
     //if job complete drop table.
     $importJob->isComplete(true);
 }