本文整理汇总了PHP中Batch类的典型用法代码示例。如果您正苦于以下问题:PHP Batch类的具体用法?PHP Batch怎么用?PHP Batch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Batch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchProfileDetailsByBusinessData
/**
* Fetch profile details by business data
*
* @param Batch $batch The batch to add this to
* @param string[] $parameters The parameters for request
* @throws \Exception
*/
public function fetchProfileDetailsByBusinessData(Batch $batch, $parameters)
{
if ($batch->hasBeenCommitted()) {
throw new \Exception("Attempting to add task to a batch which has already been comitted!");
}
$parameters['batch-id'] = $batch->getBatchId();
$this->api->post('/v4/ld/fetch-profile-details-by-business-data', $parameters);
}
示例2: testBatchFile
function testBatchFile()
{
global $client;
$batchID = 0;
$uploadedFilePath = "";
//BatchSave
$batch = new Batch();
$batch->setBatchStatusId("Waiting");
$batch->setBatchTypeId("ItemImport");
$batch->setCompanyId(31115);
$batch->setName("ItemImportTest.xls");
$batch->setOptions("Add File");
$batchFile = new BatchFile();
$batchFile->setName("ItemImportTest.xls");
$filename = "c:\\Batch\\ItemImportTest.xls";
$contents = $this->ReadContents($filename);
$batchFile->setFilePath($filename);
$batchFile->setSize(strlen($contents));
$batchFile->setContent($contents);
$batchFiles = array($batchFile);
$batch->setFiles($batchFiles);
$batchSaveResult = $client->BatchSave($batch);
$this->assertEqual(SeverityLevel::$Success, $batchSaveResult->getResultCode());
$batchID = $batchSaveResult->getBatchId();
//BatchFileSave- save BatchFile in that BAtchFile only
$file = new BatchFile();
//Set BatchId for recently stored batch
$file->setBatchId($batchID);
$file->setName("Error.xls");
$file->setSize(100);
$file->setContentType("content type");
$filename = "c:\\Batch\\Errors.xls";
$contents = $this->ReadContents($filename);
$file->setContent($contents);
$fileSaveResult = $client->BatchFileSave($file);
$this->assertEqual(SeverityLevel::$Success, $fileSaveResult->getResultCode());
//BatchFileFetch
$fetchRequest = new FetchRequest();
$fetchRequest->setFields("*,Content");
$fetchRequest->setFilters("BatchFileId=" . $fileSaveResult->getBatchFileId());
$batchFileFetchResult = $client->BatchFileFetch($fetchRequest);
$this->assertEqual(SeverityLevel::$Success, $batchFileFetchResult->getResultCode());
foreach ($batchFileFetchResult->getBatchFiles() as $batchFile) {
$this->assertEqual("Error.xls", $batchFile->getName());
}
//BatchFile delete
$delRequest = new DeleteRequest();
$delRequest->setFilters("BatchFileId=" . $fileSaveResult->getBatchFileId());
$delRequest->setMaxCount(1);
$delResult = $client->BatchFileDelete($delRequest);
$this->assertEqual(SeverityLevel::$Success, $delResult->getResultCode());
//Batch Delete
$delRequest = new DeleteRequest();
$delRequest->setFilters("BatchId=" . $batchID);
$delResult = $client->BatchDelete($delRequest);
$this->assertEqual(SeverityLevel::$Success, $delResult->getResultCode());
}
示例3: batchjsonAction
function batchjsonAction()
{
$this->_helper->viewRenderer->setNoRender();
$batchID = $this->_request->getParam('batchID');
Zend_Loader::loadClass('Batch');
Zend_Loader::loadClass('Document');
$batchObj = new Batch();
$batch = $batchObj->getByID($batchID);
if (!$batch) {
throw new Zend_Controller_Action_Exception('Cannnot find this page: ' . $this->_request->getRequestUri(), 404);
}
$batch["documents"] = $batchObj->documents;
header('Content-Type: application/json; charset=utf8');
echo Zend_Json::encode($batch);
}
示例4: create
public static function create($batchId, $urlId, $proxyId, $updateBatch)
{
SystemUtility::log('PING START', true);
SystemUtility::log('GATHERING DATA');
# Update batch here in case something crashes below
if ($updateBatch) {
SystemUtility::log('THIS IS THE LAST PING IN BATCH');
$batch = \Batch::findFirst();
$batch->updatedAt = SystemUtility::getSqlNowDate();
$batch->save();
}
$url = \Url::findFirst($urlId);
$proxy = \Proxy::findFirst($proxyId);
# Create new ping
$ping = new \Ping();
$ping->batchId = $batchId;
$ping->proxyId = $proxyId;
$ping->httpCode = self::HTTP_CODE_IN_PROGRESS;
$ping->duration = 0;
$ping->error = '';
$ping->save();
self::doPing($ping, $url, $proxy);
SystemUtility::log('PING END');
return $ping;
}
示例5: actionDelete
public function actionDelete()
{
if (array_key_exists("batchIds", $_POST)) {
$batchIds = (array) $_POST["batchIds"];
$batch = new Batch();
$batch->organizationId = Yii::app()->user->getOrgId();
/*this is important to avoid one moderator to edit/delete other org batches*/
foreach ($batchIds as $bId) {
$batch->id = $bId;
$batch->delete();
}
$this->render('delete');
} else {
Yii::app()->end();
}
}
示例6: processWindow
public function processWindow($window, $id, $ctrl, $param1, $param2)
{
global $neardBs, $neardBins, $neardLang, $neardWinbinder;
$name = $neardWinbinder->getText($this->wbInputName[WinBinder::CTRL_OBJ]);
$target = $neardWinbinder->getText($this->wbInputDest[WinBinder::CTRL_OBJ]);
switch ($id) {
case $this->wbBtnDest[WinBinder::CTRL_ID]:
$target = $neardWinbinder->sysDlgPath($window, $neardLang->getValue(Lang::GENSSL_PATH), $target);
if ($target && is_dir($target)) {
$neardWinbinder->setText($this->wbInputDest[WinBinder::CTRL_OBJ], $target . '\\');
}
break;
case $this->wbBtnSave[WinBinder::CTRL_ID]:
$neardWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_SAVE + 1);
$neardWinbinder->incrProgressBar($this->wbProgressBar);
$target = Util::formatUnixPath($target);
if (Batch::genSslCertificate($name, $target)) {
$neardWinbinder->incrProgressBar($this->wbProgressBar);
$neardWinbinder->messageBoxInfo(sprintf($neardLang->getValue(Lang::GENSSL_CREATED), $name), $neardLang->getValue(Lang::GENSSL_TITLE));
$neardWinbinder->destroyWindow($window);
} else {
$neardWinbinder->messageBoxError($neardLang->getValue(Lang::GENSSL_CREATED_ERROR), $neardLang->getValue(Lang::GENSSL_TITLE));
$neardWinbinder->resetProgressBar($this->wbProgressBar);
}
break;
case IDCLOSE:
case $this->wbBtnCancel[WinBinder::CTRL_ID]:
$neardWinbinder->destroyWindow($window);
break;
}
}
示例7: action_post
public function action_post($id)
{
if (Request::$is_ajax) {
if (isset($_POST['message']) && Batch::exists($id)) {
Batch::client_post($id, $_POST['message']);
}
} else {
$this->request->status = 403;
}
}
示例8: indexAction
/**
* The start action, it shows the "search" view
*/
public function indexAction()
{
$searchParams = ['ping.batchId' => 'batchId', 'ping.proxyId' => 'proxyId', 'b.urlId' => 'urlId'];
Tag::setDefaults(array('urlId' => $this->request->get('urlId'), 'proxyId' => $this->request->get('proxyId'), 'pingId' => $this->request->get('pingId'), 'batchId' => $this->request->get('batchId')));
$this->view->pings = $this->searchPings($searchParams);
$this->view->proxies = Proxy::find();
$this->view->urls = Url::find();
$this->view->batches = Batch::find();
#$this->view->disable();
}
示例9: getProcessedResponse
/**
* Get the batch part identified by the array key (0...n) or its id (if it was set with nextBatchPartId($id) )
*
* @throws ClientException
* @return mixed $partId
*/
public function getProcessedResponse()
{
$response = $this->getResponse();
switch ($this->_type) {
case 'getdocument':
$json = $response->getJson();
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Document::createFromArray($json, $options);
break;
case 'document':
$json = $response->getJson();
if ($json['error'] === false) {
$id = $json[Document::ENTRY_ID];
$response = $id;
}
break;
case 'getedge':
$json = $response->getJson();
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Edge::createFromArray($json, $options);
break;
case 'edge':
$json = $response->getJson();
if ($json['error'] === false) {
$id = $json[Edge::ENTRY_ID];
$response = $id;
}
break;
case 'getcollection':
$json = $response->getJson();
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = Collection::createFromArray($json, $options);
break;
case 'collection':
$json = $response->getJson();
if ($json['error'] === false) {
$id = $json[Collection::ENTRY_ID];
$response = $id;
}
break;
case 'cursor':
$options = $this->getCursorOptions();
$options['isNew'] = false;
$response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options);
break;
default:
throw new ClientException('Could not determine response data type.');
break;
}
return $response;
}
示例10: saveRelationship
/**
* Save the given relationship
*
* @param Relationship $rel
* @return boolean
*/
public function saveRelationship(Relationship $rel)
{
if ($this->openBatch) {
$this->openBatch->save($rel);
return true;
}
if ($rel->hasId()) {
return $this->runCommand(new Command\UpdateRelationship($this, $rel));
} else {
return $this->runCommand(new Command\CreateRelationship($this, $rel));
}
}
示例11: __construct
public function __construct($args)
{
global $neardCore, $neardLang, $neardBins, $neardWinbinder;
if (file_exists($neardCore->getExec())) {
$action = file_get_contents($neardCore->getExec());
if ($action == self::QUIT) {
Batch::exitApp();
} elseif ($action == self::RESTART) {
Batch::restartApp();
}
@unlink($neardCore->getExec());
}
}
示例12: testWriteManyMany_CreateParentAndChildren_WritesManyMany
/**
*
*/
public function testWriteManyMany_CreateParentAndChildren_WritesManyMany()
{
$parent = new Batman();
$parent->Name = 'Bruce Wayne';
$parent->Car = 'Bat mobile';
$children = array();
for ($i = 0; $i < 5; $i++) {
$child = new Child();
$child->Name = 'Soldier #' . $i;
$children[] = $child;
}
$batch = new \Batch();
$batch->write(array($parent));
$batch->write($children);
$sets = array();
foreach ($children as $child) {
$sets[] = array($parent, 'Children', $child);
}
$batch->writeManyMany($sets);
$parent = Human::get()->first();
$this->assertEquals(5, $parent->Children()->Count());
}
示例13: list_batches
public static function list_batches()
{
global $user;
$list = new List_IO("BaseBatchList", "ajax.php?nav=base", "batch_list_batches", "batch_count_batches", $argument_array, "BatchList");
$list->add_column("", "symbol", false, "16px");
$list->add_column(Language::get_message("BaseGeneralListColumnName", "general"), "name", true, null);
$list->add_column(Language::get_message("BaseGeneralListColumnStatus", "general"), "status", true, null);
$list->add_column(Language::get_message("BaseGeneralListColumnUser", "general"), "user", true, null);
$list->add_column(Language::get_message("BaseGeneralListColumnCreatedAt", "general"), "created_at", true, null);
$template = new HTMLTemplate("base/batch/list.html");
if ($user->is_admin() and Batch::get_type_id_by_internal_name("TEST") != null) {
$template->set_var("test_batch", true);
} else {
$template->set_var("test_batch", false);
}
$template->set_var("list", $list->get_list());
$template->output();
}
示例14: processWindow
public function processWindow($window, $id, $ctrl, $param1, $param2)
{
global $neardBs, $neardBins, $neardLang, $neardWinbinder;
$serverName = $neardWinbinder->getText($this->wbInputServerName[WinBinder::CTRL_OBJ]);
$documentRoot = $neardWinbinder->getText($this->wbInputDocRoot[WinBinder::CTRL_OBJ]);
switch ($id) {
case $this->wbInputServerName[WinBinder::CTRL_ID]:
$neardWinbinder->setText($this->wbLabelExp[WinBinder::CTRL_OBJ], sprintf($neardLang->getValue(Lang::VHOST_EXP_LABEL), $serverName, $documentRoot));
$neardWinbinder->setEnabled($this->wbBtnSave[WinBinder::CTRL_OBJ], empty($serverName) ? false : true);
break;
case $this->wbBtnDocRoot[WinBinder::CTRL_ID]:
$documentRoot = $neardWinbinder->sysDlgPath($window, $neardLang->getValue(Lang::VHOST_DOC_ROOT_PATH), $documentRoot);
if ($documentRoot && is_dir($documentRoot)) {
$neardWinbinder->setText($this->wbInputDocRoot[WinBinder::CTRL_OBJ], $documentRoot . '\\');
$neardWinbinder->setText($this->wbLabelExp[WinBinder::CTRL_OBJ], sprintf($neardLang->getValue(Lang::VHOST_EXP_LABEL), $serverName, $documentRoot . '\\'));
}
break;
case $this->wbBtnSave[WinBinder::CTRL_ID]:
$neardWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_SAVE + 1);
$neardWinbinder->incrProgressBar($this->wbProgressBar);
if (is_file($neardBs->getVhostsPath() . '/' . $serverName . '.conf')) {
$neardWinbinder->messageBoxError(sprintf($neardLang->getValue(Lang::VHOST_ALREADY_EXISTS), $serverName), $neardLang->getValue(Lang::ADD_VHOST_TITLE));
$neardWinbinder->resetProgressBar($this->wbProgressBar);
break;
}
if (Batch::genSslCertificate($serverName) && file_put_contents($neardBs->getVhostsPath() . '/' . $serverName . '.conf', $neardBins->getApache()->getVhostContent($serverName, $documentRoot)) !== false) {
$neardWinbinder->incrProgressBar($this->wbProgressBar);
Util::addWindowsHost('127.0.0.1', $serverName);
$neardWinbinder->incrProgressBar($this->wbProgressBar);
$neardBins->getApache()->getService()->restart();
$neardWinbinder->incrProgressBar($this->wbProgressBar);
$neardWinbinder->messageBoxInfo(sprintf($neardLang->getValue(Lang::VHOST_CREATED), $serverName, $serverName, $documentRoot), $neardLang->getValue(Lang::ADD_VHOST_TITLE));
$neardWinbinder->destroyWindow($window);
} else {
$neardWinbinder->messageBoxError($neardLang->getValue(Lang::VHOST_CREATED_ERROR), $neardLang->getValue(Lang::ADD_VHOST_TITLE));
$neardWinbinder->resetProgressBar($this->wbProgressBar);
}
break;
case IDCLOSE:
case $this->wbBtnCancel[WinBinder::CTRL_ID]:
$neardWinbinder->destroyWindow($window);
break;
}
}
示例15: pathinfo
<?php
require_once "header.php";
if ($session->is_logged_in()) {
$loggeduser = User::get_by_id($session->user_id);
}
$pathinfo = pathinfo($_SERVER["PHP_SELF"]);
$basename = $pathinfo["basename"];
$currentFile = str_replace(".php", "", $basename);
$pageURL = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
echo "<input id='batchid' type='hidden' value='" . $_GET['id'] . "'>";
if (isset($_GET['id'])) {
$batch = Batch::get_by_id($_GET['id']);
$school = School::get_by_id($batch->schoolid);
$batchUsers = BatchUser::getUsersInBatch($batch->id);
if ($session->is_logged_in()) {
if (!User::get_by_id($session->user_id)->is_super_admin()) {
if ($batch->pending == 1 || $batch->enabled == 0) {
header("location: index.php?negative");
}
}
} else {
if ($batch->pending == 1 || $batch->enabled == 0) {
header("location: index.php?negative");
}
}
} else {
header("location: index.php?negative");
}
?>