Bug: catch excrption request to engine fail

CR: sonhh (fake)
This commit is contained in:
2021-08-26 16:51:36 +07:00
parent b207d54462
commit 14467d53b5
10 changed files with 124 additions and 79 deletions

View File

@@ -297,6 +297,38 @@ class ConfigController extends Controller {
public function actionReset() {
if (Yii::$app->request->post()) {
if (Yii::$app->request->post("deleteDB") === "true") {
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*"));
try {
file_get_contents("http://localhost:2305/update-feature");
} catch (\Exception $exc) {
}
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com";
if ($server_ip)
$ip = $server_ip->data;
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 0;
if ($device_id)
$id_camera = intval($device_id->data);
try {
file_get_contents($ip . "/api/model/reset_log_model", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"idCamera" => $id_camera,
"isCloud" => 0
])
]
]));
} catch (Exception $ex) {
}
}
if (Yii::$app->request->post("resetDevice") === "true") {
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
@@ -328,39 +360,8 @@ class ConfigController extends Controller {
]
]));
}
if (Yii::$app->request->post("deleteDB") === "true") {
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*"));
try {
file_get_contents("http://localhost:2305/update-feature");
} catch (\Exception $exc) {
}
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com";
if ($server_ip)
$ip = $server_ip->data;
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
$id_camera = 209;
if ($device_id)
$id_camera = intval($device_id->data);
try {
file_get_contents($ip . "/api/model/reset_log_model", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"idCamera" => $id_camera,
"isCloud" => 0
])
]
]));
} catch (Exception $ex) {
}
}
return Url::to(['/config']);
\app\models\SyncUrl::deleteAll(['IN', 'key_config', ['server_api', 'device_id']]);
return Url::to(['/config/cau-hinh-thiet-bi']);
} else {
Yii::$app->response->format = "json";
return [
@@ -434,7 +435,7 @@ class ConfigController extends Controller {
$model = new \app\models\SyncUrl();
$model->create([
'key_config' => 'device_id',
'data' => $engineConfig['data']['engines'][0]['id']
'data' => strval($engineConfig['data']['engines'][0]['id'])
]);
}
return $this->render('device', [