Ejemplo n.º 1
0
        public List <SkypeMessage> GetAllMessages(long fromId, SkypeChat chat)
        {
            List <SkypeMessage> result = new List <SkypeMessage>();

            if (chat == null)
            {
                return(result);
            }
            RunReader(string.Format("select * from messages where chatname = '{0}' and id>{1} order by timestamp", chat.Name, fromId),
                      reader =>
            {
                while (reader.Read())
                {
                    long id              = reader.GetInt64(reader.GetOrdinal("id"));
                    string from          = reader.GetString(reader.GetOrdinal("from_dispname"));
                    int messageType      = reader.GetInt32(reader.GetOrdinal("type"));
                    object identities    = reader.GetValue(reader.GetOrdinal("identities"));
                    object body          = reader.GetValue(reader.GetOrdinal("body_xml"));
                    long timestamp       = reader.GetInt64(reader.GetOrdinal("timestamp"));
                    DateTime time        = UnixTimeStampToDateTime(timestamp);
                    SkypeMessage message = new SkypeMessage
                    {
                        ID            = id,
                        Author        = from,
                        Message       = (body == null || body == DBNull.Value) ? string.Empty : body.ToString(),
                        PointedPerson = (identities == null || identities == DBNull.Value) ? string.Empty : identities.ToString(),
                        Chat          = chat,
                        Time          = time,
                        Type          = (MessageType)messageType
                    };
                    message.HandleMessageType();
                    result.Add(message);
                }
            });

            return(result);
        }
Ejemplo n.º 2
0
        public List<SkypeMessage> GetAllMessages(long fromId, SkypeChat chat)
        {
            List<SkypeMessage> result = new List<SkypeMessage>();
            if (chat == null)
            {
                return result;
            }
            RunReader(string.Format("select * from messages where chatname = '{0}' and id>{1} order by timestamp", chat.Name, fromId),
                reader =>
                {
                    while (reader.Read())
                    {
                        long id = reader.GetInt64(reader.GetOrdinal("id"));
                        string from = reader.GetString(reader.GetOrdinal("from_dispname"));
                        int messageType = reader.GetInt32(reader.GetOrdinal("type"));
                        object identities = reader.GetValue(reader.GetOrdinal("identities"));
                        object body = reader.GetValue(reader.GetOrdinal("body_xml"));
                        long timestamp = reader.GetInt64(reader.GetOrdinal("timestamp"));
                        DateTime time = UnixTimeStampToDateTime(timestamp);
                        SkypeMessage message = new SkypeMessage
                        {
                            ID = id,
                            Author = from,
                            Message = (body == null || body == DBNull.Value) ? string.Empty : body.ToString(),
                            PointedPerson = (identities == null || identities == DBNull.Value) ? string.Empty : identities.ToString(),
                            Chat = chat,
                            Time = time,
                            Type = (MessageType)messageType
                        };
                        message.HandleMessageType();
                        result.Add(message);
                    }
                });

            return result;
        }