Ejemplo n.º 1
0
        // Get a list of friends from `WCDB_Contact.sqlite`.
        public List <Person> GetWCDBFriends()
        {
            var friends = new List <Person>();

            using (var cmd = new SQLiteCommand("SELECT userName,dbContactRemark,dbContactChatRoom,dbContactHeadImage FROM Friend", WCDBConn))
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var friend = new Person {
                            UsrName = reader.GetString(0)
                        };
                        var sections = reader.TryGetBlobParse(1);
                        if (sections != null)
                        {
                            friend.NickName  = BlobParser.TryGetString(sections, 0x0a);
                            friend.Alias     = BlobParser.TryGetString(sections, 0x12);
                            friend.ConRemark = BlobParser.TryGetString(sections, 0x1a);
                        }
                        sections = reader.TryGetBlobParse(2);
                        if (sections != null)
                        {
                            friend.DbContactChatRoom = BlobParser.TryGetString(sections, 0x32);
                        }
                        sections = reader.TryGetBlobParse(3);
                        if (sections != null)
                        {
                            friend.Portrait   = BlobParser.TryGetString(sections, 0x12);
                            friend.PortraitHD = BlobParser.TryGetString(sections, 0x1a);
                        }
                        friends.Add(friend);
                    }
                }
            return(friends);
        }
Ejemplo n.º 2
0
 public static List <Section> TryGetBlobParse(this SQLiteDataReader reader, int i)
 {
     if (reader.IsDBNull(i))
     {
         return(null);
     }
     using (var stream = reader.GetStream(i))
     {
         return(BlobParser.Parse(stream));
     }
 }