471 |
AppendText(tekst); |
AppendText(tekst); |
472 |
} |
} |
473 |
} |
} |
474 |
|
Sleep(10); //Small delay to avoid busy wait |
475 |
} |
} |
476 |
Sleep(100); //Give the modem a chance to send the last data |
Sleep(100); //Give the modem a chance to send the last data |
477 |
while(Serial.getComstat().cbInQue > 0) |
while(Serial.getComstat().cbInQue > 0) |
741 |
CString SQL, Textwindow; |
CString SQL, Textwindow; |
742 |
SQL.Format("update command set executed=now() where id=%s",IDnr); |
SQL.Format("update command set executed=now() where id=%s",IDnr); |
743 |
db.ExecuteSQL(SQL); |
db.ExecuteSQL(SQL); |
744 |
|
Sleep(10); |
745 |
AppendText("Command executed"); |
AppendText("Command executed"); |
746 |
} |
} |
747 |
Sleep(150); |
Sleep(150); |
925 |
CString SQL, name, value; |
CString SQL, name, value; |
926 |
SQL = "select name, value from config;"; |
SQL = "select name, value from config;"; |
927 |
CRecordset rs(&db); |
CRecordset rs(&db); |
928 |
rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); |
try |
|
if (rs.GetRecordCount()>0) |
|
929 |
{ |
{ |
930 |
rs.MoveFirst(); |
rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); |
931 |
|
if (rs.GetRecordCount()>0) |
932 |
|
{ |
933 |
|
rs.MoveFirst(); |
934 |
|
|
935 |
rs.GetFieldValue((short)0, name); |
rs.GetFieldValue((short)0, name); |
936 |
rs.GetFieldValue(1,value); |
rs.GetFieldValue(1,value); |
937 |
|
|
938 |
Alive.name = name; |
Alive.name = name; |
939 |
Alive.value = value; |
Alive.value = value; |
940 |
Alive.tid = CTime::GetCurrentTime(); |
Alive.tid = CTime::GetCurrentTime(); |
941 |
if(Alive.name == "phonenr") |
if(Alive.name == "phonenr") |
942 |
{ |
{ |
943 |
Alive.Phonenr = value; |
Alive.Phonenr = value; |
944 |
} |
} |
945 |
|
|
946 |
buffer.push_back(Alive); |
buffer.push_back(Alive); |
947 |
rs.MoveNext(); |
rs.MoveNext(); |
948 |
|
|
949 |
|
} |
950 |
|
rs.Close(); |
951 |
|
return buffer; |
952 |
} |
} |
953 |
rs.Close(); |
catch (char * str) |
954 |
return buffer; |
{ |
955 |
|
AppendText("Keepalive failed, closing and opening the db connection again"); |
956 |
|
if(db.IsOpen()) |
957 |
|
{ |
958 |
|
db.Close(); |
959 |
|
AppendText("DB connection closed"); |
960 |
|
} |
961 |
|
if(!db.IsOpen()) |
962 |
|
{ |
963 |
|
DBConnect(); |
964 |
|
AppendText("DB connection started again"); |
965 |
|
} |
966 |
|
} |
967 |
|
|
968 |
|
|
969 |
} |
} |