471 |
AppendText(tekst); |
AppendText(tekst); |
472 |
} |
} |
473 |
} |
} |
474 |
|
Sleep(5); //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) |
924 |
CString SQL, name, value; |
CString SQL, name, value; |
925 |
SQL = "select name, value from config;"; |
SQL = "select name, value from config;"; |
926 |
CRecordset rs(&db); |
CRecordset rs(&db); |
927 |
rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); |
try |
|
if (rs.GetRecordCount()>0) |
|
928 |
{ |
{ |
929 |
rs.MoveFirst(); |
rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); |
930 |
|
if (rs.GetRecordCount()>0) |
931 |
|
{ |
932 |
|
rs.MoveFirst(); |
933 |
|
|
934 |
rs.GetFieldValue((short)0, name); |
rs.GetFieldValue((short)0, name); |
935 |
rs.GetFieldValue(1,value); |
rs.GetFieldValue(1,value); |
936 |
|
|
937 |
Alive.name = name; |
Alive.name = name; |
938 |
Alive.value = value; |
Alive.value = value; |
939 |
Alive.tid = CTime::GetCurrentTime(); |
Alive.tid = CTime::GetCurrentTime(); |
940 |
if(Alive.name == "phonenr") |
if(Alive.name == "phonenr") |
941 |
{ |
{ |
942 |
Alive.Phonenr = value; |
Alive.Phonenr = value; |
943 |
} |
} |
944 |
|
|
945 |
buffer.push_back(Alive); |
buffer.push_back(Alive); |
946 |
rs.MoveNext(); |
rs.MoveNext(); |
947 |
|
|
948 |
|
} |
949 |
|
rs.Close(); |
950 |
|
return buffer; |
951 |
} |
} |
952 |
rs.Close(); |
catch (char * str) |
953 |
return buffer; |
{ |
954 |
|
AppendText("Keepalive failed, closing and opening the db connection again"); |
955 |
|
if(db.IsOpen()) |
956 |
|
{ |
957 |
|
db.Close(); |
958 |
|
AppendText("DB connection closed"); |
959 |
|
} |
960 |
|
if(!db.IsOpen()) |
961 |
|
{ |
962 |
|
DBConnect(); |
963 |
|
AppendText("DB connection started again"); |
964 |
|
} |
965 |
|
} |
966 |
|
|
967 |
|
|
968 |
} |
} |