コード例 #1
3
 public function soapServer($request, $response)
 {/*{{{*/
     $postdata = file_get_contents("php://input");
     $function = 'soapServer';
     $this->ioLogRecorder->addLog(XDateTime::now()->toString()." service [{$function}] ".$this->ioLogRecorder->format2SimpleLog($postdata));
     $configs = ProviderConfigFactory::getProviderAppConfigs(PhoneConference::SPTYPE_HUAWEI, TeleConfProvider::APPTYPE_CONF);
     $callbackUrl = $configs['callbackUrl'];
     $server = new SoapServer(null, array('uri' => 'HuaweiConfCallback','location'=>$callbackUrl));
     $server->setClass('HuaweiTeleConfApi');
     try
     {
         $lockName = $this->getLockerName($postdata);
         $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
         $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
         $locker->getLock($lockName);
         $server->handle();
         $locker->releaseLock($lockName);
     }
     catch(Exception $ex)
     {
         $locker->releaseLock($lockName);
     }
     header("HTTP/1.1 202 Accepted");
     header("Content-Type: text/xml;charset=UTF-8");
     return parent::DIRECT_OUTPUT;
 }/*}}}*/
コード例 #2
0
 public function service($request, $response)
 {/*{{{*/
     ob_start();
     $result = $this->callCenterApi->returnSuccess();
     $function = $request->service;
     if(method_exists($this, $function))
     {
         try
         {
             $lockName = $this->getLockerName($request);
             $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
             $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
             $locker->getLock($lockName);
             $result = $this->$function($request,$response);
             $locker->releaseLock($lockName);
         }
         catch(LockException $ex)
         {
             error_log(XDateTime::now()->toString()."并发锁错误 $lockName\n", 3 , $this->logFileName);
         }
         catch(Exception $ex)
         {
             error_log(XDateTime::now()->toString()."释放锁 $lockName\n", 3 , $this->logFileName);
             $locker->releaseLock($lockName);
         }
     }
     echo $result;
     $this->logTxt .= XDateTime::now()->toString().'--->'.print_r($result, true)."\n";
     header('Content-Length: ' . ob_get_length());
     return parent::DIRECT_OUTPUT;
 }/*}}}*/
コード例 #3
0
 public function service($request, $response)
 {/*{{{*/
     ob_start();
     $result = "";
     $function = $request->service;
     if(method_exists($this, $function))
     {
         try
         {
             $lockName = $this->getLockerName($request);
             $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
             $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
             $locker->getLock($lockName);
             $result = $this->$function($request,$response);
             $locker->releaseLock($lockName);
         }
         catch(LockException $ex)
         {
             $this->ioLogRecorder->addLog(XDateTime::now()->toString()."并发锁错误 $lockName\n");
         }
         catch(Exception $ex)
         {
             $locker->releaseLock($lockName);
         }
     }
     echo $result;
     header('Content-Length: ' . ob_get_length());
     return parent::DIRECT_OUTPUT;
 }/*}}}*/
コード例 #4
0
 public function service($request, $response)
 {/*{{{*/
     ob_start();
     $function = $request->service;
     $result = $this->callCenterApi->responseCmdSucc();
     if(method_exists($this, $function))
     {
         try
         {
             $this->logTxt .= $function;
             $results = $this->xmlToArray(file_get_contents("php://input"));
             if(false == empty($results['ucid']))
             {
                 $lockName = $this->getLockerName($results);
                 $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
                 $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
                 $locker->getLock($lockName);
                 $result = $this->$function($request,$response);
                 $locker->releaseLock($lockName);
             }
             else
             {
                 $result = $this->$function($request,$response);
             }
         }
         catch(LockException $ex)
         {
             $this->logTxt .= XDateTime::now()->toString()." 并发锁错误 $lockName\n";
         }
         catch(Exception $ex)
         {
             $this->logTxt .= XDateTime::now()->toString()." 释放锁 $lockName\n";
             $locker->releaseLock($lockName);
         }
     }
     echo $result;
     $this->logTxt .= XDateTime::now()->toString().'--->'.print_r($result, true)."\n";
     header('Content-Length: ' . ob_get_length());
     return parent::DIRECT_OUTPUT;
 }/*}}}*/
コード例 #5
0
    public function service($request, $response)
    {/*{{{*/
        $function = $request->service;

        //这里用框架的request无法接收指定格式的数据,故用file_get_contents("php://input") by dfy
        $postdata = file_get_contents("php://input");
        $this->ioLogRecorder->addLog(XDateTime::now()->toString()." service [{$function}] ".$this->ioLogRecorder->format2SimpleLog($postdata));

        $postdata = json_decode($postdata, true);
        //需要调试详细日志时打开配置 by hyb
        //$this->printDetailCallbackLog($function, $postdata);

        ob_start();
        //给全时返回的数据
        $result = json_encode(array("statusCode" => '0'));
        if(method_exists($this, $function))
        {
            try
            {
                $lockName = $this->getLockerName($postdata);
                $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
                $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
                $locker->getLock($lockName);
                $this->$function($postdata);
                $locker->releaseLock($lockName);
            }
            catch(LockException $ex)
            {
                $this->ioLogRecorder->addLog(XDateTime::now()->toString()."并发锁错误 $lockName\n");
            }
            catch(Exception $ex)
            {
                $locker->releaseLock($lockName);
            }
        }
        echo $result;
        header('Content-Length: ' . ob_get_length());
        return parent::DIRECT_OUTPUT;
    }/*}}}*/
コード例 #6
0
 private function dealAutoCreatedConfOrder($orderId, $teleConfOwnerId)
 {/*{{{*/
     $lockName = "setconfowner{$orderId}";
     try
     {
         $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
         $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
         $locker->getLock($lockName);
         $confOwnerId = TelOrderClient::getInstance()->updateAdminUser4ConfOwner($teleConfOwnerId, $this->curUser);
         $locker->releaseLock($lockName);
     }
     catch(Exception $ex)
     {
         $locker->releaseLock($lockName);
     }
     return $teleConfOwnerId;
 }/*}}}*/
コード例 #7
0
<?php
/*
 * 功能:更新医生个人空间的sitemap.xml,以便搜索引擎查询,每个月的1号凌晨2:30分进行一次,注意凌晨3点有定时任务
 * 日志位置:/home/avatar/logs/webapps/spacefront/sitemap/exeTime_*
 */
$ROOT = dirname(__FILE__);
include_once($ROOT.'/../assembly.php');
ini_set('memory_limit', '128M');
$configFile = $ROOT.'/../config/config.php';
include_once($configFile);

$locker = LockUtil::factory(LockUtil::LOCK_TYPE_FILE, array('single' => true));
if (false == $locker->getLock(__FILE__)){
    exit;
}

$threadSplitNum = 10; //运行的php程序个数
system('sh '.$ROOT.'/createDataDirectory.sh');
$logPath = $ROOT.'/../root/logs/sitemap';
$spaceTotal = SpaceClient::getInstance()->getTotalComfirmedDoctor('Space'); //获得总大小
$pageSize = ceil($spaceTotal / $threadSplitNum);
$curPage = $threadSplitNum;
for(;$curPage > 0; --$curPage ){
	system("/usr/bin/nohup /Data/apps/php/bin/php {$ROOT}/updatedoctorsitemap.php {$curPage} {$pageSize} >> {$logPath}/exeTime_{$curPage}.log &");
}
$locker->releaseLock(__FILE__);
	
コード例 #8
0
    private function anaPostData($request,$response)
    {/*{{{*/
        //get post data, May be due to the different environments
        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
        if (!empty($postStr))
        {
           //保存数据
           $weixPostData = WeixClient::getInstance()->addWeixPostData($postStr, WeixUser::WEIXINTYPE_PATIENT);
           $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);

           $lockName = $postObj->FromUserName;  //微信的openid
           try
           {
               $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
               $locker  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
               $locker->getLock($lockName);
               $this->dealPostData($postObj);
               $locker->releaseLock($lockName);
           }
           catch(Exception $ex)
           {
               $locker->releaseLock($lockName);
           }
        }
        else 
        {
            echo mb_convert_encoding("你啥也没说", 'utf-8','auto');
        }
        exit;
    }/*}}}*/
コード例 #9
0
ファイル: intf.php プロジェクト: sdgdsffdsfff/hdf-client
    public function run($configs)
    {/*{{{*/
        $result = array();
        $result['errno'] = -1;
        $result['data'] = array();
        try
        {
            BeanFinder::register('configs', new Configuration($configs));
            $this->initDebug();
            Logger::setUp($configs['system']);
            BeanFinder::get('debug')->begin('service', $this->service.'::'.$this->do, true);

            //是否需要进程间同步
            $synchronized = isset($this->options['synchronized'])?$this->options['synchronized']:false;
            if ($synchronized)
            {
                $cacher= DAL::get()->getCache(Cacher::CACHETYPE_LOCKER);
                $lockUtil  = LockUtil::factory(LockUtil::LOCK_TYPE_MEMCACHE, array('memcache' => $cacher));
                $lockName = $this->service.$this->do;

                //client来决定同步标志,同一个方法,可以根据不用的标志来实施不同的锁
                //同一个service,synchronizedKey 不能重复
                $synchronizedKey = isset($this->options['synchronizedKey'])?$this->options['synchronizedKey']:false;
                if ($synchronizedKey)
                {
                    $lockName = $this->service.':'.$synchronizedKey;
                }
                $lockName = strtolower($lockName);
                $lockUtil->getLock($lockName, 10);
            }

            $uw = new UnitOfWork();
            $service = new $this->service;
            $service->initialize($this->options);
            $this->checkMethod($service);
            

            //error_log("files: ".print_r($_FILES, true), 3, '/tmp/a');
            //error_log("args: ".print_r($this->args, true), 3, '/tmp/a');
            //error_log("service: ".print_r($service, true), 3, '/tmp/a');
            //error_log("do: ".print_r($this->do, true), 3, '/tmp/a');
            //error_log("options: ".print_r($this->options, true), 3, '/tmp/a');
            $result['data'] = call_user_func_array(array($service, $this->do), $this->args);

            $uw->commit();

            BeanFinder::get('debug')->end();
            $result = $this->terminateDebug($result);

            $service->terminate();

            if ($synchronized && $lockUtil)
			    $lockUtil->releaseLock($lockName);

            $uw = $service = null;
            $this->checkOutput($result['data']);
            $result['errno'] = 0;
        }
        catch (LockException $e)
        {
            $result['errmsg']  = 'LockTimeOut';
            $result['exception'] = get_class($e);
            $result['ex'] = $e;
            //do some log here
            error_log(date('Y-m-d H:i:s')." ".print_r(unserialize(serialize($e)), true), 3, '/tmp/exception_sys.log');

            BeanFinder::get('debug')->addParams($e)->autoCloseNode();
            $result = $this->terminateDebug($result);
        }
        catch (BizException $e)
        {
            $result['errmsg']  = $e->getMessage();
            $result['exception'] = get_class($e);
            $result['ex'] = $e;
            //do some log here
            //error_log(print_r($e, true), 3, '/tmp/exception_biz.log');

            if ($synchronized && $lockUtil)
			    $lockUtil->releaseLock($lockName);

            BeanFinder::get('debug')->addParams($e)->autoCloseNode();
            $result = $this->terminateDebug($result);
        }
        catch (SystemException $e)
        {
            $result['errmsg']  = '系统错误';
            $result['exception'] = get_class($e);
            $result['ex'] = $e;
            //do some log here
            error_log(date('Y-m-d H:i:s')." ".print_r(unserialize(serialize($e)), true), 3, '/tmp/exception_sys.log');

            if ($synchronized && $lockUtil)
			    $lockUtil->releaseLock($lockName);

            BeanFinder::get('debug')->addParams($e)->autoCloseNode();
            $result = $this->terminateDebug($result);
        }
        catch (CustomException $e)
        {
            $result['errmsg']  = '系统错误';
            $result['exception'] = get_class($e);
            $result['ex'] = $e;
            //do some log here
            error_log(date('Y-m-d H:i:s')." ".print_r($e->errorMessage(), true), 3, '/tmp/exception_sys.log');

            if ($synchronized && $lockUtil)
			    $lockUtil->releaseLock($lockName);

            BeanFinder::get('debug')->addParams($e)->autoCloseNode();
            $result = $this->terminateDebug($result);
        }
        catch (Exception $e)
        {
            $result['errmsg']  = '系统错误';
            $result['exception'] = get_class($e);
            $result['ex'] = $e;
            //do some log here
            error_log(date('Y-m-d H:i:s')." ".print_r(unserialize(serialize($e)), true), 3, '/tmp/exception_sys.log');

            if ($synchronized && $lockUtil)
			    $lockUtil->releaseLock($lockName);

            BeanFinder::get('debug')->addParams($e)->autoCloseNode();
            $result = $this->terminateDebug($result);
        }
        return $this->prepareOutput($result);
    }/*}}}*/