alive 추가

git-svn-id: svn://192.168.0.12/source@159 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
admin
2015-07-08 08:11:03 +00:00
parent 3626f1ffa9
commit eb58276654
2 changed files with 15 additions and 14 deletions

View File

@@ -17,6 +17,7 @@
Widget::Widget(QWidget *parent) : QWidget(parent) , m_nMode(E_MODE_WAIT) Widget::Widget(QWidget *parent) : QWidget(parent) , m_nMode(E_MODE_WAIT)
{ {
connect(&m_timer, SIGNAL(timeout()), this, SLOT(Update())); connect(&m_timer, SIGNAL(timeout()), this, SLOT(Update()));
connect(&m_timerAlive, SIGNAL(timeout()), this, SLOT(Alive()));
QVBoxLayout *vlayout = new QVBoxLayout; QVBoxLayout *vlayout = new QVBoxLayout;
{ {
m_pResultList = new QListWidget; m_pResultList = new QListWidget;
@@ -39,8 +40,7 @@ Widget::Widget(QWidget *parent) : QWidget(parent) , m_nMode(E_MODE_WAIT)
m_db.setUserName("admin"); m_db.setUserName("admin");
m_db.setPassword("admin123"); m_db.setPassword("admin123");
m_db.setDatabaseName("concepters"); m_db.setDatabaseName("concepters");
m_db.setConnectOptions("CLIENT_INTERACTIVE=999999999;"); //m_db.setConnectOptions("MYSQL_OPT_RECONNECT=1");
m_db.setConnectOptions("MYSQL_OPT_RECONNECT=true;");
if (!m_db.open()) if (!m_db.open())
{ {
InsertLog("MySql Error..."); InsertLog("MySql Error...");
@@ -52,7 +52,8 @@ Widget::Widget(QWidget *parent) : QWidget(parent) , m_nMode(E_MODE_WAIT)
setWindowTitle("CrawlerList " + QString::number(QCoreApplication::applicationPid())); setWindowTitle("CrawlerList " + QString::number(QCoreApplication::applicationPid()));
RefreshButton(); RefreshButton();
m_timer.start(1000); m_timer.start(1000);
m_timerAlive.start(60*60000);
} }
Widget::~Widget() Widget::~Widget()
@@ -232,15 +233,6 @@ void Widget::StopButton()
void Widget::Update() void Widget::Update()
{ {
if (m_db.isOpen() == false)
{
if (m_db.open() == false)
{
InsertLog("MySql Open Error...");
InsertLog(m_db.lastError().text());
return;
}
}
switch(m_nMode) switch(m_nMode)
{ {
case E_MODE_WAIT: case E_MODE_WAIT:
@@ -254,9 +246,17 @@ void Widget::Update()
if(m_pManage[m_nPlatform]->Update()==true) if(m_pManage[m_nPlatform]->Update()==true)
m_nMode = E_MODE_WAIT; m_nMode = E_MODE_WAIT;
break; break;
} }
} }
void Widget::Alive()
{
QSqlQuery query;
query.exec("SELECT 1");
query.next();
}
void Widget::RefreshButton() void Widget::RefreshButton()
{ {
m_pcb->clear(); m_pcb->clear();

View File

@@ -40,7 +40,7 @@ public:
private: private:
QLineEdit *m_pedUntilPage; QLineEdit *m_pedUntilPage;
QTimer m_timer; QTimer m_timer,m_timerAlive;
QSqlDatabase m_db; QSqlDatabase m_db;
static const int C_PLATFORM_MAX = 4; static const int C_PLATFORM_MAX = 4;
SManage *m_pManage[C_PLATFORM_MAX]; SManage *m_pManage[C_PLATFORM_MAX];
@@ -66,6 +66,7 @@ private slots:
void StartButton(); void StartButton();
void StopButton(); void StopButton();
void Update(); void Update();
void Alive();
}; };
#endif // WIDGET_H #endif // WIDGET_H