当前位置: 首页>>代码示例>>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;未经允许,请勿转载。