예제 #1
0
    public function build()
    {/*{{{*/
        $this->myEcho("\n处理: ".get_class($this)."\n");
        $this->totalTimes = $this->getTotalDBTimes();
        $this->myEcho('数据获取次数: '.$this->totalTimes.' ('.$this->stepLen."条/次)\n");
        $this->myEcho('标准模版路径: '.$this->workPath."\n\n");
        $nowTimes= 1;
        $dataPond = array();
        XString::clearDir($this->workPath);
        $this->nowFile = 0;

        do{
            $this->myEcho('   #'.$nowTimes.' 读取');
            $datas = null;
            $datas = $this->getData($nowTimes, $this->stepLen);
            $this->myEcho(' -> 切片 ');
            $dataPond = $this->edward->shred($datas, $nowTimes, $this->totalTimes);
            $this->myEcho((string)$this->edward);

            if (count($dataPond))
            {
                $this->myEcho(' -> 保存');
            }
            foreach($dataPond as $data)
            {
                $this->myEcho(' '.$this->nowFile.'.'.self::SUFFIX_XML);
                $data = XString::convertEncoding($data, $this->charset, 'gbk');
                $this->write2File($data);
                unset($data);
                if($this->fileCntLimit != 0 && $this->nowFile >= $this->fileCntLimit)
                {
                    break 2;
                }
            }

            $nowTimes++;
            unset($dataPond);
            $this->myEcho("\n");
        } while ($nowTimes <= $this->totalTimes + 1);
    }/*}}}*/
예제 #2
0
 private function completeData($functionName)
 {/*{{{*/
     $className = str_replace("test", '', $functionName);
     $this->assertTrue(class_exists($className), $className."类不存在\n");
     $factory = new OpenFactory;
     $factory->wrapData();
     $dataPath = $configs->standardPath.strtolower($className);
     $configs =  BeanFinder::get('configs');
     $resPath = $configs->resPath.strtolower($className);
     $this->assertTrue(is_dir($resPath), $resPath."路径不存在\n");
     $fileList = XString::listFile($resPath);
     $this->assertNotEmpty($fileList, $className."下没有文件\n");
     XString::clearDir($dataPath);
     foreach ($fileList as $key => $file)
     {
         if (strstr($file, 'xml') == false)
         {
             unset ($fileList[$key]);
         }
     }
     return $fileList;
 }/*}}}*/
예제 #3
0
    private function processSource($sourceInfo)
    {/*{{{*/
        if( empty($sourceInfo['tpl']) || 
            empty($sourceInfo['data']) || 
            empty($sourceInfo['res']))
            return false;

        foreach ($sourceInfo['data'] as $dataName => $dataFiles)
        {
            $resDataPath = $this->resPath.$dataName."/";
            if (isset($sourceInfo['res']['subset']) && $sourceInfo['res']['subset'])
            {
                $resDataPath = $this->resPath.$dataName."_".$sourceInfo['res']['subset']."/";
            }
            XString::clearDir($resDataPath);
            foreach($dataFiles as  $num => $dataFile)
            {
                $resData = $this->wrap($sourceInfo['tpl'],$dataFile);
                $resDataFile = $resDataPath.$num.".".$sourceInfo['res']['extension'];
                XString::write2file($resData, $resDataFile);
                $this->myEcho("   写入 $resDataFile \n");
            }
        }
    }/*}}}*/