{\r
DateTime date;\r
date.SetToGMTime();\r
- date.Add(0,0,-1);\r
+ int currentday=date.GetDay();\r
+ date.Add(0,0,-6);\r
+ // insert trust lists every 6 hours - if 6 hours ago was different day then set to midnight of current day to insert list today ASAP\r
+ if(currentday!=date.GetDay())\r
+ {\r
+ date.Set(date.GetYear(),date.GetMonth(),currentday);\r
+ }\r
SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID, PrivateKey FROM tblLocalIdentity WHERE PrivateKey IS NOT NULL AND PrivateKey <> '' AND PublishTrustList='true' AND InsertingTrustList='false' AND (LastInsertedTrustList<='"+date.Format("%Y-%m-%d %H:%M:%S")+"' OR LastInsertedTrustList IS NULL);");\r
\r
if(rs.Empty()==false)\r
while(st.RowReturned())\r
{\r
st.ResultText(0,publickey);\r
- st.ResultInt(1,messagetrust);\r
- st.ResultInt(2,trustlisttrust);\r
+ if(st.ResultNull(1)==false)\r
+ {\r
+ st.ResultInt(1,messagetrust);\r
+ }\r
+ else\r
+ {\r
+ messagetrust=-1;\r
+ }\r
+ if(st.ResultNull(2)==false)\r
+ {\r
+ st.ResultInt(2,trustlisttrust);\r
+ }\r
+ else\r
+ {\r
+ trustlisttrust=-1;\r
+ }\r
xml.AddTrust(publickey,messagetrust,trustlisttrust);\r
st.Step();\r
}\r