public List <LyncHEntity.LyncMessage> GetMessage(Contact contact, DateTime dtStart, DateTime dtEnd) { List <LyncMessage> list = new List <LyncMessage>(); try { lock (locker) { using (var connection = new SqliteConnection(DATABASE_NAME)) { using (var command = connection.CreateCommand()) { connection.Open(); command.CommandText = string.Format(@"SELECT * from Message where ContactId = '{0}' and MessageTime >= '{1}' and MessageTime < '{2}' order by strftime('%s',MessageTime)", contact.Id, DateTime2String(dtStart == DateTime.MinValue ? new DateTime(1970, 1, 1) : dtStart), DateTime2String(dtEnd)); using (var reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { LyncMessage message = new LyncMessage(); message.ContactId = int.Parse(reader["ContactId"].ToString()); message.MessageText = MessageFormatter.DecodeFromBase64(reader["MessageText"].ToString()); message.MessageTime = DateTime.Parse(reader["MessageTime"].ToString()); message.IsCompressed = bool.Parse(reader["IsCompressed"].ToString()); list.Add(message); } } reader.Close(); reader.Dispose(); } command.Dispose(); } connection.Close(); connection.Dispose(); } } } catch (SqliteException exp) { logger.Error(exp); } return(list); }