當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Batch::setFiles方法代碼示例

本文整理匯總了PHP中Batch::setFiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP Batch::setFiles方法的具體用法?PHP Batch::setFiles怎麽用?PHP Batch::setFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Batch的用法示例。


在下文中一共展示了Batch::setFiles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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());
 }
開發者ID:vijaynalawade-avalara,項目名稱:AvaTax-SOAP-PHP-SDK,代碼行數:57,代碼來源:BatchSvcTest.php


注:本文中的Batch::setFiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。