Esempio n. 1
0
        public IList<StoredMessage> ReadMessages(string clientId, string withJid)
        {
            _connection.Open();
            var command = _connection.CreateCommand();

            command.CommandText = @"
            select * from history
            where client_id = @p1 and
            (from_jid = @p2 or to_jid = @p2)";

            command.CommandType = CommandType.Text;
            command.Parameters.Add(new SqliteParameter("@p1", clientId));
            command.Parameters.Add(new SqliteParameter("@p2", withJid));

            var reader = command.ExecuteReader();
            var result = new List<StoredMessage>();
            while (reader.Read())
            {
                var msg = new StoredMessage();
                msg.ClientId = reader.GetString(1);
                msg.From = reader.GetString(2);
                msg.To = reader.GetString(3);
                msg.Date = reader.GetInt64(4);
                msg.MessageXml = reader.GetString(5);
                result.Add(msg);
            }
            _connection.Close();
            return result;
        }
Esempio n. 2
0
 private HistoryItem ToHistoryItem(StoredMessage arg)
 {
     return new HistoryItem
     {
         Date = new DateTime(arg.Date),
         XmppMessage = ToMessage(arg.MessageXml),
         ClientId = Guid.Parse(arg.ClientId)
     };
 }