Exemple #1
0
        private String addRealName(ChatList chL)
        {
            int            jj   = 0;
            String         name = "";
            Database       dat  = new Database("wa2.db");
            List <Contact> lc   = new List <Contact>();

            lc = dat.ListeContacts();
            dat.closeConnection();
            Contact contact = new Contact();

            while (jj < lc.Count())
            {
                contact = lc.ElementAt(jj);
                if (chL.getKey_remote_jid() == contact.getJid())
                {
                    name = contact.getDisplay_name();
                    break;
                }
                else
                {
                    if (chL.getSubject() != null && chL.getSubject() != "")
                    {
                        name = chL.getSubject();
                    }
                    else
                    {
                        name = contact.getJid();
                    }
                    jj++;
                }
            }

            return(name);
        }
Exemple #2
0
        public List <ChatList> listChat()
        {
            new Database();
            var           liste = new List <ChatList>();
            String        query = "SELECT chat_list._id as id ,chat_list.key_remote_jid, chat_list.subject, chat_list.creation, max(messages.timestamp) as max FROM chat_list LEFT OUTER JOIN messages on messages.key_remote_jid = chat_list.key_remote_jid  GROUP BY chat_list.key_remote_jid, chat_list.subject, chat_list.creation ORDER BY max(messages.timestamp) desc";
            SQLiteCommand myCmd = new SQLiteCommand(query, this.myConn);

            this.openConnection();
            SQLiteDataReader rslt = myCmd.ExecuteReader();

            if (rslt.HasRows)
            {
                while (rslt.Read())
                {
                    ChatList cl = new ChatList();
                    cl.setKey_remote_jid(rslt["key_remote_jid"].ToString());
                    cl.setId(rslt.GetDouble(0));
                    cl.setTimestamp(rslt.GetDouble(4));
                    //   if (rslt["creation"] != null )
                    //  {
                    //   cl.setCreation(rslt.GetFieldValue<double>(3)) ;
                    //  }
                    cl.setSubject(rslt["subject"].ToString());
                    liste.Add(cl);
                }
            }
            this.closeConnection();
            return(liste);
        }
Exemple #3
0
        // Charge la liste de chats de la base de données
        private void load_chatList(List <ChatList> chListe)
        {
            Database db = new Database();
            //var chListe = db.listChat();
            int    j     = 0;
            String verif = "";

            panel5.Controls.Clear();
            this.panel5.Controls.Add(btnSearch());
            this.panel5.Controls.Add(textBox());
            while (j < chListe.Count())
            {
                ChatList chL = new ChatList();
                chL = chListe.ElementAt(j);
                //  chat_cpnt cc = new chat_cpnt();
                contact_item_list cc = new contact_item_list();
                List <Contact>    lc = new List <Contact>();

                liste = db.listMessages(chL.getKey_remote_jid());
                cc.setNom(chL.getKey_remote_jid());
                cc.setNumero(liste.ElementAt(liste.Count() - 1).getData());


                DateTime t = convertTime(long.Parse(chL.getTimestamp().ToString()) / 1000);
                verif = String.Format("{0:dd/MM/yyyy}", t);
                msg   = chL.getKey_remote_jid();
                cc.setTime(verif);
                cc.Location = new System.Drawing.Point(0, 63 * j + 45);
                cc.setColor(Color.White);

                cc.lbl_t().Click += new System.EventHandler(this.test);
                //cc.Click += new System.EventHandler(this.test);
                System.IO.FileInfo file = new System.IO.FileInfo(@"wa2.db");
                if (System.IO.File.Exists(@"wa2.db") && file.Length > 5)
                {
                    cc.setNom(addRealName(chL));
                }
                panel5.Controls.Add(cc);
                //panel5.Controls.Add(cc);
                // panel5.BringToFront();
                liste = null;

                j++;
            }
            panel5.BringToFront();
            panel7.SendToBack();
            //db.closeConnection();
            messageContrl1.label2.Text = chListe.Count().ToString();
        }