Commit a5640c98 authored by Medicean's avatar Medicean

(UE: Database) 优化检测和测试连接异常时提示

parent 74a67740
...@@ -52,7 +52,7 @@ class PHP extends Base { ...@@ -52,7 +52,7 @@ class PHP extends Base {
// 组合完整的代码 // 组合完整的代码
let tmpCode = data['_']; let tmpCode = data['_'];
data['_'] = `@ini_set("display_errors", "0");@set_time_limit(0);echo "${tag_s}";${tmpCode};echo "${tag_e}";die();`; data['_'] = `@ini_set("display_errors", "0");@set_time_limit(0);echo "${tag_s}";try{${tmpCode};}catch(Exception $e){echo "ERROR://".$e->getMessage();};echo "${tag_e}";die();`;
// 使用编码器进行处理并返回 // 使用编码器进行处理并返回
return this.encodeComplete(tag_s, tag_e, data); return this.encodeComplete(tag_s, tag_e, data);
......
...@@ -528,6 +528,7 @@ module.exports = { ...@@ -528,6 +528,7 @@ module.exports = {
}, },
probedb: { probedb: {
title: 'Detect database function support', title: 'Detect database function support',
success: 'Check completed',
coltype: 'ConnType', coltype: 'ConnType',
issupport: 'Support', issupport: 'Support',
} }
......
...@@ -529,6 +529,7 @@ module.exports = { ...@@ -529,6 +529,7 @@ module.exports = {
}, },
probedb: { probedb: {
title: '检测数据库函数支持', title: '检测数据库函数支持',
success: '检测完毕',
coltype: '连接类型', coltype: '连接类型',
issupport: '状态', issupport: '状态',
} }
......
...@@ -245,6 +245,9 @@ class ASP { ...@@ -245,6 +245,9 @@ class ASP {
}) })
).then((res) => { ).then((res) => {
if(res['text'].length > 0){ if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']); toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{ }else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']); toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
...@@ -360,6 +363,9 @@ class ASP { ...@@ -360,6 +363,9 @@ class ASP {
}) })
).then((res) => { ).then((res) => {
if(res['text'].length > 0){ if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']); toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{ }else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']); toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......
...@@ -241,6 +241,9 @@ class CUSTOM { ...@@ -241,6 +241,9 @@ class CUSTOM {
}) })
).then((res) => { ).then((res) => {
if(res['text'].length > 0){ if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']); toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{ }else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']); toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
...@@ -357,6 +360,9 @@ class CUSTOM { ...@@ -357,6 +360,9 @@ class CUSTOM {
}) })
).then((res) => { ).then((res) => {
if(res['text'].length > 0){ if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']); toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{ }else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']); toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// import AceEditor from 'react-ace'; // import AceEditor from 'react-ace';
const LANG = antSword['language']['database']; const LANG = antSword['language']['database'];
const LANG_T = antSword['language']['toastr'];
class Database { class Database {
...@@ -238,6 +239,9 @@ class Database { ...@@ -238,6 +239,9 @@ class Database {
that.drive.core.request( that.drive.core.request(
that.drive.core.base.probedb() that.drive.core.base.probedb()
).then((ret) => { ).then((ret) => {
if(ret['text'].indexOf("ERROR://") > -1){
throw res["text"];
}
let _data = ret['text'].split('\n'); let _data = ret['text'].split('\n');
let data_arr = []; let data_arr = [];
for (let i = 0; i < _data.length; i ++) { for (let i = 0; i < _data.length; i ++) {
...@@ -255,8 +259,10 @@ class Database { ...@@ -255,8 +259,10 @@ class Database {
grid.parse({ grid.parse({
'rows': data_arr 'rows': data_arr
}, 'json'); }, 'json');
toastr.success(LANG['probedb']['success'], LANG_T['success']);
win.progressOff(); win.progressOff();
}).catch((err)=>{ }).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff(); win.progressOff();
}); });
} }
......
...@@ -359,7 +359,7 @@ class PHP { ...@@ -359,7 +359,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] }, { type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => { { type: 'combo', label: '', name: 'encode', options: (() => {
let ret = []; let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => { ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({ ret.push({
text: _, text: _,
value: _, value: _,
...@@ -373,7 +373,7 @@ class PHP { ...@@ -373,7 +373,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] }, { type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => { { type: 'combo', label: '', name: 'encode', options: (() => {
let ret = []; let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => { ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({ ret.push({
text: _, text: _,
value: _, value: _,
...@@ -458,6 +458,9 @@ class PHP { ...@@ -458,6 +458,9 @@ class PHP {
}) })
).then((res) => { ).then((res) => {
if(res['text'].length > 0){ if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']); toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{ }else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']); toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
...@@ -555,7 +558,7 @@ class PHP { ...@@ -555,7 +558,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] }, { type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => { { type: 'combo', label: '', name: 'encode', options: (() => {
let ret = []; let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => { ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({ ret.push({
text: _, text: _,
value: _, value: _,
...@@ -569,7 +572,7 @@ class PHP { ...@@ -569,7 +572,7 @@ class PHP {
{ type: 'label', label: LANG['form']['encode'] }, { type: 'label', label: LANG['form']['encode'] },
{ type: 'combo', label: '', name: 'encode', options: (() => { { type: 'combo', label: '', name: 'encode', options: (() => {
let ret = []; let ret = [];
['gbk', 'gb2312', 'utf-8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr'].map((_) => { ['utf8', 'big5', 'dec8', 'cp850', 'hp8', 'koi8r', 'latin1', 'latin2', 'ascii', 'euckr', 'gb2312', 'gbk'].map((_) => {
ret.push({ ret.push({
text: _, text: _,
value: _, value: _,
...@@ -659,6 +662,9 @@ class PHP { ...@@ -659,6 +662,9 @@ class PHP {
}) })
).then((res) => { ).then((res) => {
if(res['text'].length > 0){ if(res['text'].length > 0){
if(res['text'].indexOf("ERROR://") > -1) {
throw res["text"];
}
toastr.success(LANG['form']['test_success'], LANG_T['success']); toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{ }else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']); toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment