/** * @inheritdoc */ protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused) { $dirNameBase = $dirName; foreach ($messages as $category => $msgs) { /** * Fix Directory */ $module = $this->getModuleByCategory($category); if ($module !== null) { // Use Module Directory $dirName = str_replace(Yii::getAlias("@humhub/messages"), $module->getBasePath() . '/messages', $dirNameBase); preg_match('/.*?Module\\.(.*)/', $category, $result); $category = $result[1]; } else { // Use Standard HumHub Directory $dirName = $dirNameBase; } $file = str_replace("\\", '/', "{$dirName}/{$category}.php"); $path = dirname($file); FileHelper::createDirectory($path); $msgs = array_values(array_unique($msgs)); $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]); $this->stdout("Saving messages to {$coloredFileName}...\n"); $this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused); } }
public function startHead($controller, $headType, $headId, $restarting) { if (!$restarting) { // Console::output(Console::ansiFormat('Starting ' . $headId, [Console::FG_CYAN])); } else { // Console::output(Console::ansiFormat('Restarting ' . $headId, [Console::FG_CYAN])); } $_this = $this; $process = new \React\ChildProcess\Process($this->getSubCommand($controller, [$headType, $headId])); $process->on('exit', function ($exitCode, $termSignal) use(&$_this, &$controller, $headType, $headId) { if ($exitCode !== 0) { Console::stderr(Console::ansiFormat("Broadcast head {$headType}:{$headId} exited with error code {$exitCode}", [Console::FG_RED])); sleep(10); } if (static::isPaused()) { Yii::$app->end(0); } $_this->_heads[$headId] = $_this->startHead($controller, $headType, $headId, true); }); $this->loop->addTimer(0.0001, function ($timer) use($process, &$_this) { $process->start($timer->getLoop()); $process->stdout->on('data', function ($output) use($_this) { $stdout = fopen('php://stdout', 'w+'); fwrite($stdout, $output); }); $process->stderr->on('data', function ($output) use($_this) { $stderr = fopen('php://stderr', 'w+'); fwrite($stderr, $output); }); }); sleep(5); return $process; }
public function actionIndex() { $this->stdout('Description goes here.' . PHP_EOL); $helpCommand = Console::ansiFormat("yii help dota2api/economy", [Console::FG_CYAN]); $this->stdout("Use {$helpCommand} to get usage info." . PHP_EOL); return self::EXIT_CODE_NORMAL; }
/** * Prints a string to STDERR. * * @param string $string the string to print * @return int|boolean Number of bytes printed or false on error */ public static function stderr($string) { $args = func_get_args(); array_shift($args); $string = parent::ansiFormat($string, $args) . "\n"; return parent::stderr($string); }
protected function stderr($string) { if (Console::streamSupportsAnsiColors(\STDOUT)) { $string = Console::ansiFormat(" Error: " . $string, [Console::FG_RED]); } return fwrite(\STDERR, $string); }
/** * Show errors * @param array $errors array of errors string * @throws yii\base\ExitException */ protected function showErrors($errors) { foreach ((array) $errors as $err) { Console::error(Console::ansiFormat(Yii::t('activeuser_backend', "Error") . ": ", [Console::FG_RED]) . $err[0]); } yii::$app->end(); }
/** * message * * @param string $string * @access private * @return integer|null */ private function message($string) { if (!empty($string) && !$this->quiet) { $args = func_get_args(); array_shift($args); $string = Console::ansiFormat($string, $args); return Console::stdout($string); } }
/** * Prints a string to STDERR. * * @param string $string the string to print * @return int|boolean Number of bytes printed or false on error */ public function stderr($string) { if ($this->isColorEnabled(\STDERR)) { $args = func_get_args(); array_shift($args); $string = Console::ansiFormat($string, $args) . "\n"; } return Console::stderr($string); }
/** * Colorizes a message for console output. * @param string $message the message to colorize. * @param array $format the message format. * @return string the colorized message. * @see Console::ansiFormat() for details on how to specify the message format. */ protected function formatMessage($message, $format = [Console::FG_RED, Console::BOLD]) { $stream = PHP_SAPI === 'cli' ? \STDERR : \STDOUT; // try controller first to allow check for --color switch if (Yii::$app->controller instanceof \yii\console\Controller && Yii::$app->controller->isColorEnabled($stream) || Yii::$app instanceof \yii\console\Application && Console::streamSupportsAnsiColors($stream)) { $message = Console::ansiFormat($message, $format); } return $message; }
public function stdout($string) { if (Console::streamSupportsAnsiColors(STDOUT)) { $args = func_get_args(); array_shift($args); $string = Console::ansiFormat($string, $args); } return Console::stdout($string); }
/** * Initializing $_languageElements array. * @param array $languageSourceIds */ private function _initLanguageElements($languageSourceIds) { $languageSources = LanguageSource::findAll(['id' => $languageSourceIds]); foreach ($languageSources as $languageSource) { $this->_languageElements[$languageSource->category][$languageSource->message] = $languageSource->id; $category = Console::ansiFormat($languageSource->category, [Console::FG_RED]); $message = Console::ansiFormat($languageSource->message, [Console::FG_RED]); $this->_scanner->stdout('category: ' . $category . ', message: ' . $message); } }
/** * Helper method for writting console application output, include before and after wrappers. * * @param string $message The message which is displayed * @param string $color A color from \yii\helpers\Console::FG_GREEN; * @param return void */ protected function output($message, $color = null) { $format = []; if (!$this->isMuted()) { if ($color !== null) { $format[] = $color; } echo Console::ansiFormat("\r" . $message . "\n", $format); } }
/** * * @param string $string * @return string */ public function output($string) { if ($this->isColorEnabled()) { $args = func_get_args(); array_shift($args); $string = Console::ansiFormat($string, $args); } $b = Console::stdout($string); echo PHP_EOL; return $b; }
public static function write($path, $content) { if (file_exists($path)) { $old = file_get_contents($path); if ($old === $content) { return; } } file_put_contents($path, $content); Console::stdout(Console::ansiFormat("written file: {$path}\n", [Console::FG_YELLOW])); }
/** * Logs a message to console and then to yii\log\Logger. */ public function log($message, $level, $category = 'application') { if ($level <= $this->getSpamLevel()) { $style = self::$styles[$level]; if ($style) { $message = Console::ansiFormat($message, $style); } Console::stdout($message . "\n"); } parent::log($message, $level, $category); }
/** * 用户创建交互 * @param $_model * @return mixed */ private function saveFounderData($_model) { $model = clone $_model; $model->username = Console::prompt('请输入创始人用户名', ['default' => 'admin']); $model->email = Console::prompt('请输入创始人邮箱', ['default' => '*****@*****.**']); $model->password = Console::prompt('请输入创始人密码', ['default' => 'admin']); if (!($user = $model->signup())) { Console::output(Console::ansiFormat("\n输入数据验证错误:", [Console::FG_RED])); foreach ($model->getErrors() as $k => $v) { Console::output(Console::ansiFormat(implode("\n", $v), [Console::FG_RED])); } if (Console::confirm("\n是否重新创建创始人账户:")) { $user = $this->saveFounderData($_model); } } return $user; }
/** * @inheritdoc */ public function export() { foreach ($this->messages as $message) { $string = $this->formatMessage($message) . "\n"; $level = $message[1]; if ($this->stderrIsNotStdout && in_array($level, $this->stderrLevels)) { if ($this->stderrSupportsColors) { Console::stderr(Console::ansiFormat($string, $this->colorMap[$level])); } else { Console::stderr($string); } } if ($this->stdoutSupportsColors) { Console::stdout(Console::ansiFormat($string, $this->colorMap[$level])); } else { Console::stdout($string); } } }
public function actionIndex() { $default_values = [['title_prefix', '', 'Название сайта(префикс)'], ['title_postfix', 'Название сайта', 'Название сайта(постфикс)'], ['uploads_path', 'uploads', 'Корневая директория для загрузки файлов'], ['thumbs_path', 'thumbs', 'Папка для превьюшек']]; echo 'Установить все параметры по умолчанию? ' . Console::ansiFormat('[Y/n]:', [Console::FG_YELLOW]); $input = strtolower(readline()); switch ($input) { case 'y': echo Console::ansiFormat('удаляем таблицу с настройками...', [Console::FG_BLUE, Console::CROSSED_OUT]) . PHP_EOL; \Yii::$app->db->createCommand('TRUNCATE TABLE key_value')->execute(); foreach ($default_values as $item) { $obj = new Keyvalue(); $obj->key = $item[0]; $obj->value = $item[1]; $obj->name = $item[2]; $obj->save(); } echo Console::ansiFormat('успешно вернулись в каменный век!', [Console::FG_GREEN]) . PHP_EOL; break; } }
/** * Устанавливает коды стран отправителей исходя из IP адресов * @throws \Exception */ function actionIndex() { if (!extension_loaded('geoip')) { throw new \Exception(Console::ansiFormat('Расширение GeoIP недоступно')); } $comments = Comments::find()->where(['country_code' => null])->all(); $geoip = new GeoIP(); foreach ($comments as $item) { if (!$item->country_code) { $ip = long2ip($item->ip); try { $geoip->setHost($ip); $code = $geoip->getCountryCode(); $item->country_code = $code; $item->save(); echo Console::ansiFormat($item->id . ': ' . $ip . ' - ' . $code, [Console::FG_GREEN]) . PHP_EOL; } catch (\Exception $e) { echo Console::ansiFormat($item->id . ': ' . $ip . ' - ' . 'host не обнаружен!', [Console::FG_RED]) . PHP_EOL; } } } }
/** * Исполнение всех необходимых тасков */ public function run() { if (file_exists($this->lockFile)) { echo Console::ansiFormat("Previous cron doesn't complete\n", [Console::FG_RED]); if (time() - filemtime($this->lockFile) > $this->maxTime) { unlink($this->lockFile); } return false; } echo Console::ansiFormat("Cron started\n", [Console::FG_GREEN]); file_put_contents($this->lockFile, time()); $currentTime = time(); $currentTimeParts = array('minute' => intval(date('i', $currentTime)), 'hour' => intval(date('G', $currentTime)), 'dayOfMonth' => intval(date('j', $currentTime)), 'month' => intval(date('n', $currentTime)), 'dayOfWeek' => intval(date('w', $currentTime))); foreach ($this->tasks as $task) { if ($task->needRun($currentTimeParts)) { echo Console::ansiFormat(sprintf("Task '%s' start running\n", $task->name), [Console::FG_GREEN]); shell_exec(PHP_BINDIR . '/php ' . \Yii::getAlias('@console/../yii') . ' ' . $task->command); } } echo Console::ansiFormat("Cron completed\n", [Console::FG_GREEN]); unlink($this->lockFile); return true; }
/** * 낙찰검색 */ public function kepco_suc_search($job) { echo $job->workload(), PHP_EOL; $workload = Json::decode($job->workload()); $httpClient = new \GuzzleHttp\Client(['base_uri' => 'http://203.248.44.161', 'cookies' => true, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', 'Content-Type' => 'application/json', 'X-Requested-With' => 'XMLHttpRequest', 'Accept-Language' => 'ko', 'Accept-Encoding' => 'gzip, deflate', 'DNT' => '1', 'Pragma' => 'no-cache', 'Connection' => 'Keep-Alive', 'Accept' => '*/*', 'Referer' => 'http://203.248.44.161/mdi.do?theme=default', 'X-CSRF-TOKEN' => $this->csrf_token, 'Cookie' => $this->cookie]]); if (!empty($workload['recently'])) { $fromNoticeDate = date('Y-m-d', strtotime($workload['recently'])); $toNoticeDate = date('Y-m-d'); } else { $fromNoticeDate = $workload['fromNoticeDate']; $toNoticeDate = $workload['toNoticeDate']; } $limit = 100; $response = $httpClient->request('POST', '/router', ['json' => ['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.OpenInfoDataListController', 'method' => 'findOpenInfoDataBidList', 'tid' => 16, 'type' => 'rpc', 'data' => [['companyId' => 'ALL', 'fromNoticeDate' => $fromNoticeDate . 'T00:00:00', 'toNoticeDate' => $toNoticeDate . 'T23:59:59', 'limit' => $limit, 'page' => 1, 'start' => 0]]]]); $body = $response->getBody(); $json = Json::decode($body); $total = $json[0]['result']['total']; echo Console::ansiFormat('[검색건수] : ' . $total, [Console::FG_YELLOW]), PHP_EOL; $rows = $json[0]['result']['records']; foreach ($rows as $row) { sleep(1); echo ' - ' . $row['id'] . '/' . $row['bidResultStateInOpenInfoData'] . '/' . $row['purchaseType'] . '/' . $row['no'] . '/' . $row['revision'] . '/' . $row['bidRevision'] . '/' . $row['name'] . '/', PHP_EOL; } $lastPage = ceil($total / $limit); for ($page = 2; $page <= $lastPage; $page++) { $start = $limit * $page - $limit; $response = $httpClient->request('POST', '/router', ['json' => ['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.OpenInfoDataListController', 'method' => 'findOpenInfoDataBidList', 'tid' => 16, 'type' => 'rpc', 'data' => [['companyId' => 'ALL', 'fromNoticeDate' => $fromNoticeDate . 'T00:00:00', 'toNoticeDate' => $toNoticeDate . 'T23:59:59', 'limit' => $limit, 'page' => $page, 'start' => $start]]]]); $body = $response->getBody(); $json = Json::decode($body); $rows = $json[0]['result']['records']; echo ' > page : ' . $page . ' / ' . $lastPage, PHP_EOL; foreach ($rows as $row) { sleep(1); echo ' - ' . $row['id'] . '/' . $row['bidResultStateInOpenInfoData'] . '/' . $row['purchaseType'] . '/' . $row['no'] . '/' . $row['revision'] . '/' . $row['bidRevision'] . '/' . $row['name'] . '/', PHP_EOL; } } }
public function callback(AMQPMessage $msg) { $routingKey = $msg->delivery_info['routing_key']; $method = 'read' . Inflector::camelize($routingKey); if (!isset($this->interpreters[$this->queue])) { $interpreter = $this; } elseif (class_exists($this->interpreters[$this->queue])) { $interpreter = new $this->interpreters[$this->queue](); if (!$interpreter instanceof AmqpInterpreter) { throw new Exception(sprintf("Class '%s' is not correct interpreter class.", $this->interpreters[$this->queue])); } } else { throw new Exception(sprintf("Interpreter class '%s' was not found.", $this->interpreters[$this->queue])); } if (method_exists($interpreter, $method)) { $info = ['exchange' => $msg->get('exchange'), 'queue' => $this->queue, 'routing_key' => $msg->get('routing_key'), 'reply_to' => $msg->has('reply_to') ? $msg->get('reply_to') : null]; try { $interpreter->{$method}(Json::decode($msg->body, true), $info); } catch (\Exception $exc) { $error_info = "consumer fail:" . $exc->getMessage() . PHP_EOL . "info:" . print_r($info, true) . PHP_EOL . "body:" . PHP_EOL . print_r($msg->body, true) . PHP_EOL . $exc->getTraceAsString(); \Yii::warning($error_info, __METHOD__); $format = [Console::FG_RED]; Console::stdout(Console::ansiFormat($error_info . PHP_EOL, $format)); Console::stdout(Console::ansiFormat($exc->getTraceAsString() . PHP_EOL, $format)); } } else { if (!isset($this->interpreters[$this->queue])) { $interpreter = new AmqpInterpreter(); } $error_info = "Unknown routing key '{$routingKey}' for exchange '{$this->queue}'."; $error_info .= PHP_EOL . $msg->body; \Yii::warning($error_info, __METHOD__); $interpreter->log(sprintf("Unknown routing key '%s' for exchange '%s'.", $routingKey, $this->queue), $interpreter::MESSAGE_ERROR); // debug the message $interpreter->log(print_r(Json::decode($msg->body, true), true), $interpreter::MESSAGE_INFO); } }
public function export() { foreach ($this->messages as $message) { $string = $this->formatMessage($message) . "\n"; $level = $message[1]; if ($level == Logger::LEVEL_INFO) { if (strncmp('BEGIN ', $message[0], 6) == 0) { $ansiColor = $this->_levelAnsiColorMap[Logger::LEVEL_PROFILE_BEGIN]; } elseif (strncmp('END ', $message[0], 4) == 0) { $ansiColor = $this->_levelAnsiColorMap[Logger::LEVEL_PROFILE_END]; } else { $ansiColor = $this->_levelAnsiColorMap[Logger::LEVEL_INFO]; } } elseif (array_key_exists($level, $this->_levelAnsiColorMap)) { $ansiColor = $this->_levelAnsiColorMap[$level]; } else { $ansiColor = $this->defaultAnsiColor; } if ($this->_stdoutIsTerminal) { if ($this->_stdoutSupportsAnsiColors && $ansiColor) { Console::stdout(Console::ansiFormat($string, $ansiColor)); } else { Console::stdout($string); } } else { Console::stdout($string); if ($this->_stderrIsTerminal && ($level == Logger::LEVEL_ERROR || $level == Logger::LEVEL_WARNING)) { if ($this->_stderrSupportsAnsiColors && $ansiColor) { Console::stderr(Console::ansiFormat($string, $ansiColor)); } else { Console::stderr($string); } } } } }
/** * Writes messages into PHP files * * @param array $messages * @param string $dirName name of the directory to write to * @param boolean $overwrite if existing file should be overwritten without backup * @param boolean $removeUnused if obsolete translations should be removed * @param boolean $sort if translations should be sorted */ protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort) { foreach ($messages as $category => $msgs) { $file = str_replace("\\", '/', "{$dirName}/{$category}.php"); $path = dirname($file); FileHelper::createDirectory($path); $msgs = array_values(array_unique($msgs)); $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]); $this->stdout("Saving messages to {$coloredFileName}...\n"); $this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category); } }
/** * Loads the specified fixture data. * For example, * * ``` * # load the fixture data specified by User and UserProfile. * # any existing fixture data will be removed first * yii fixture/load User UserProfile * * # load all available fixtures found under 'tests\unit\fixtures' * yii fixture/load "*" * * # load all fixtures except User and UserProfile * yii fixture/load "*" -User -UserProfile * ``` * * @throws Exception if the specified fixture does not exist. */ public function actionLoad() { $fixturesInput = func_get_args(); if ($fixturesInput === []) { $this->stdout($this->getHelpSummary() . "\n"); $helpCommand = Console::ansiFormat('yii help fixture', [Console::FG_CYAN]); $this->stdout("Use {$helpCommand} to get usage info.\n"); return self::EXIT_CODE_NORMAL; } $filtered = $this->filterFixtures($fixturesInput); $except = $filtered['except']; if (!$this->needToApplyAll($fixturesInput[0])) { $fixtures = $filtered['apply']; $foundFixtures = $this->findFixtures($fixtures); $notFoundFixtures = array_diff($fixtures, $foundFixtures); if ($notFoundFixtures) { $this->notifyNotFound($notFoundFixtures); } } else { $foundFixtures = $this->findFixtures(); } $fixturesToLoad = array_diff($foundFixtures, $except); if (!$foundFixtures) { throw new Exception("No files were found by name: \"" . implode(', ', $fixturesInput) . "\".\n" . "Check that files with these name exists, under fixtures path: \n\"" . $this->getFixturePath() . "\"."); } if (!$fixturesToLoad) { $this->notifyNothingToLoad($foundFixtures, $except); return static::EXIT_CODE_NORMAL; } if (!$this->confirmLoad($fixturesToLoad, $except)) { return static::EXIT_CODE_NORMAL; } $fixtures = $this->getFixturesConfig(array_merge($this->globalFixtures, $fixturesToLoad)); if (!$fixtures) { throw new Exception('No fixtures were found in namespace: "' . $this->namespace . '"' . ''); } $fixturesObjects = $this->createFixtures($fixtures); $this->unloadFixtures($fixturesObjects); $this->loadFixtures($fixturesObjects); $this->notifyLoaded($fixtures); return static::EXIT_CODE_NORMAL; }
/** * Show message in console * * @param $message */ private function writeConsole($message) { $out = Console::ansiFormat('[' . date('d.m.Y H:i:s') . '] ', [Console::BOLD]); $this->stdout($out . $message . "\n"); }
public function i2conv_run($job) { $workload = $job->workload(); $workload = Json::decode($workload); try { $this->module->i2db->close(); $this->module->infodb->close(); $bidKey = BidKey::findOne($workload['bidid']); if ($bidKey === null) { return; } $bidvalue = $bidKey->bidValue; if ($bidvalue === null) { return; } if (!ArrayHelper::isIn($bidKey->state, ['Y', 'N', 'D'])) { return; } if ($bidKey->bidproc === 'J') { return; } if (empty($bidKey->location)) { return; } switch ($bidKey->bidtype) { case 'con': echo Console::renderColoredString('%y[공사]%n'); break; case 'ser': echo Console::renderColoredString('%g[용역]%n'); break; case 'pur': echo Console::renderColoredString('%b[구매]%n'); break; default: return; } echo $bidKey->constnm; echo '[' . $bidKey->notinum . ']'; echo '(' . $bidKey->state . ',' . $bidKey->bidproc . ')'; //------------------------------------------------------ // v3_bid_key //------------------------------------------------------ $v3bidkey = V3BidKey::findNew($bidKey->bidid); $this->stdout($v3bidkey->isNewRecord ? "[NEW]\n" : "\n", Console::FG_RED); $v3bidkey->attributes = ['whereis' => $bidKey->whereis, 'bidtype' => $bidKey->bidtype, 'con' => strpos($bidKey->bidview, 'con') === false ? 'N' : 'Y', 'ser' => strpos($bidKey->bidview, 'ser') === false ? 'N' : 'Y', 'pur' => strpos($bidKey->bidview, 'pur') === false ? 'N' : 'Y', 'notinum' => $bidKey->notinum, 'orgcode' => $bidKey->orgcode_i, 'constnm' => $bidKey->constnm, 'org' => $bidKey->org_i, 'bidproc' => $bidKey->bidproc, 'contract' => $bidKey->contract, 'bidcls' => $bidKey->bidcls, 'succls' => $bidKey->succls, 'conlevel' => $bidKey->toV3BidKey_conlevel(), 'ulevel' => $bidKey->opt, 'concode' => $bidKey->toV3BidKey_concode(), 'sercode' => $bidKey->toV3BidKey_sercode(), 'purcode' => $bidKey->toV3BidKey_purcode(), 'location' => $bidKey->location ? $bidKey->location : 0, 'convention' => $bidKey->convention == '3' ? '2' : $bidKey->convention, 'presum' => $bidKey->presum ? $bidKey->presum : 0, 'basic' => $bidKey->basic ? $bidKey->basic : 0, 'pct' => $bidKey->pct ? $bidKey->pct : '', 'registdate' => strtotime($bidKey->registdt) > 0 ? date('Y-m-d', strtotime($bidKey->registdt)) : '', 'explaindate' => strtotime($bidKey->explaindt) > 0 ? date('Y-m-d', strtotime($bidKey->explaindt)) : '', 'agreedate' => strtotime($bidKey->agreedt) > 0 ? date('Y-m-d', strtotime($bidKey->agreedt)) : '', 'opendate' => strtotime($bidKey->opendt) > 0 ? date('Y-m-d', strtotime($bidKey->opendt)) : '', 'closedate' => strtotime($bidKey->closedt) > 0 ? date('Y-m-d', strtotime($bidKey->closedt)) : '', 'constdate' => strtotime($bidKey->constdt) > 0 ? date('Y-m-d', strtotime($bidKey->constdt)) : '', 'writedate' => strtotime($bidKey->writedt) > 0 ? date('Y-m-d', strtotime($bidKey->writedt)) : '', 'reswdate' => strtotime($bidKey->resdt) > 0 ? date('Y-m-d', strtotime($bidKey->resdt)) : '', 'state' => $bidKey->state, 'in_id' => 91]; //------------------------------------------------------ // v3_bid_value //------------------------------------------------------ $v3BidValue = V3BidValue::findNew($v3bidkey->bidid); $v3BidValue->attributes = ['scrcls' => $bidvalue->scrcls, 'scrid' => $bidvalue->scrid, 'constno' => $bidvalue->constno, 'refno' => $bidvalue->refno, 'realorg' => $bidvalue->realorg, 'yegatype' => $bidvalue->yegatype, 'yegarng' => str_replace('|', '/', $bidvalue->yegarng), 'prevamt' => $bidvalue->prevamt, 'parbasic' => $bidvalue->parbasic, 'lvcnt' => $bidvalue->lvcnt, 'charger' => str_replace('|', '/', $bidvalue->charger), 'multispare' => str_replace('|', '/', str_replace(',', '', $bidvalue->multispare)), 'contper' => $bidvalue->contper, 'noticedt' => strtotime($bidKey->noticedt) > 0 ? strtotime($bidKey->noticedt) : 0, 'registdt' => strtotime($bidKey->registdt) > 0 ? strtotime($bidKey->registdt) : 0, 'explaindt' => strtotime($bidKey->explaindt) > 0 ? strtotime($bidKey->explaindt) : 0, 'agreedt' => strtotime($bidKey->agreedt) > 0 ? strtotime($bidKey->agreedt) : 0, 'opendt' => strtotime($bidKey->opendt) > 0 ? strtotime($bidKey->opendt) : 0, 'closedt' => strtotime($bidKey->closedt) > 0 ? strtotime($bidKey->closedt) : 0, 'constdt' => strtotime($bidKey->constdt) > 0 ? strtotime($bidKey->constdt) : 0, 'writedt' => strtotime($bidKey->writedt) > 0 ? strtotime($bidKey->writedt) : 0, 'editdt' => strtotime($bidKey->editdt) > 0 ? strtotime($bidKey->editdt) : 0]; //공동도급지역코드 (사용하나??) $arr = explode('|', $bidvalue->contloc); foreach ($arr as $val) { if (empty($val)) { continue; } $m = BidLocal::findOne(['bidid' => $v3bidkey->bidid, 'name' => iconv('utf-8', 'euckr', $val)]); if ($m !== null) { $v3BidValue->contloc = $m->code; break; //v3_bid_key.contloc char(4) 때문 1개 지역만 처리... } } //------------------------------------------------------ // v3_bid_itemcode //------------------------------------------------------ V3BidItemcode::deleteAll(['bidid' => $v3bidkey->bidid]); $bidItemcodes = $bidKey->toV3BidItemcodes_attributes(); foreach ($bidItemcodes as $row) { $v3BidItemcode = V3BidItemcode::findNew($v3bidkey->bidid, $row['bidtype'], $row['code']); $v3BidItemcode->name = $row['name']; $v3BidItemcode->save(); } //------------------------------------------------------ // v3_bid_local //------------------------------------------------------ V3BidLocal::deleteAll(['bidid' => $v3bidkey->bidid]); $bidlocals = $bidKey->bidLocals; foreach ($bidlocals as $bidlocal) { $v3BidLocal = new V3BidLocal(['bidid' => $v3bidkey->bidid, 'code' => $bidLocal->code, 'name' => $bidLocal->name]); $v3BidLocal->save(); } //------------------------------------------------------ // v3_bid_subcode //------------------------------------------------------ V3BidSubcode::deleteAll(['bidid' => $v3bidkey->bidid]); $subcodes = $bidKey->bidSubcodes; foreach ($subcodes as $subcode) { $v3BidSubcode = new V3BidSubcode(['bidid' => $v3bidkey->bidid, 'g2b_code' => $subcode->g2b_code, 'g2b_code_nm' => $subcode->g2b_code_nm, 'i2_code' => $subcode->i2_code, 'itemcode' => $subcode->itemcode, 'pri_cont' => $subcode->pri_cont, 'share' => $subcode->share]); $v3BidSubcode->save(); } //------------------------------------------------------- // v3_bid_content //------------------------------------------------------- $bidcontent = $bidKey->bidContent; if ($bidcontent !== null) { $v3content = V3BidContent::findNew($v3bidkey->bidid); $v3content->attributes = ['content_bid' => $bidcontent->bid_html, 'important_suc' => $bidcontent->nbidcomment, 'content_suc' => $bidcontent->nbid_html, 'upfile_bid' => $bidcontent->bid_file, 'upfile_suc' => $bidcontent->nbid_file, 'important_bid' => !empty($bidcontent->bidcomment_mod) ? $bidcontent->bidcomment_mod . '\\n<hr/>\\n' . $bidcontent->bidcomment : $bidcontent->bidcomment]; $v3content->save(); $v3BidValue->origin_lnk = $bidcontent->orign_lnk; $v3BidValue->attchd_lnk = $bidcontent->attchd_lnk; } //----------------------------------------------------- // v3_bid_goods //----------------------------------------------------- $bidGoods = $bidKey->bidGoods; V3BidGoods::deleteAll(['bidid' => $v3bidkey->bidid]); foreach ($bidGoods as $g) { $v3BidGood = new V3BidGoods(); $v3BidGood->attributes = $g->attributes; $v3BidGood->save(); } //------------------------------------------------------- // v3_bid_res,v3_bid_succom //------------------------------------------------------- $bidRes = $bidKey->bidRes; if (ArrayHelper::isIn($bidKey->bidproc, ['S', 'F']) && $bidRes !== null) { $v3BidResult = V3BidResult::findNew($v3bidkey->bidid); $v3BidResult->attributes = ['yega' => $bidRes->yega, 'innum' => $bidRes->innum, 'officenm1' => $bidRes->officenm1, 'prenm1' => $bidRes->prenm1, 'officeno1' => $bidRes->officeno1, 'success1' => $bidRes->success1, 'resdt' => strtotime($bidKey->resdt) > 0 ? strtotime($bidKey->resdt) : 0, 'reswdt' => strtotime($bidRes->reswdt) > 0 ? strtotime($bidRes->reswdt) : 0]; $arr = explode('|', $bidRes->selms); $selms = []; foreach ($arr as $v) { if ($v == '') { continue; } $selms[] = intval($v) - 1; } $v3BidResult->selms = implode('-', $selms); $v3BidResult->save(); if ($bidKey->whereis != '08' && $bidKey->bidproc != 'F') { $v3BidValue->multispare = str_replace('|', '/', str_replace(',', '', $bidRes->multispare)); } $v3BidValue->save(); if ($bidRes->innum > 0) { $succoms = $bidKey->succoms; if (count($succoms) == $bidRes->innum) { V3BidSuccom::deleteAll(['constdate' => $v3bidkey->constdate, 'bidid' => $v3bidkey->bidid]); Console::startProgress(0, $bidRes->innum); $n = 1; foreach ($succoms as $s) { $v3succom = V3BidSuccom::findNew($v3bidkey->constdate, $v3bidkey->bidid, $s->seq); $v3succom = new V3BidSuccom(['constdate' => $v3bidkey->constdate, 'bidid' => $v3bidkey->bidid, 'seq' => $s->seq, 'regdt' => strtotime($s->regdt) > 0 ? strtotime($s->regdt) : 0, 'pct' => $s->pct, 'prenm' => $s->prenm == null ? '' : $s->prenm, 'officenm' => $s->officenm, 'officeno' => $s->officeno, 'success' => $s->success, 'etc' => $s->etc, 'rank' => $s->rank]); $v3succom->save(); Console::updateProgress($n, $bidRes->innum); $n++; } Console::endProgress(); } } } $v3BidValue->save(); $v3bidkey->save(); $gman_client = new GearmanClient(); $gman_client->addServers($this->module->gman_server); $gman_client->doBackground('i2conv_legacy', Json::encode($workload)); } catch (\Exception $e) { echo Console::ansiFormat($e, [Console::FG_RED]), PHP_EOL; Yii::error($e, 'i2conv'); $gman_client = new GearmanClient(); $gman_client->addServers('192.168.1.242'); $gman_client->doBackground('send_chat_message_from_admin', Json::encode(['recv_id' => 149, 'message' => iconv('cp949', 'utf-8', $e) . "\n[i2conv]"])); } $this->stdout(sprintf("[%s] Peak memory usage: %s MB\n", date('Y-m-d H:i:s'), memory_get_peak_usage(true) / 1024 / 1024), Console::FG_GREY); }
public static function hint($msg) { $msg = Console::ansiFormat($msg, [Console::FG_BLUE, Console::BOLD]); Console::output($msg); }
/** * @param \Exception $e */ public function errorTrace(\Exception $e) { echo "\n" . Console::ansiFormat('Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ')', [Console::BG_RED, Console::FG_BLACK]) . "\n"; }
/** * @return string */ protected function getPrompt() : string { $prompt = $this->_options['prompt']; $route = $this->context->getAsString(); if ($route) { $prompt .= ' ' . $this->context->getAsString(); } return Console::ansiFormat($prompt . ': ', $this->_options['style.prompt']); }