Esempio n. 1
0
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     $importHash = $context->getEnvironment('_import_hash');
     $importer = \Workflow\Importer::getInstance($importHash);
     $importer->set('finish', true);
     //        $importState = $context->getEnvironment("_internal");
     //
     //        $importState["finish"] = true;
     //
     //        $context->setEnvironment("_internal", $importState);
     $result = array("done" => $importer->get('seek'), "ready" => true);
     echo json_encode($result);
     exit;
 }
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     //        $importState = $context->getEnvironment("_internal");
     $pause_rows = $this->get("pause_rows");
     $importHash = $context->getEnvironment('_import_hash');
     $importer = \Workflow\Importer::getInstance($importHash);
     if ($pause_rows !== -1 && !empty($pause_rows)) {
         if ($importer->get("seek") - $importer->get("lastPause") >= $pause_rows && $importer->get("total") > $importer->get("seek")) {
             $debugValue = $importer->get("seek");
             $importer->set("lastPause", $importer->get('seek'));
             //                $context->setEnvironment("_internal", $importState);
             \Workflow\Queue::addEntry($this, $this->getWorkflow()->getUser(), $context, "static", time() + 864000 * 3, 1);
             $totalRows = $importer->get("total");
             $seek = $importer->get("seek");
             $importParams = $importer->get("importParams");
             if (!empty($importParams['skipfirst'])) {
                 $totalRows -= 1;
                 $seek -= 1;
             }
             $result = array("done" => $seek, 'total' => $totalRows, "ready" => false, 'debug' => $debugValue);
             $importer->set("execID", $this->getExecId());
             echo json_encode($result);
             exit;
         }
     }
     do {
         $row = $importer->getNextRow();
         $importer->set("seek", $importer->get("seek") + 1);
         //            $importer->get("seek")++;
         if ($row == false) {
             return "no";
         }
     } while (count($row) == 1 && empty($row[0]));
     // leere Zeilen am Ende der Datei werden nicht wieder in das Environment geschrieben und somit nicht mitgezählt!
     //        $context->setEnvironment("_internal", $importState);
     #$importState["pos"]++;
     #$context->setEnvironment("_internal", $importState);
     $cols = $this->get("cols");
     $csv = array();
     foreach ($cols as $index => $colKey) {
         $csv[$colKey] = $row[$index];
     }
     $context->setEnvironment("csv", $csv);
     return "yes";
 }
Esempio n. 3
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["drfxxcw"] = "workflow";
     ${"GLOBALS"}["qdicwdai"] = "context";
     $yygxkirxkn = "hash";
     $lmnathdjcp = "params";
     $szuzcuefxy = "execId";
     $vleloffw = "environment";
     global $current_user;
     ${${"GLOBALS"}["ppcqurfuseke"]} = PearDatabase::getInstance();
     ${$lmnathdjcp} = $request->getAll();
     ${${"GLOBALS"}["dchjxoxtxl"]} = (int) $request->get("workflow");
     ${$yygxkirxkn} = $request->get("hash");
     ${${"GLOBALS"}["iujcwkxmrghj"]} = \Workflow\Importer::getInstance(${${"GLOBALS"}["giulhdd"]});
     ${"GLOBALS"}["yijvwhkkly"] = "ready";
     ${"GLOBALS"}["civjsw"] = "current_user";
     ${${"GLOBALS"}["kblmucwe"]} = $objImporter->get("execId");
     $gbidioupkub = "hash";
     if (!empty(${$szuzcuefxy})) {
         $uomjohpljtr = "execId";
         $amancvjzyb = "task";
         ${"GLOBALS"}["ihdjnerjw"] = "sql";
         ${${"GLOBALS"}["hkxcia"]} = \Workflow\Queue::getQueueEntryByExecId(${$uomjohpljtr});
         ${"GLOBALS"}["mtarmljwhk"] = "task";
         ${${"GLOBALS"}["ihdjnerjw"]} = "DELETE FROM vtiger_wf_queue WHERE id = " . ${$amancvjzyb}["queue_id"] . "";
         $adb->query(${${"GLOBALS"}["fmhsywrhw"]});
         \Workflow\Queue::runEntry(${${"GLOBALS"}["mtarmljwhk"]});
         exit;
     }
     ${${"GLOBALS"}["hfdtldd"]} = \Workflow\VTEntity::getDummy();
     ${${"GLOBALS"}["xuwgiqqwoqm"]} = new \Workflow\Main(${${"GLOBALS"}["drfxxcw"]}, false, ${${"GLOBALS"}["civjsw"]});
     ${$vleloffw} = array("_import_hash" => ${$gbidioupkub}, "_internal" => $_SESSION["_import_data"][${${"GLOBALS"}["giulhdd"]}]);
     ${${"GLOBALS"}["ibtbwjumn"]}["importParams"] = $objImporter->get("importParams");
     $context->loadEnvironment(${${"GLOBALS"}["ibtbwjumn"]});
     $objWorkflow->setContext(${${"GLOBALS"}["qdicwdai"]});
     $objWorkflow->start();
     ${${"GLOBALS"}["ibtbwjumn"]} = $context->getEnvironment();
     ${${"GLOBALS"}["meglgccnf"]} = $objImporter->get("ready");
     if (${${"GLOBALS"}["yijvwhkkly"]} == true) {
         $objImporter->handleFinish();
     } else {
         $objImporter->handlePause();
     }
 }